I’ve been having a problem with this, i can’t seem to move a gameobject diagonally towards a certain target between two points,i’ve tried positioning the gameobject using rotation but nothing seems to work and it never aligns with the path
void Start()
{
transform.position = points [0].transform.position;
time = Time.time;
endPosition = points [1].transform.position;
float pathlength = Vector3.Distance(startPosition,endPosition);
angle = Vector3.Angle (startPosition, endPosition);
transform.Rotate ((angle+-90)*Vector3.down);
}
void move()
{
Vector3 a = Quaternion.Euler(angle,0,0) * (Vector3.down + Vector3.left);
if (!(gameObject.transform.position.Equals(endPosition))) {
transform.position += a * Time.deltatime;
} else if(gameObject.transform.position.Equals(endPosition))
{
// add health script here
Destroy (gameObject);
}
}
void FixedUpdate()
{
move ();
}
,