x


Trigger Spawning?

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 ));

}
}
more ▼

asked Jan 01 '12 at 02:58 AM

kewlhead gravatar image

kewlhead
16 6 8 8

Don't mind the Tigger... fixed that and it works for spawning... But I'm still not sure on how to only spawn one at a time.

Jan 01 '12 at 03:37 AM kewlhead
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Use GetButtonDown instead of GetButton.

more ▼

answered Jan 01 '12 at 03:43 AM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2504
x1705
x986
x441
x337

asked: Jan 01 '12 at 02:58 AM

Seen: 861 times

Last Updated: Jan 01 '12 at 11:36 PM