- Home /
I can't shoot up or down. HELP!
i can only shoot straight forward, not up and down! Script;
var projectile : Rigidbody; var speed = 20;
function Update () {
if(Input.GetButton("Fire1")) {
clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = transform.TransformDirection(Vector3(0,0,speed));
Destroy(clone.gameObject,3);
}}
Answer by fafase · Oct 29, 2012 at 06:25 PM
try with.
clone.rigidbody.AddForce(transform.forward*force);
That goes ins$$anonymous$$d of your clone.velocity = transform.TransformDirection(Vector3(0,0,speed));
Remove that one, declare a var force:float; then start shooting. Depending on how you want the projectile to go increase the value. Don't be scared to start with 100 or more. This way your projectile will use physics meaning it will be affected by gravity. The path of your projectile will be a curve just like anything in the world (that has no constant thrust...).
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
A node in a childnode? 1 Answer
Shooting Script Instantiate Problems. Help? 0 Answers
Unity is acting REALLY weird 0 Answers
Enemy AI problems & Tree problems 0 Answers