Beispiel #1
0
    // if activated, I move player towards the final position, following a path
    void Update()
    {
        if (activated)
        {
            if (pathIndex != patrolPath.GetPathLength())
            {
                player.transform.rotation = Quaternion.Slerp(player.transform.rotation, transform.rotation, Time.deltaTime * 3f);

                Vector3 target = patrolPath.GetPositionOfPathNode(pathIndex);
                player.transform.position = Vector3.Lerp(player.transform.position, target, 3f * Time.deltaTime);
                if (Vector3.Distance(player.transform.position, target) < .1f)
                {
                    pathIndex++;
                }
            }
        }
    }
Beispiel #2
0
 // Return the position of the actual destination in patrol path
 protected Vector3 GetDestinationOnPath()
 {
     return(patrolPath.GetPositionOfPathNode(m_PathDestinationNodeIndex));
 }