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!
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.
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.
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.
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
character = Player.CharacterAdded:wait()
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?