I'm trying to script a cube where upon going through a bigger cube, it increases speed. Here's my code:
The console reads the Debug Log "We've finally touched!" so it's detecting collision and the trigger does work.
So why isn't a force being added to the cube? I was thinking maybe it's because I have this in an OnTriggerEnter method and that it's only adding a force to the rigidbody for one frame?
I'd appreciate any assistance. Thank you for your time.
As force is applied over time but OnTriggerEnter only happens once per event, you need to use Impulse Force Mode in your Add Force :
ForceMode.Impulse : http://docs.unity3d.com/Documentation/ScriptReference/ForceMode.Impulse.html
all ForceModes : http://docs.unity3d.com/Documentation/ScriptReference/ForceMode.html
Replace the Addforce line in your script to :
or you may want to use :