本文整理汇总了C#中EnemyController.GetPrevMvt方法的典型用法代码示例。如果您正苦于以下问题:C# EnemyController.GetPrevMvt方法的具体用法?C# EnemyController.GetPrevMvt怎么用?C# EnemyController.GetPrevMvt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EnemyController
的用法示例。
在下文中一共展示了EnemyController.GetPrevMvt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveLogic
public Vector3 MoveLogic(EnemyController enemy, GameObject player)
{
if (LMHelper.IsInRange(enemy, player))
{
enemy.SetAggroState(true); //aggroed if within aggro range
float pm = enemy.GetPrevMvt().magnitude;
Vector3 mvt;
// If hitting a wall and moving slowly, take a detour sideways
// (prevents behavior if out in the open or if it happens to graze a wall while moving rapidly)
if (enemy.GetWallHit() && pm <= .05)
{
Vector3 direct = LMHelper.BaseMoveLogic(enemy, player); //first get direct approach
mvt = Vector3.Cross(direct, new Vector3(0f, 1f, 0f)); //cross with vertical to get left perpendicular
if (Time.time % 4 <= 0.02)
{
mvt *= -1; //flip direction every 5 seconds
}
mvt -= direct * (Random.value - 0.5f); //take random angle from straight perpendicular
mvt.Normalize(); //re-normalize
}
else // otherwise chase as normal
{
mvt = LMHelper.BaseMoveLogic(enemy, player);
}
return mvt;
}
enemy.SetAggroState(false);
return new Vector3(0f, 0f, 0f);
}