Exemplo n.º 1
0
    private void FollowPath()
    {
        Vector3 target = patrolPath[pathIndex];

        //Utility.LogChangedValue("ReachedWaypoint", ReachedWaypoint (target));

        velocity = moveController.velocity;

        velocity.x    = target.x - transform.position.x;
        velocity.x    = Mathf.Sign(velocity.x) * walkSpeed;
        walkDirection = (int)Mathf.Sign(velocity.x);

        if (ladderMap == null || ladderMap.GetTileIdAtPosition(transform.position, 0) == -1)
        {
            velocity += Physics.gravity * Time.deltaTime;
            if (velocity.y < Physics.gravity.y)
            {
                velocity.y = Physics.gravity.y;
            }
        }
        else
        {
            velocity.y = 0f;
        }

        moveController.Move(velocity * Time.deltaTime);

        if (ReachedWaypoint(target))
        {
            pathIndex = patrolPath.GetNextWaypointIndex(pathIndex);
            Sleep(1);
        }
    }
 private void CycleWaypoint()
 {
     currentWaypointIndex = patrolPath.GetNextWaypointIndex(currentWaypointIndex);
 }