- Home /
I can't shoot back
Ok, so I am relativly new to unity, and I have started a "Top Down shooter" I can move an all, I can shoot in any direction forward, but when I try to shoot backwards the bullet just appears, but it doesn't move. I can shoot up, up-right. right, left, up-left, but any direction that includes down the bullet doesn't move. Please help...
here is the script:
var speed = 6.0; var gravity = 20.0; var bulletPrefab:Transform;
private var moveDirection = Vector3.zero;
function FixedUpdate() { var controller : CharacterController = GetComponent(CharacterController); if (controller.isGrounded) {
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
if (moveDirection != Vector3.zero) {
var rotation = transform.rotation;
rotation.SetLookRotation(moveDirection);
transform.rotation = rotation;
}
moveDirection *= speed;
if(Input.GetButtonDown("Jump")) {
var bullet = Instantiate(bulletPrefab,
GameObject.Find("spawnFireBall").transform.position,
Quaternion.identity);
bullet.rigidbody.AddForce(transform.forward * 1200);
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
is your spawn point ai$$anonymous$$g right when shooting down? Also as a side note, i think is better put your spawnpoint into a var:
var yourSpawnPoint : Transform;
And then:
var bullet = Instantiate(bulletPrefab, yourSpawnPoint.position, yourSpawnPoint.rotation);
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer
Shooting and changing bullet 1 Answer
Need help with shooting script 2 Answers
shooting gun help 0 Answers