I have a problem. I am trying to make a raycast trigger, that when my mainObject collides with the otherObject, the manObject shall the mainObject give the otherObject a force so it it flies up in the y axis.
here’s my script so far:
var Size = 0.000;
function Raycast () {
var collision = Collision;
var up = transform.TransformDirection(Vector3.up);
Debug.DrawRay(transform.position, -up * Size, Color.green);
if (Physics.Raycast(transform.position, -up, Size))
{
Debug.Log("Hit");
Destroy (gameObject);
}
}
Heres the force script
rigidbody.velocity = new Vector3(0, 0, 0);
rigidbody.AddForce(new Vector3(0, 700, 0), ForceMode.Force);