// ------------------------------------------------------------------------ // prepare movement: try to go to you right field void FixedUpdate() { if (!Enable) { return; } if (actor.Walking || actor.nextFloor || Random.value % 0.25f == 0) { return; } if (actor.nextFieldAvailable(transform.right)) { actor.turnRight(); actor.move(transform.forward); } else if (actor.nextFieldAvailable(transform.forward)) { actor.move(transform.forward); } else if (actor.nextFieldAvailable(-transform.right)) { actor.turnLeft(); actor.move(transform.forward); } else if (actor.nextFieldAvailable(-transform.forward)) { actor.turnRight(); actor.turnRight(); actor.move(transform.forward); } }
// ------------------------------------------------------------------------ public virtual bool move(Vector3 direction) { if (!Enable) { Enable = true; } MoveActor m = GetComponent <MoveActor>(); if (m) { return(m.move(direction)); } return(false); }
// ------------------------------------------------------------------------ void FixedUpdate() { if (!Enable) { return; } if (actor.Walking || actor.nextFloor) { return; } if (actor.assignNextField(direction)) { actor.move(direction); } else if (actor.assignNextField(-direction)) { StartCoroutine(changeDirection()); } }