Hello i have a problem with my script. Trying to add force to this gameobject when i shoot it with my raycast. And it will move AWAY from the player (where the raycast it casted from). But i get a nasty error:
"Operator '-' cannot be used with a left hand side of type 'UnityEngine.Transform' and a right hand side of type 'UnityEngine.Transform'."
Script:
#pragma strict
var rb : Rigidbody;
var force : float;
var PlayerPosition : Transform;
var HittedObjectPosition : Transform;
function AddForceFunction ()
{
rb.AddForce(PlayerPosition - HittedObjectPosition).Normalized * force;
}."
↧