Unity 2D lookat and shoot issues
Hi, I am trying to figure out this problem for quite some time, but can't seem to find solution. I looked already on forums and here in unity questions, but can't find the fix.
So a little brief: I am making boss in space shooter game and he has bullets that follow player. They work and bullets shoot towards player. Problem is that bullets use LookAt to rotate and then rotate on x,y,z axis. I need them only to rotate on x and y axis.
TLDR: Bullets look squished and sphere like when shooting, how to make them look okay?
public static bool canFire4 = false; public GameObject shotPrefab; private GameObject player;
public float fireRate;
private float nextFire;
void Start(){
player = GameObject.FindGameObjectWithTag ("Player");
}
void Update(){
if (Time.time > nextFire && canFire4) {
nextFire = Time.time + fireRate;
Debug.DrawLine (transform.position, player.transform.position, Color.red);
transform.LookAt (player.transform);
Instantiate (shotPrefab, transform.position, transform.rotation);
}
}
Your answer
Follow this Question
Related Questions
LookAt() rotating the wrong way 0 Answers
How can i rotate an object using LookAt with only 1 axis? 0 Answers
Flip 3D Character Rotation 180 on Y axis 1 Answer
Problems With .rotate behavior 1 Answer
How can I set rotation properly? 0 Answers