I made a treasure chest that you find and you open it with a raycast, but the problem I have is after its open, if your raycast hits it the animation plays again. Its pretty stupid looking and i don't no how to fix it. This iss my code so far(only the important parts):
The solution is to remember the event of opening the chest, and only do the raycast test if the chest was not previously opened. For instance, you could have a
as an instance variable of that script, then do
when you open the chest (just before the Play("chestOpen") call), and finally, surround the entire raycast check with the following check:
Of course, since your game will likely have more things to interact with than a single chest, you will probably have to think up a more sophisticated way of tracking events than simple boolean variables, but this should solve your immediate problem.
answered Nov 16 '10 at 10:10 AM