Invalid call. Nonexistent function 'bounce' in base 'TileMap'.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tjoeser

This is my code

func _on_top_checker_body_entered(body):
speed = 0

so its about body.bounce()

What do I do?

:bust_in_silhouette: Reply From: timothybrentwood

What’s going on is the body object is a TileMap object. TileMap objects do not have a bounce() function declared in their class so it crashes.
The quick and dirty solution is:

func _on_top_checker_body_entered(body):
    if body.has_method("bounce"):
        speed = 0

To give you a more accurate solution I would need to know what object you want to bounce(). Do you want to bounce() the parent object of your topchecker object? If so change body.bounce() to get_parent().bounce().

That is part of my enemie script and its supposed to make my Player bounce. When I # the line I just hit the enemie without bouncing. I tried “get_parent().bounce()” and it didn’t work.

Update: i copied your code and modified it a bit and it works thank you so much!!

Tjoeser | 2021-06-13 21:31