- Home /
Y Axis fpsshooter fallow
I am working on a fps, and i can get it to shoot, and to fallow the mouse side to side, but it will only shoot at a fixed height. i want it to shoot on the Y axis too. please help! (this is the script I'm using to shoot)
var projectile : Rigidbody; var speed = 20;
function Update()
{
if( Input.GetButton( "Fire1" ) )
{
var instantiatedProjectile : Rigidbody = Instantiate(
projectile, transform.position, transform.rotation );
instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );
Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );
}
}
Comment
Best Answer
Answer by syclamoth · Feb 29, 2012 at 12:19 AM
Well, instead of using the player's transform, why not just use the camera's?
Everywhere where you use 'transform', instead use 'Camera.main.transform'!
Your answer
Follow this Question
Related Questions
How do I put a delay on a gunshot? 2 Answers
Raycast Positioning 2 Answers
Problem creating a 2D scroller shooting game 2 Answers
GetComponent not Returning 1 Answer
about animation tab ? 1 Answer