Referencing a game object with contents of a variable

Hi All,

I want to create a function that I can call and pass the name of a game object to it as a parameter. This object will then carry out the code stored in the function eg transformation, opacity change etc. Can this be done with the name of the object that the student assigns or with the object ID?

Any help would be greatly appreciated.

Both. You can use this CoBlock:

like this:

Consider why this is needed though - you could simply pass the game object.

Hope this helps! Let me know if you have any further questions about this. If this solves your issue, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

Hi Geoff,

Thanks for that - so with regards to passing the game object, are you meaning just use the get item block and use that in a function parameter?

Hi again

I have just tried it and it works - it is certainly a lot easier this way. Thank you for pointing this out so promptly Geoff.