![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | wooshuwu |
I’m trying to convert a tutorial script that’s in gdscript to c# as I am more comfortable with it. However, in the tutorial script they are able to call a method from an object, whose datatype will be a RigidBody child, from the function parameters only if it exists, i.e. after checking the existence with the has_method function. However, I can’t seem to find a way to call the function from the object in c# as it’s a function that’s going to be a custom method in a child class (of a RigidBody). Is there a way to do this in c# or is it only usable for gdscript?
Can you show us the GDscript example?
juppi | 2022-01-30 10:01
The GDScript example goes as shows:
func collided(body):
if hit_something == false:
if body.has_method("bullet_hit"):
body.bullet_hit(BULLET_DAMAGE, global_transform)
hit_something is a property of the overall object. bullet_hit is a method of a different class that will be created later in the tutorial. For c#, is there a way to call it even if the class has not been created yet similar to the gdscript or will I only be able to call the function once the class is created and the function is defined?
wooshuwu | 2022-01-30 10:36