I need to add a force to an object based on the local vector of the object that is hitting it and not the world coordinates or local coordinates of the object being hit.

I have the following script attached the the “projectile” I thought that the “direction” variable take the vector3 of the owner of the script but it did not. I am a novice and I appreciate any help.`using UnityEngine;
using System.Collections;

public class Projectile : MonoBehaviour

{
public float power;
private Vector3 direction;

void OnTriggerEnter(Collider other)
{
	direction = Vector3.forward;
	other.rigidbody.AddRelativeForce(direction * power);
}

}`

Thanks!

Vector3.forward is the global forward (Z-axis, (0,0,1)) Vector. If you want the local forward, you need to use the transform’s forward, helpfully named transform.forward.

So your code would be:

void OnTriggerEnter(Collider other)
{
    direction = transform.forward;
    other.rigidbody.AddRelativeForce(direction * power);
}