OnTriggerEnter Speed Help

Hey guys, just wondering, im trying to do some scripting here, and the goal is to get my sphere to speed up when it hits something.

My sphere is rolling down a “hill” using only gravity, and im trying to get it to speed up when it hits a trigger. I dont have any scripts attached to the sphere, and all I have for the Trigger is function OnTriggerEnter (other : Collider) {

I cant figure out how to get it to acces the sphere and speed it up. Heck, I dont know how to make it roll faster regardless! Any help?

Bump :frowning:

Try adding a force to it.

but how do I get the trigger to acces the force on the sphere when it hits it?

you can try something like this

function OnTriggerEnter (Hit : Collider)
{
      if(Hit.gameObject.tag == "Speed*")
      {
      rigidbody.AddForce(insert where you want it to go here)
      }
}

*Speed being the Tag of the collider :slight_smile:

function OnTriggerEnter(hit : Collider)
{
   if(hit.gameObject.tag == "Speed*") {
         rigidbody.velocity = rigidbody.velocity * 1.1;
         rigidbody.angularVelocity = rigidbody.angularVelocity * 1.1;
   }
}

The above is if the script is on the rolling object.

function OnTriggerEnter(hit : Collider)
{
   if(hit.rigidbody) {
         hit.rigidbody.velocity = hit.rigidbody.velocity * 1.1;
         hit.rigidbody.angularVelocity = hit.rigidbody.angularVelocity * 1.1;
   }
}

The above is if the script is on the trigger.

Thanks all of you. I hope to become a bigger part of this community soon. :slight_smile: