protected MyBehaviorTreeState GoToPlayerDefinedTarget() { if (m_debugTarget != MyAIComponent.Static.DebugTarget) { m_debugTarget = MyAIComponent.Static.DebugTarget; if (MyAIComponent.Static.DebugTarget.HasValue) ;//CyberhoundTarget.SetTargetPosition(MyAIComponent.Static.DebugTarget.Value); else return MyBehaviorTreeState.FAILURE; } var botPosition = Bot.Player.Character.PositionComp.GetPosition(); // Distance to target if (m_debugTarget != null) { if (Vector3D.Distance(botPosition, m_debugTarget.Value) <= 1f) return MyBehaviorTreeState.SUCCESS; //var nextPoint = MyAIComponent.Static.PathEngineGetNextPathPoint(botPosition, MyAIComponent.Static.DebugTarget.Value); //var nextPoint = MyAIComponent.Static.PathfindingGetNextPathPoint(botPosition, m_debugTarget.Value); Vector3D point = m_debugTarget.Value; MyDestinationSphere destSphere = new MyDestinationSphere(ref point, 1); var path = MyAIComponent.Static.Pathfinding.FindPathGlobal(botPosition, destSphere, null); Vector3D nextPoint; float targetRadius; VRage.ModAPI.IMyEntity entity; if (path.GetNextTarget(botPosition, out nextPoint, out targetRadius, out entity)) { if (WolfTarget.TargetPosition != nextPoint) //WolfTarget.SetTargetPosition(m_debugTarget.Value/*nextPoint*/); WolfTarget.SetTargetPosition(nextPoint); WolfTarget.AimAtTarget(); WolfTarget.GotoTargetNoPath(0.0f, false); } else return MyBehaviorTreeState.FAILURE; } return MyBehaviorTreeState.RUNNING; }
public MyBotNavigation() { m_steerings = new List<MySteeringBase>(); m_path = new MyPathSteering(this); m_steerings.Add(m_path); //m_steerings.Add(new MyCollisionDetectionSteering(this)); m_aiming = new MyBotAiming(this); m_stuckDetection = new MyStuckDetection(0.05f, MathHelper.ToRadians(2f)); m_destinationSphere = new MyDestinationSphere(ref Vector3D.Zero, 0.0f); m_wasStopped = false; }
public void GenerateNavmeshTile(Vector3D? target) { if (target.HasValue) { Vector3D point = target.Value + 0.1f; MyDestinationSphere destSphere = new MyDestinationSphere(ref point, 1); var path = Static.Pathfinding.FindPathGlobal(target.Value - 0.1f, destSphere, null); Vector3D nextPosition; float targetRadius; VRage.ModAPI.IMyEntity entity; path.GetNextTarget(target.Value, out nextPosition, out targetRadius, out entity); } DebugTarget = target; }
public MyBotNavigation() { m_steerings = new List<MySteeringBase>(); m_path = new MyPathSteering(this); m_steerings.Add(m_path); //m_steerings.Add(new MyCollisionDetectionSteering(this)); m_aiming = new MyBotAiming(this); m_stuckDetection = new MyStuckDetection(); m_destinationSphere = new MyDestinationSphere(ref Vector3D.Zero, 0.0f); }