KinematicBody annual engine movement does not work

I played with Godot-Engine and tried a little game.

But I can’t get collision information.

if is_colliding():
    print ("Collision with " + get_collider())
    get_node("Sprite").set_texture(walk_cycle_right_1)
    move_state_right = 1
    set_pos(Vector2(get_pos().x -10, get_pos().y))

It always prints false. I move my character ( KinematicBody2dSprite/CollisionShape2d) with the command set_pos.

+4
source share
1 answer

For a kinematic body, you need to use move or move_to to trigger a collision. If you really need to use set_pos, check collisionshape2d.shape and do a collision check.

Godot, KinematicBody2D collisiong: http://docs.godotengine.org/en/stable/tutorials/2d/kinematic_character_2d.html

KinematicBody2D Godot: http://docs.godotengine.org/en/stable/classes/class_kinematicbody2d.html?highlight=KinematicBody2D

+2

Source: https://habr.com/ru/post/1665135/


All Articles