![godot kinematicbody2d godot kinematicbody2d](http://liuqingwen.me/2018/12/30/introduction-of-godot-3-part-12-talk-about-collision-and-move-and-collide-vs-move-and-slide-in-kinematicbody2d/godot_12_collision_response.gif)
I asked a variant of this question on a Godot forum, but am also asking it here for increased visibility. What's wrong and how can I achieve the desired movement? This is confirmed by analyzing the collision object move_and_collide(remainder). The problem seems to be that when I move the player by the remainder, the player is still colliding with the block, even though I move the block itself in the previous line. if collider in get_tree().get_nodes_in_group("moveables"):Ĭollider.global_position.x += remainder.x Ideally, the player would push the block without losing any velocity.Įven if I directly update only the horizontal position of my block, it still moves slower than expected, and my player sprite is blurred, presumably because of collision corrections. This code does allow the player to push the block, but only slowly. Move_and_collide(remainder) # move player by remainder If collider in get_tree().get_nodes_in_group("moveables"):Ĭollider.move_and_collide(remainder) # move block by remainder Var horizontal_movement = Vector2(remainder.x, 0)
![godot kinematicbody2d godot kinematicbody2d](https://game-blog.sethcorker.com/static/1656fc429f679736ac60db7f427f1071/5d8bd/editor.png)
# reset y vel so it doesn't keep accumulating What is wrong DigoFreitas Posts: 7 Member. Bug on boxes pushing another boxes (KinematicBody2D). Var collision_angle = rad2deg(acos(normal.dot(Vector2(0,-1)))) 7.6K Godot Help 1K General Support 76 Audio 327 GUI 939 3D 1.2K 2D 347 Shaders 3.4K Programming 246 Optimizing and Exporting 413 Forum 100 Forum Chat Home Programming. Var collision = move_and_collide(vel * delta) My block is in a group called moveables, has no script, and has no other forces acting on it.Īfter I calculate the velocity of my player in _physics_process(), I have the following code. a KinematicBody2D with two children: Sprite and CollisionShape2D Godot is. When I collide with a block which is also a KinematicBody2D I'd like my player to push it without losing velocity. your app with a different build of the engine Godot rates 4 r/Pla圜anvas. I am working in Godot 3, where my player is a KinematicBody2D.