private Vector3 GetPursuitDirection(TestingSteering PlayerSteering, TestingSteering PursuitSteering) { Vector3 distance = PursuitSteering.CurrentPosition - PlayerSteering.CurrentPosition; float futureTime = distance.magnitude / PlayerSteering.MoveMaxSpeed; Vector3 futurePosition = PursuitSteering.CurrentPosition + PursuitSteering.CurrentVelocity * futureTime; return(SeekBehaviour.GetDirectionVector(PlayerSteering.CurrentPosition, futurePosition)); }
public static Vector3 GetDirectionVector(TestingSteering playerSteering, TestingSteering leaderSteering) { Vector3 followPosition = GetFollowPosition(leaderSteering); Vector3 force = SeekBehaviour.GetDirectionVector(playerSteering.CurrentPosition, followPosition); //force += Seperation(playerSteering); return(force); }
private Vector3 GetFollowDirection(TestingSteering playerSteering, TestingSteering leaderSteering) { Vector3 tv = leaderSteering.CurrentVelocity * -1; tv = tv.normalized * _followDistance; Vector3 followPosition = leaderSteering.CurrentPosition + tv; Vector3 force = SeekBehaviour.GetDirectionVector(playerSteering.CurrentPosition, followPosition); //force += Seperation(playerSteering); return(force); }
public static Vector3 GetFormationDirection(TestingSteering playerSteering, TestingSteering leaderSteering, Vector3 positionOffset) { Vector3 leadRot = leaderSteering.transform.rotation.eulerAngles; float rot = leadRot.y * Mathf.Deg2Rad; float cs = Mathf.Cos(rot); float sn = Mathf.Sin(rot); float newX = ((cs * positionOffset.x) - (sn * positionOffset.x)); float newZ = ((sn * positionOffset.z) + (cs * positionOffset.z)); Vector3 tmpPos = new Vector3(newX, 0, newZ); tmpPos += leaderSteering.CurrentPosition; //Vector3 tmpPos = leaderSteering.CurrentPosition + positionOffset; return(SeekBehaviour.GetDirectionVector(playerSteering.CurrentPosition, tmpPos)); }
public static Vector3 GetDirectionVector(TestingSteering playerSteering) { if (GridGenerator.level != null && GridGenerator._currentEnd != null) { Debug.Log("Finding path"); List <Vector3> path = HierarchicalAStar.FindPath(GridGenerator.level, playerSteering.CurrentPosition - new Vector3(0, 1, 0), GridGenerator._currentEnd.transform.position); Debug.Log(path[1]); Vector3 nodePos = path[1]; if (nodePos == Vector3.zero) { nodePos = path[2]; if (nodePos == Vector3.zero) { nodePos = path[3]; } } Vector3 seekPosition = new Vector3(nodePos.x, playerSteering.CurrentPosition.y, nodePos.y); return(SeekBehaviour.GetDirectionVector(playerSteering.CurrentPosition, seekPosition)); } return(Vector3.zero); }