|
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)
How do I fix this? Thanks.
(comments are locked)
|
|
It looks like the transform "forward" that you're referring to in that last line is the transform of whatever GameObject this script is attached to, rather than the transform of the bullet or the gun, which is probably what you need:
Alternatively, you could add a Constant Force Component to the bullet prefab and it could handle its own motion. That worked, thanks!
Mar 06 '10 at 08:26 PM
Steve 1
my bar at the bottom keeps on saying, insert a semicolon at the end
Oct 14 '10 at 01:32 AM
Joe 8
It simply means you need to insert a semicolon on the line as instructed. If you new to Unity, Please, rather then relying on people here to make the game for you, read a book. Thank you,
Nov 11 '12 at 05:45 AM
3
Where do I put this script? What I have is: First Person Controller Graphics (don't worry about this) Main Camera M4 (which is the texture of my gun) I put the script in M4 but it didn't work. Where should I put it?
Dec 05 '12 at 07:00 AM
Starman385
it works fantastic thanks
Dec 28 '12 at 11:13 AM
Nick Carpeggiani
(comments are locked)
|
|
var BulletPrefab :Transform; var force : float = 2000; function Update() { if(Input.GetButtonDown("Fire1")) { var bullet = Instantiate(BulletPrefab, GameObject.Find("spawnPoint").transform.position, Quaternion.identity); bullet.rigidbody.AddForce(transform.forward * force); } } try this script.make sure that your bullet prefab has a rigidbody attached to it.
(comments are locked)
|
|
if the spawnpoint is at th end of the gun, and if it follows the camera this shouldn't happen.
(comments are locked)
|
|
I Dont see my bullit fly away can somebody help me please??? :( Ok, you see what you just did there? That's not an answer, that's another question- and it's not even a good one. Please, don't do that.
Oct 24 '11 at 07:34 AM
syclamoth
(comments are locked)
|
