Terasology / Behaviors

Store for an assortment of behaviors that can be applied to creatures
https://terasology.github.io/Behaviors
6 stars 18 forks source link

fix: Fixes bug in direct line travel #37

Closed agent-q1 closed 4 years ago

agent-q1 commented 4 years ago

Bug Fix

Bug Fix in MoveToAction node that causes characters to remain dormant even when they haven't reached the destination.

Justification

The relevant part of code is supposed to check if the destination has been reached, and set the drive to 0, as well as return Behaviorstate.SUCCESS. However, just checking if the individual coordinates are lesser than distance (a constant set at 0.2f) is not enough. What if all the coordinates (of target direction) start out as negative negative?, Then it will always believe that the destination has been reached and never move, which is not the case.

Thus I believe, this should be changed as so.

kaen commented 4 years ago

Really surprised this wasn't noticed until now. The change definitely looks correct to me, this check incorrectly passes if the entity's position is more positive than the target's, which would be 1/8th of the time (in theory).

LGTM :+1:

skaldarnar commented 4 years ago

@agent-q1 are the tests failing because of this change?

agent-q1 commented 4 years ago

Nope @skaldarnar they're pre-existing or atleast that's what @Cervator told IIIRC. Should probably fix those tests some time