How to calculate the Potential position of a Character

Greetings,

So I’ve been trying to add a root effect to the character that I’m working on. What I mean by root effect is having him being able only to move around a certain radius of a certain location. I tried to do it with a physics Constraint, didn’t work because both the root actor and the character dont have physics simulation on. Next Idea I had, is when the character is trapped, would calculate the potential position of the character in the next frame by analyzing the input of the player at that frame and try to add whatever positional change to the current location.
My problem is I don’t know how to do that correctly?

Any ideas on how to do this, or another idea to accomplish the root effect?
And thank you.

There might be an easier solution.

  • Create a sphere/volume at root position, if the character no longer intersects with the sphere or leaves the volume, stop the/pull them back in. No physics, just collision.

  • Or spawn an invisible cylinder the player can only move inside of.

  • Or even simpler, check the distance between root location and the player. if Dist > RootDiamater->StopPlayer

  • For something more interesting, you can make the player move slower and slower the further away they move from the centre of the root, stopping them completely eventually. And only restore speed when their forward vector is rotated towards the root point.

One these might work for you and sounds more straightforward than dealing with delta. Although, that might work just fine. There’s probably another half a dozen solutions to this.

Actually, I figured out a way to find the potential position, by creating a FVector AccumulatedMotion that is zeroed at the end of tick, and that accumulates the direction from MoveForward and MoveRight, where I don’t call AddMovementInput anymore.
In tick, I check if the vector is not zeroed, and I use it to predict the position. If that position is out of the radius, I pass the direction from the Player to the root position to AddMovementInput which will push the player back. If not, it will pass the AccumulatedMotion vector.

But thanks @Everynone for the answer, that gave some ideas to polish this more.