I’m trying to get some cargo to deposit into my truck when I drive under a dump and press a certain button. I got it set up to where I could drop cargo at any time by a button press, but I need it to only happen when I’m under the dump. Also, is there any way to limit to one piece of cargo spawned a a time? Thanks.
Here’s the code so far:
var cargo : Rigidbody;
var speed = 1;
function OnTiggerEnter(other : Collider){
if (Input.GetButton ("Fire1")) {
clone = Instantiate(cargo, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection( Vector3 ( 0, speed, 0 ));
}
}