Add force to the object

Hey guys,

I have some problems for the game that I am trying to make. My character is a ball and I wondering how I can act something like, if the ball goes to a specifiek object like jump object or speed boost…how can I add extra force on that ball object.

Since on OnTriggerEnter() or OnCollisionEnter() is not possible to use the AddForce command…so anyone have idea how else I can make this work?

Here is my code for the ball character:

function OnTriggerEnter(other : Collider) {

   //if deadzone is been entered
   if(other.tag == "DeadZone")
   {
	
   }


	if(other.tag == "Finish")
	{
	
	//play the sound
	other.audio.Play();
	//yield WaitForSeconds(1);
	Application.LoadLevel(nextLevel);
		//Show other level
	Destroy(other.gameObject);
	//if the ring is hit load a new game
	//Application.LoadLevel(nextLevel);
	//if there is no level destory the object
	Destroy(gameObject);

	}
	if(other.tag =="Crystal")
	{
	other.audio.Play();
	yield WaitForSeconds(0.4);
	Destroy(other.gameObject);
	}
	
	if(other.tag =="PowerSpeed")
	{
	//Should give the object extra movement
	}
	
}

Any suggestions or ideas how I can able to make this work is welcome.

if you have a rigidbody attached to your game object, just add a velocity in the direction you want the object to go to.

rigidbody.velocity += direction * force;

Hi Guys

I am facing the same problem I have two characters both have character controller attached to them additional capsule colliders added to them with the “Is Trigger” property checked.

in my code im trying to detech the collision between them add force, using the “OnTriggerEnter” functions

this is my code :

However i am unable to addforce to the object that is “AIPlayer”
can you please explain my why is this happening?

Thank you