Skip to content

RelativeRandom Waypoint Type Setting Location Incorrectly #321

@dlockman

Description

@dlockman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions