• News

• Industries

• Learning & Support

• Community

• Marketplace

# TopDown Movement Help

So, I’ve got a squad of pawns I want to move around my grid. Everything seems to be working find except that my pawns do not end on the middle of my grid point.

What seems to be happening is that they stop as soon as the outer edge of their capsule component reaches that move point (middle of the grid tile) so they always stop just short of where they should.

I can compensate for this by adding the radius of the capsule to the movement vector, … except I can’t because the top down movement uses Simple Move to Location. I have to add the radius of the capsule component to the location in the direction of my movement vector then feed that location to the Simple Move.

I can get the movement vector by subtracting the starting location from the ending location …

… and before I go and get into all the trig needed to make this work (which I can do, but would rather not) …

Is there an easier way to get the pawn to snap to grid locations in the top down templet? Or an easy way to add 21 UE units to a location along a given vector?

Thanks

You essentially never need trig in 3D graphics / physics. You need vector addition/subtraction/scaling, normalization, dot products, and cross products.

To add the radius of the capsule to the target location, calculate (target - source), set the Z component of that difference to 0, normalize the result, multiply by capsule radius, and add to the original target location.

But, it’s likely easier to use a slightly less simple “move to location” behavior, that has a “tolerance” value for how close they should be before accepting the target. And then you can just slam the position of the pawn to be exact, once they’re within 2 centimeters or whatever, if that really matters.

Hey thanks for the response. I already got it figured out though, just forgot to come back and delete this question.

Never delete questions!
Other people will have the same question, and can find it on google.
Saying “this worked” in a follow-up post is much better.

1 Like

@jwatte

Good advice. I’ll keep that in mind.