Hey there!
So i need to change some things what means i cant use NavMeshAgent for that,
so i got an CharacterController which should move from Point A to Point B,
i got a simple funciton which does that for me:
public void MoveTowardsTarget(Vector3 target)
{
Vector3 destination = target - transform.position;
if (destination.magnitude > .1f)
{
//Move to Direction
destination = destination.normalized * MaxWalkSpeed;
characterController.Move(destination * Time.deltaTime);
//Look at Direction
destination.y = transform.position.y;
Quaternion targetRot = Quaternion.LookRotation(destination - transform.position, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, Time.deltaTime * 2f);
}
}
if i put that one in the Update Loop it works but if i put that into a coroutine:
IEnumerator test()
{
while (!isAtTarget(target.transform.position))
{
MoveTowardsTarget(target.transform.position);
}
yield return null;
}
Unity Crashes … , anyone any idea?