-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Context: I was debugging a set of behavior that I noticed kept trying to set waypoints underground, autopilot complained in debug logs, and then it could never reach those waypoints obviously.
WapointProfile.cs for code snippets
EntityRandom works consistently and makes sense
if (Waypoint == WaypointType.EntityRandom && entity?.PositionComp != null) {
return new EncounterWaypoint(GetRandomCoords(entity.PositionComp.WorldAABB.Center));
}
RelativeRandom (what I was using before ) is subtracting the entity's original coordinates after running the same method for some reason, which usually ended up giving a waypoint deep in the planet that the ship can obviously never reach given how autopilot path checking works.
if (Waypoint == WaypointType.RelativeRandom && entity?.PositionComp != null) {
var offset = GetRandomCoords(entity.PositionComp.WorldAABB.Center) - entity.PositionComp.WorldAABB.Center;
return new EncounterWaypoint(offset, entity);
}
Seems like the fix should be easy, just have the RelativeRandom calculate location same as EntityRandom? The only difference is supposed to be (from documentation) that EntityRandom keeps tracking the entity as it moves, whereas RelativeRandom is fixed after waypoint is set.