December 2, 2017 at 04:13 #22536plagelpussParticipant
I am trying to figure out how to get units to only follow their path. Right now my units start out moving directly towards the target and then when the replanning is fired they move back to their original location and then start following the path. I just copied the code directly from Apex/Examples/SceneSpecific/PathRequests/Path Request Example 1.
While i was playing around i found the unit.MoveAlong(result.path, myreplan); override that allows you to write your own replan logic, but right now I am only returning the path that gets passed into the function.
private Path myreplan(GameObject unit, IPositioned currentDestination, Path path)
unfortunately I am getting the following error on like a third of my units (i have 32 units and i get 9-10 null reference execptions)
NullReferenceException: Object reference not set to an instance of an object
Apex.Steering.Components.SteerForPathComponent.GetDesiredSteering (Apex.Steering.SteeringInput input, Apex.Steering.SteeringOutput output) (at Assets/Apex/Apex Path/Scripts/Steering/Components/SteerForPathComponent.cs:446)
Apex.Steering.SteeringComponent.GetSteering (Apex.Steering.SteeringInput input, Apex.Steering.SteeringOutput output) (at Assets/Apex/Apex Path/Scripts/Steering/SteeringComponent.cs:44)
Apex.Steering.SteerableUnitComponent.Steer (Single deltaTime) (at Assets/Apex/Apex Path/Scripts/Steering/SteerableUnitComponent.cs:409)
Apex.Steering.SteerableUnitComponent.FixedUpdate () (at Assets/Apex/Apex Path/Scripts/Steering/SteerableUnitComponent.cs:209)
I opened up SteerForPathComponent and im guessing the issue is with _currentDestination.postion
if (Arrive(_currentDestination.position, _remainingTotalDistance, input, output))
if (_pendingPathRequest != null)
//TODO: this should be set whenever the unit stops, however since it may not be the only locomotion component a smarter way must be found
//The SterrableUnitComponent ought to handle this, so if there is no locomotion component that have out put it is set to true; otherwise false.
//Also change the description of the property
_unit.hasArrivedAtDestination = true;
Does anyone have any ideas as to why im getting these null references?December 4, 2017 at 10:56 #22548GeminiorKeymaster
Something is clearly wrong.
Units should move along their path at all times, no extra logic required. The only time you will want to do custom replanning is if you don’t use the path finder but instead supply your own custom paths.
What is wrong I cannot say. You should open the examples project and launch any scene to see that path finding + steering work as expected. Then identify the differences between the setup used in the examples scenes and you own.
You must be logged in to reply to this topic.