AddForce() to one object relative to another object.

I have a boost platform and Im trying to make it so that when the player collides with trigger, AddForce() is applied to the direction of the Z axis of the boost platform. This way i can change rotation during gameplay and the AddForce() direction changes too.
Here’s my code but for some reason the force doesn’t apply. I get no error but i think its the argument for force, but i dont know how to fix it.

#pragma strict


function OnTriggerEnter(collision : Collider)
{
 if(collision.gameObject.tag == "Player")//Ball Collide Speed 
 {
 Debug.Log(transform.forward);
 collision.gameObject.rigidbody.AddForce(transform.forward * 100);
 }
}

Hello, I’m a beginner and I don’t guarantee that my answer is right but I think that your code is a little bit wrong. Here, try this :

#pragma strict

function OnTriggerEnter(someName : Collision)
{

if
(someName.collider.gameObject.tag == “Player”)//Ball Collide Speed
{

Debug.Log(transform.forward);

someName.rigidbody.AddForce(transform.forward * 100, ForceMode.Acceleration);
}
}

Again, I am no expert at all so please let me know if I helped you in any way. :slight_smile:

PS: I would use Mathf.MoveTowards instead in order to move the platform.