Question by
Aunty · Feb 09, 2017 at 03:55 PM ·
2d-physics
Rotating an isometric enemy to face the player.
Hey guys probably a really silly question but I'm currently making my HSC major work for my software class and I cant for the life of me face my enemy ships at my player.
Here is a video of the problem https://youtu.be/xlHZ3Z4-akQ and here is my scripting: using UnityEngine; using System.Collections;
public class EnemyScript : MonoBehaviour {
public Transform target;
public float speed;
void Update()
{
// rotate the enemy ship to face the player ship
transform.LookAt(target.position);
//correcting the original rotation
transform.Rotate(new Vector3(0, -90, 0), Space.Self);
//me struggling to get the ship to face the right way ( unsuccessfully)
transform.localEulerAngles = transform.eulerAngles + (new Vector3(0, 0, 0 * transform.eulerAngles.x));
{
transform.Translate(new Vector3(speed * Time.deltaTime, 0, 0));
}
}
}
Comment
I tried switching it up on the scale on the enemy but im either horrid at maths or it doesn't work that way.
Your answer