- Home /
Projecting created objects?
Okay so I'm doing a project for school and I'm using this script to create random objects (trash)...I'm still new to scripting, but I wanted to know if I if there was something I could do to this script to make the objects project forward. If i can't do that, I guess I need to know what script would work best to project objects as if you were throwing them.
thanks in advance, you guys are great.
var trash : GameObject[];
function Update () {
if (Input.GetButtonDown("Fire1")) {
Instantiate (trash[Random.Range(0, trash.Length)], transform.position, transform.rotation);
}
}
Answer by rutter · Apr 14, 2012 at 01:07 AM
When you say "project forward", you mean that you want them to move?
If so, you can attach a rigidbody and give it some velocity. There's a pretty simple example for this at Unity's manual page on instantiating prefabs, which goes over the basics of spawning "missile" objects.
Answer by pileofdeadninjas · Apr 14, 2012 at 02:11 AM
i guess that was a little vague, but i just want to throw them forward. I'll see what I can do with that guide for now