Hey everyone, I’m working on a small project again. I’m just an artist so I have not a lot of experience with scripting and I would like some help with a simple script.
I have an fbx object (objectA) with an animation linked to it and I want to replace it with another animated object (objectB) when I push the ‘up arrow key’. So objectB should appear on the same place as objectA, while ObjectA gets removed.
How should I do this? Thanks in advance!
First thing, Create an empty game object, and attach both objects to it, In your script, disable all objects you dont want to be seen, then enable the one you do. Start it’s animation.
Next, use the Input.GetKey(KeyCode.UpArrow) and disable all objects, and enable the UpArrow object, Start it’s animation.
Now, this may not work due to the disableing of the UpArrow object. If not, you will have to make a function that disables every object and enables the one that you want. (very simple) While your at it, make sure that it starts if it is not running.
You will need a set of GameObject variables to house all of your animation sequences, the function would go through them all and disable what is not the one you want enabled and enable the one you do. The point is to make sure that the object is never disabled when your animating it. Then, if is not playing, make it play.