How do you detect when a player and enemy collide?

ManiacBananaManiacBanana Posts: 11Member

My player is a kinetmaticbody2d with collisionshape2d. So is the enemy. Is there any straight forward way to do this? I just want to open a new scene when the player and enemy touch. I tried using an area2d on the enemy but it complains that it has no shape unless I put a second collisionshape on it, and then it just didnt show that it was colliding with the player.

Thanks!


Tags :

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 3,540Admin

    You might be able to detect collisions with an enemy and a KinematicBody2D using the get_slide_collision function (documentation). I have not used it myself, but it looks like it returns a bunch of information relating to KinematicBody2D collisions, including the body each collision made contact with.

    Also, welcome to the forums! :smile:

  • ManiacBananaManiacBanana Posts: 11Member

    Thanks! I've been through that page so many times i never actually noticed that method.
    Oh my goodness it worked! Thank you so much!

Sign In or Register to comment.