Stopping with millimetre precision (Pawn)

Hi,

I have a problem. I want the pawn to stop automatically at high speed (1200) precisely at the end of the wall. How can you best implement that in Blueprint?

Thanks in advance

Use a trace to find out if the wall ended and then stop the movment with the Stop Movement Immediatly Node. You probably also need to stop what caused the movement.

Note:
It would be “better” (less resource hungry) to use a sphere or box collider to find out if the wall ended. But a collider wouldn’t be as precise as a trace.

How is the object moving? If you’re using a stock controller like the character controller, it may not be easy to make it stop at exact location without manually calling “set position” on it after the stop.

Even in a custom movement component, you’ll probably want to detect that the next frame is going to “go past” the end, and use that to set your velocity such that it exactly catches up with the edge, and then next frame, set the velocity to 0.

It’s somewhat unclear exactly what the effect you want, is, but your best bet is likely to detect the situation, use “set actor location” to align to the exact spot, and then set the velocity to 0 on the movement or physics component so it doesn’t move further.

It doesn’t work. Boxpawn has to stop precisely at the end of the wall so that the boxpawn fits into the entrance. The entrance has exactly the same width as the boxpawn.

What do you mean “it doesn’t work?”
If you calculate the exact position it needs to have, and set the actor position to be that (and set velocity to 0) then it will have exactly that position.

Another option is to have snap points in the level, where your pawn will “know” when it’s close to one, and snap to it if velocity is low.

I don’t want to calculate it myself, the boxpawn has to find out dynamically where exactly the end of the wall is.

So, is the problem “find the wall location,” or is the problem “once I know where the wall is, make the pawn stop exactly there?”

If you have to dynamically find the wall location, then you very likely need a small amount of slop in the gap between the blocks for the block to really fit – 1 cm should be plenty.
Then, use eight ray casts to find the walls nearby the pawn, to figure out what support planes to “snap” to.

Jam eight sensor traces into the array something like this:

You can break the hits that you get, and calculate supporting planes to snap to.

You will presumably only pay attention to planes whose normals point in the same direction as your movement direction, and/or whose normal dot your normalized movement is close to 1 or close to -1 (so the planes are perpendicular.)

1 Like

how do you do that with move and stop?

Not sure how helpful this is but here’s something similar from a while back:

Alternatively, you could use a box trace in cardinal directions. If a box trace returns null, it’s time to stop or turn.


edit: just realised the thread I linked was also yours… my bad.

That wouldn’t work, the boxpawn has to fit exactly into the entrance. Entrance and boxpawn have the same width.

Why wouldn’t it work? BoxTrace with the dimensions of the box. You could even orient the box trace do go diagonal.

Boxpawn would just keep going straight

I have already done this example. If the boxpawn didn’t stop precisely at the end of the wall, the boxpawn wouldn’t fit in the entrance anymore, so the boxpawn would just keep going straight

it is not a sphere, but a cube.

Does not matter, just tested the above, replacing traces with a non-oriented boxtrace. 5 min job. Do give it a proper try. If in doubt, post script - perhaps there is room for improvement.


I can imagine this could potentially cause issues with wildly fluctuating framerate. You’d then need to implement wiggle room.

Show me this in a blueprint so I can understand

To make the stop with a very high level of precision, you’d do more than one trace per frame. You know how much you’re moving each frame and the distance left to the gap - ensure that last step before the opening is clamped. You could even snap vector to grid for the last step.

Thank you for your suggested solutions. I can’t implement this in Blueprint because I don’t understand it properly. I have to see it to understand it.

Is it even feasible to stop in exact position?

@Godlike0207
It is feasible, but you might need to rethink the way you’re doing the movement. It would be a very restrictive movement, but you could work a node-to-node movement system where you have all of the positions hard-coded, and interpolate between the points. Other than what other comments have said, It’s hard to have such consistent accuracy and precision when the user can control so much.
I hope this can help,
-Zen

2 Likes