Nonexistent function 'Collider' in base KinematicBody2D

theservertheserver Posts: 2Member

Hello there, i'm trying to detect collision between 2 KinematicBody2D in my scene, but whenever i try to use the move_and_collide().collider, it tells me the function does not exist... ?

Thank you in advance for your help !

Best Answer

  • cyberealitycybereality Posts: 927
    edited December 2019 Accepted Answer

    collider is an Object, not a function. You can do this:

    collision.get_collider()
    

    or

    collision.collider
    

Answers

  • cyberealitycybereality Posts: 927Moderator
    edited December 2019 Accepted Answer

    collider is an Object, not a function. You can do this:

    collision.get_collider()
    

    or

    collision.collider
    
  • cyberealitycybereality Posts: 927Moderator

    Also, welcome to the forum!

  • theservertheserver Posts: 2Member

    @cybereality , thank you, your answer helped me a lot. It's some rookie mistake, but i started using godot not so long ago. I guess i'll spend a lot of time on that forum trying to figure things out :)

  • cyberealitycybereality Posts: 927Moderator

    Awesome! So glad to help.

  • Dev_startDev_start Posts: 1Unconfirmed Member

    I tried this tactic but it says collision isn't in the current scope

  • TwistedTwiglegTwistedTwigleg Posts: 2,873Admin

    @Dev_start - Can you share the code you are using? If GDScript is saying a variable is not in the current scope, it generally means it is defined in the wrong location, like attempting to use a function-defined variable outside of the function it was defined in.


    Also:

    Also: This comment was caught in the moderation queue since you have not confirmed your account yet.

    Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

    If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file