|
enter code hereThe title sums up my problem. I have a game that seems to run fine when I try to play it through the play button at the top of the screen. All of my scripts run just fine and no errors come up. Unfortunately, now that the game is done and we're ready to put it in the quarterly art show, we've run into a snag. When we hit build and run, some of the triggers break. The first simply triggers an animation on a swinging wrecking ball. I know the animation works, because another script that triggers it when I left click (for testing purposes) can sometimes trigger it. Then again some times I build the project it can't. I havn't changed anything, but the results sometimes differ! The second is similar. Its a trigger over a portion of walkway that drops out from under the player. Again, It can be triggered with click commands, but the trigger seems to fail entirely. I almost hope I'm doing something wrong. At least that way I can fix it and never have to deal with this again. Thanks for your help in advance!
(comments are locked)
|

I'm not sure if this is a mistake on your part, but I don't ever use OnTriggerEnter inside of the Update loop, I'm surprised that it even compiles. Your code inside OnTriggerEnter seems perfectly legitimate, save for the fact that it's in update, and you should almost never use GameObject.Find inside of update.
Even for desktop platforms, it is highly suggested to call GameObject.Find on a SINGLE event, and cache the component rather than refreshing the reference every frame. I can see that this probably wasn't your intention, but just a forewarning.
danny, think you just misread the {}s, that's an empty Update() function before OnTriggerEnter(). :)
Haha that's what happens when you stare at code all day my mistake. Have you tried using incollisionenter instead? I'm assuming since they sometimes work that the istrigger is checked in the inspector? Have you tried putting a print to make sure that ontrigger is getting called?