- Home /
Question by
a_p_squared · Mar 30, 2021 at 03:41 PM ·
iosainavmeshnavmeshagentnavigation
Runtime Navmesh not working on mobile build
I am using the Unity Navmesh Components system for the movement of a group of characters. The system is working perfectly in the editor but the characters are not moving in the iOS build. I can't seem to find any other posts regarding this issue.
I am not sure if the code is relevant to the issue since it is working fine in the editor, but here it is for reference.
public void MoveToPosition(Vector3 position)
{
if(runningCoroutine != null)
{
StopCoroutine(runningCoroutine);
runningCoroutine = null;
}
else
{
runningCoroutine = StartCoroutine(moveToPosition(position));
}
}
IEnumerator moveToPosition(Vector3 position)
{
SetWalking(true);
SetNavMovement(position);
float time = 0.0f;
Vector3 startPos = _transform.position;
while (!_navAgent.isStopped)
{
if ((_transform.position - startPos).magnitude > 1.0f)
{
startPos = _transform.position;
time = 0.0f;
yield return null;
}
else
{
time += Time.deltaTime;
if(time > 2.0f)
{
_navAgent.isStopped = true;
}
yield return null;
}
}
SetWalking(false);
}
private void SetWalking(bool value)
{
isMoving = value;
_animator.SetBool("isWalking", value);
}
private void SetNavMovement(Vector3 position)
{
_navAgent.isStopped = false;
_navAgent.destination = position;
}
I've been looking for a fix for a couple of days now and I would really appreciate some help. Thanks in advance.
Comment