Greetings,
I’m at work on a more serious, larger project right now. If I want to make the code useable, I need to make it REuseable. So I’m in the process of making some functions for my events, but I ran into a major issue…
Before I get to that, let me show you a Construct 3 function (KiwiStory example):
Let me point out 2 things here:
- You can define the “enemies” family without needing to make a parameter for it.
- There’s another function nested inside this one, Explosion_1, and it works perfectly without needing parameters.
Now, let me show you what I was trying to do:
Confession time. I’m not a fan of the way GDevelop’s functions work…
If you want to refer to objects, variables, behaviors, ANYTHING really, you need to add an entire parameter for it, and definite it in the function call. You can lock them to specific objects either, so you can put pretty much any object in that parameter.
Also note that I tried to nest the “respawn” function inside of the “hurt” function, in an attempt to make the code tidier (And in case I need to use the respawn function elsewhere). However, since I have the “respawn” function referring to a composite part of the player (Robirdy in this case), now the “Hurt” function needs the composite object AND it’s variable in it, just so the nesting can work…
Let’s go back to Construct 3 event. If I were to make that in GDevelop, I would need to add a parameter for the Health variable. Worse yet, if that nested function were to work at all, I would need to add parameters for the explosion object, the animations, AND the behavior within the enemy damage function, on top of having to add them as parameters in the Explosion_1 function too!
Basically, I’m wondering…
Is there a secret technique in GDevelop that lets me refer to things OUTSIDE of a function without needed a parameter for it like Construct 3 does?