Пример #1
0
    /// <summary>
    /// This version of ConsiderDestination will only return a valid location if the pathing system is able to find a route
    /// from the current position to the candidate location.
    /// </summary>
    /// <param name="location"></param>
    /// <returns></returns>
    public override Vector3?ConsiderDestination(Vector3 location)
    {
        var result = base.ConsiderDestination(location);

        if (result.HasValue)
        {
            Vector3 start = LocomotionTeleport.GetCharacterPosition();
            Vector3 dest  = result.GetValueOrDefault();
        }
        return(null);
    }
Пример #2
0
	/// <summary>
	/// This coroutine will be active during the teleport transition and will move the camera 
	/// according to the PositionLerp curve.
	/// </summary>
	/// <returns></returns>
	IEnumerator DoWarp()
	{
		LocomotionTeleport.IsTransitioning = true;
		var startPosition = LocomotionTeleport.GetCharacterPosition();  
		float elapsedTime = 0;
		while (elapsedTime < TransitionDuration)
		{
			elapsedTime += Time.deltaTime;
			var t = elapsedTime / TransitionDuration;
			var pLerp = PositionLerp.Evaluate(t);
			LocomotionTeleport.DoWarp(startPosition, pLerp);
			yield return null;
		}
		LocomotionTeleport.DoWarp(startPosition, 1.0f);
		LocomotionTeleport.IsTransitioning = false;
	}
    /// <summary>
    /// This version of ConsiderDestination will only return a valid location if the pathing system is able to find a route
    /// from the current position to the candidate location.
    /// </summary>
    /// <param name="location"></param>
    /// <returns></returns>
    public override Vector3?ConsiderDestination(Vector3 location)
    {
        var result = base.ConsiderDestination(location);

        if (result.HasValue)
        {
            Vector3 start = LocomotionTeleport.GetCharacterPosition();
            Vector3 dest  = result.GetValueOrDefault();
            UnityEngine.AI.NavMesh.CalculatePath(start, dest, NavMeshAreaMask, _path);

            if (_path.status == UnityEngine.AI.NavMeshPathStatus.PathComplete)
            {
                return(result);
            }
        }
        return(null);
    }