浏览代码

feat: Update ChaseAction to new navigation system.

This improves performance because the navigation paths don't have to be recalculated each frame.
/main
Luke Stampfli 4 年前
当前提交
197c682f
共有 1 个文件被更改,包括 1 次插入11 次删除
  1. 12
      Assets/BossRoom/Scripts/Server/Game/Action/ChaseAction.cs

12
Assets/BossRoom/Scripts/Server/Game/Action/ChaseAction.cs


private NetworkedObject m_Target;
private ServerCharacterMovement m_Movement;
private Vector3 m_CurrentTargetPos;
public ChaseAction(ServerCharacter parent, ref ActionRequestData data, int level) : base(parent, ref data, level)
{

m_Target = MLAPI.Spawning.SpawnManager.SpawnedObjects[m_Data.TargetIds[0]];
m_Movement = m_Parent.GetComponent<ServerCharacterMovement>();
m_Movement.SetMovementTarget(m_Target.transform.position);
m_CurrentTargetPos = m_Target.transform.position;
m_Movement.FollowTransform(m_Target.transform);
return true;
}

//we made it! we're done.
Cancel();
return false;
}
float target_moved = (m_Target.transform.position - m_CurrentTargetPos).magnitude;
if( m_Data.Amount < target_moved )
{
//target has moved past our range tolerance. Must repath.
this.m_Movement.SetMovementTarget(m_Target.transform.position);
m_CurrentTargetPos = m_Target.transform.position;
}
return true;

正在加载...
取消
保存