So I had an idea to make a heat seeking dodgeball but I have literally no idea how I would go about doing it other than the fact the velocity is involved.
Basically the dodgeball should home in on Humanoids that don’t belong to the thrower.
Here is some pseudocode to get you started:
go through all players (or humanoids)
get the direction vector from the humanoids pos and the ball pos
compare the direction vector with the balls current velocity (to get the humanoid which requires the least amount of turning to aim towards)
go to the found humanoid (set velocity?)
Although this doesn’t account for obstacles and this might go for players that are really far away. So you would need extra checks for that.
1 Like
I’m sitting here trying to figure this out, I know I would loop through the players first like this, but otherwise i’m confused as heck, been looking for a bit
for i,v in pairs(game.Players:GetChildren()) do
-- v is your playerb
end
Here’s the next step:
for i,plr in pairs(game.Players:GetPlayers()) do
-- check if the player has a character
if not plr.Character then
return
end
-- check if the player has a primarypart
if not plr.Character.PrimaryPart then
return
end
local directionVector = plr.Character.PrimaryPart.Position - ball.Position
-- the rest is up to you...
end
(Btw when comparing you should probably convert the vectors to unit vectors)
1 Like