Tip for function object parameters

Just wanted to point out something to remember when working with function parameters and objects for newer people, because I sometimes still trip myself up on it even though I’m more comfortable with functions now.

Your object parameter can have a different name than the actual object on a scene.

I know it’s probably a better practice to call it the same thing, to avoid confusion. But it happens. Sometimes I think of a simpler name later and don’t want to rename the actual object, especially if it is in use by other functions and would be time consuming to change everything since objects in extensions aren’t automatically renamed (which I like for some situations).

The main thing to remember in this case is that the events inside the function need to reference the object by its parameter name, not its scene name. When you add the function to your scene or external event sheet, you can then select the associated object from your scene for that parameter.

If you don’t know this and used different names in the ‘wrong’ places, you might think the function is broken or wonder why it isn’t working as expected.

1 Like

This is indeed true :slight_smile: Functions are running in their own “context”, as defined by the names of the parameters - which can be different than object on the scene. In a function, the scene objects do not “exist anymore”.

1 Like

Thank you for confirming the info, 4ian :slight_smile:


Applies for any object variables in functions as well.


For example, let’s say you want to use a variable to define the damage of a bullet because maybe you want it to do more or less depending on the scene.

On the scene, the object is named bullet, but in the function you called it slug.
You would write “slug.Variable(damage)” not “bullet.Variable(damage)”.