x


rocket if fire 2 problems

ok im trying to make a rocket shoot out with this script when i click right click ( fire 2) but my version wont work it only happens when i left click. how do i instantiate this script when i click fire 2

var projectile : Rigidbody;
var initialSpeed = 20.0;
var reloadTime = 0.5;
var ammoCount = 20;
private var lastShot = -10.0;

function Fire () {
    // Did the time exceed the reload time?
    if (Time.time > reloadTime + lastShot && ammoCount > 0) {
        // create a new projectile, use the same position and rotation as the Launcher.
        var instantiatedProjectile : Rigidbody = Instantiate (projectile, transform.position, transform.rotation);

        // Give it an initial forward velocity. The direction is along the z-axis of the missile launcher's transform.
        instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, 0, initialSpeed));

        // Ignore collisions between the missile and the character controller
        Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);

        lastShot = Time.time;
        ammoCount--;
    }
}
more ▼

asked Jun 28 '10 at 08:18 PM

james 1 gravatar image

james 1
15 5 5 6

You're probably using web player, try it in stand along

Jun 28 '10 at 08:39 PM spinaljack

no im not using a web player i just want that script to start when i right click

Jun 28 '10 at 09:00 PM james 1

i know that if(Input.GetButtonDown)) {} has to be in there but where and how

Jun 28 '10 at 09:02 PM james 1
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Try:

function Update()
{
  if (Input.GetMouseButtonDown(1))
  {
    Fire();
  }
}
more ▼

answered Jun 28 '10 at 10:02 PM

Deikkan gravatar image

Deikkan
198 8 9 19

this does help but it still shoots when i left click

Jun 29 '10 at 04:33 AM james 1

oh and i made an account called bytyan

Jun 29 '10 at 04:33 AM james 1

Sounds like somewhere in one of your scripts, you still have a method that takes an Input.GetButtonDown("Fire1") condition. Just remove that code

Jun 29 '10 at 05:36 AM Deikkan
(comments are locked)
10|3000 characters needed characters left

Check Edit -> project settings Input for what key you have for Fire1

And use this line: if (Input.GetButton ("Fire1")){ Shoot();}

more ▼

answered Jul 03 '10 at 11:56 AM

TaigaStudios gravatar image

TaigaStudios
242 3 4 16

(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:

x5060
x329
x38

asked: Jun 28 '10 at 08:18 PM

Seen: 785 times

Last Updated: Jun 28 '10 at 08:26 PM