How to make a rushing system?

I wanna know how to make a rushing system in which the player presses a key and rushes to the nearest enemy. This game here showcases what I want perfectly:

I really just can’t figure out how to find the nearest character from the player, and then getting the user character to rush in front of the target character. Any ideas?

2 Likes

You could use magnitude, and detect what is the closest player in the range. Then, use some sort of velocity or force to go to the player.

What would I use to detect nearest players? Would I need a hitbox of some sort?

1 Like

You could use magnitude like I said in the post above you could use magnitude. Loop through the players and subtract the v’s (player) HumanoidRootPart’s position and the LocalPlayer’s position and get the magnitude from that.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.