# Predicting User Movements

Good evening, I have been trying to figure out a way to predict a user’s movement based on their humanoid movement, position, and velocity. I can not think of an efficient and effective way to do that.

Any suggestions, tips, and constructive criticisms are welcome here!

1 Like

You mean something like analizing the atterns of their movements? or to just get the keys currently being pressed.

1 Like

Yeah, I’m trying to analyze their movement pattern to predict where they are going to move next. I can do `HumanoidRootPart.Position + HumanoidRootPart.Velocity` but that’s not accurate nor consistent.

1 Like

Well, then you would have to resort to extremely complicated aspects of psychology and statistics, especialy if the movement isn’t restricted in any way.

2 Likes

wait until roblox have time machines

2 Likes

Alright, that does sound complicated. So let me make it a bit less complicated.

Let’s assume that you are a guided missile. You do constantly know the enemy’s location, vectors, and velocity. You want to intercept them, rather than chasing them because that is smarter and you have more speed on impact (and way cooler). Despite you knowing their location, vectors, and velocity, their vectors can change and you don’t want to find they banked a hard right at the last second, you want to predict their new reasonable vector to get a more accurate hit.

While this sounds pretty simple to humans, we all know that an optimized and efficient algorithm is needed for computers.

In that case, you could use a combination of UserInputService:IsKeyDown() and the LookVector of the player’s HumanoidRootPart so it tries to get ahead.

1 Like

Alright, I’ll look into it tomorrow.

What if the target user is using shift lock?

it would still aim forward of the player

Right, but the player may be moving to the side.

You can use :IsKeyDown() so if the a or d keys are pressed you use rightvector or -rightvector.

Okay, so currently, I tried the code that I said I was not going to use (`HumanoidRootPart.Position + HumanoidRootPart.Velocity`). I added in some visualization to the code to make it spawn blocks.

``````while wait() do
local Player = game.Players.LocalPlayer

local character = Player.Character

if not character or not character.Parent then
end

local HumanoidRootPart = character.HumanoidRootPart

local part = Instance.new("Part", workspace)

part.Position = HumanoidRootPart.Position + HumanoidRootPart.Velocity --1 second ahead

part.Anchored = true

print(HumanoidRootPart.Velocity)
end
``````

Let’s say that I am going to use this. How would I improve it to get better accuracy?

1 Like
1 Like

I can’t see that clearly, can you elaborate?

Never mind, I clicked on the source and saw why.

Yes, this is what the script I sent for, to track the player based on their velocity.