x


Making a gun shoot

Hi, I'm new to Unity and I'm trying to make a simple FPS. My problem is that when I shoot, the bullet doesn't go where I'm aiming, it just shoots right in front of me even if I'm aiming all the way up or down. Here's a screenshot. http://img21.imageshack.us/img21/1820/screenshotxwq.png

Here's the script I used for shooting. (And I don't really know much about scripting, I just got this from tutorials and stuff)

var BulletPrefab:Transform;
var force : float = 2000;

function Update()
{
if(Input.GetButtonDown("Fire1"))
{
var bullet = Instantiate(BulletPrefab, 

GameObject.Find("spawnPoint").transform.position, 

GameObject.Find("Gun").transform.rotation);

bullet.rigidbody.AddForce(transform.forward * force);

}
}

How do I fix this?

Thanks.

more ▼

asked Mar 05 '10 at 02:06 AM

Steve 1 gravatar image

Steve 1
1 1 1 2

(comments are locked)
10|3000 characters needed characters left

4 answers: sort voted first
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:

x5076
x446
x308

asked: Mar 05 '10 at 02:06 AM

Seen: 17998 times

Last Updated: Dec 28 '12 at 11:13 AM