Hi,
I'm creating a custom Action in Adventure Creator to toggle a door (or any other object) open or closed. I’m not a programmer by trade, and I’ve been relying on ChatGPT to guide me. I set up parameters for the GameObjects in the ActionList so I can link them in the Inspector. However, even though the parameter fields look correctly assigned in the Editor, when I run the game and the custom Action is called, those parameters end up being null in code. The result is that my Action never finds the Animator or triggers anything because the reference doesn’t come through.
Here’s a summary of what happens:
1. Parameters are set to GameObject type in the ActionList (either in-scene or as an ActionList Asset).
2. I drag the desired GameObject from the scene into the parameter field in the Inspector.
3. At runtime, a debug log in my custom Action shows that param.gameObject (or param.objectValue) is null.
4. Consequently, my Action doesn’t have a valid reference to run GetComponent<Animator> or do anything else.
I’ve tried:
Maybe I cannot reference scene objects during runtime if they are not prefabs? (I watched the prefabs tutorial, and the difference in my case, is that I'm trying to create a prefab with parameters that I can reference with different gameObjects in the scene.)
No matter what I do, the parameter is always null in-game.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
I'd need to see the code to understand what's going on, but are you extracting the parameter's value in the AssignValues function?
A tutorial on adding parameters to a custom Action can be found here.
Here is the code and I'll take a look to the tutorial.
https://pastecode.io/s/tyqgv6fr
AC has its own functions to override a field with a parameter value. Replace:
with:
Got it! Thanks a lot!