Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Dava | |
Old Version | Published before Godot 3 was released. |
Hi, I’ve veen trying to add collision to my player and the environment, but adding collision in godot is way harder than i thought, i thought all we had to do was add the collision node to each of the object, add the collision box, then collision would work, but only thing that happens is that the player goes through the object so i tried adding it with scripts in many ways such as:
#player script
if(!get_node(".").is_colliding()):
set_pos(get_pos() + Vector2(0, -16))
anim.play("movement")
anim.seek(0, true)
yield(animator, "finished")
emit_signal("move")
pass
and this:
#player script
if(!get_node(".").is_colliding()):
if(Input.is_action_pressed("ui_up"):
move up()
I even tried this:
#player script
function _ready():
add_to_group("colliders")
func collision_check(body):
if(body.is_in_group("colliders")):
set_pos(0)
#other object script
func _ready():
add_to_group("colliders")
None worked, I really need help working with collision in godot
Could be simple or complicated depending on your design, care to share the scene structure? just that piece of code says too little about your problem.
eons | 2017-03-11 10:20
Not really sure how to, but for the player, the scene system is:
kinematicbody2D (with script)
- animatedsprite
- collisionshape2D
- animation
as for the object:
staticbody2d (with script)
- animation
hope this helps
Dava | 2017-03-11 14:34