- Home /
Problem with AIM to SHOOT script
I'm having a problem with a script, I'm really new to to coding but I don't see anything wrong with it. The script makes you have to hold down FIRE2 to press FIRE1 to shoot. Whenever I hold down FIRE2 and press FIRE1 it just won't shoot. It works when I take out the line with having to use FIRE2.
If anyone knows what I'm doing wrong with this code, I need help. Thanks in advanced!
var projectile : Transform;
function Start() {
}
function Update() {
if(Input.GetButtonDown("Fire2")) {
if (Input.GetButtonDown("Fire1")) {
var Clone : Transform;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.rigidbody.AddForce(clone.transform.forward * 1000);
rigidbody.AddRelativeForce(Vector3.forward * Time.deltaTime * 1000);
Physics.IgnoreCollision(clone.collider, collider);
}
}
}
Answer by robertbu · May 04, 2013 at 06:40 AM
Input.GetButtonDown() only returns true for the frame in which it is pressed. Replace it with:
Input.GetButton("Fire2");
Oh wow thanks a lot, I sure learned something XD It works now, I totally didn't know that Input.GetButtonDown() worked that way. Thanks again!
Your answer
Follow this Question
Related Questions
how do I shoot where my cross hair points? 0 Answers
3rd Person Gun Aim 1 Answer
Flamethrower in 2D? 1 Answer
aim down sights of gun 3 Answers
BCE0005: Unknown identifier: 'Fire'. / Secondary shot? 1 Answer