If the Alien is some kind of PhysicsBody2d i think you can check if it has the function eaten() with`
if body.has_function(“eaten”):
and then call the function.
Also the autocomplete in the editor will give you a complete list of functions for anything, and the docs can be accessed in the editor with the “Search Help” button.
Socrates | 2018-03-23 05:50
I followed your link but there are no functions in the list of a PhysicsBody2D like has_function() . Autocomplete doesn’t give me a list of functions I can call on Body. In fact it doesn’t give me anything when I push “.”
Where can I find a list of all the functions like body.get_name() or body.queue_free() or body.has_function()?
Thanks!
As a side note,
if body.has_function("eaten") is true, how would I call the function “eaten”?
EDIT: for the side note I did figure out that you can just call body.eaten() and it will work
ondesic | 2018-03-23 15:04
Sorry it should be has_method() not has_function()
Also, in the docs has_method is a method of the Object class, which PhysicsBody2d inherits from. All the classes a class inherits from can be found at the top of the appropriate docs page, e.g. PhysicsBody2D inherits from CollisionObject2d, Node2D, CanvasItem, etc. and you have to click on those things to see all the methods available to PhysicsBody2D. Not sure why autocomplete wouldn’t be working though.