How to knock players AWAY from the caster/player with BodyVelocity?

I’m trying to create a method to knock players away from the player, more specifically the caster will spin in a circle and all enemies inside of the circle hit will be knocked back away from the player. ATM I’ve used body velocity to launch players towards where the caster is looking, but I have no idea how to even begin with this.

I’m not asking you to write code for me just ideas on how it can be done

Can you please explain a little more?

If you have the position of the caster and the position of each player, you can create a vector pointing from the caster to the player by doing PlayerPosition - CasterPosition. If applied on the player as a body velocity, this will cause their velocity to point away from the caster, with a magnitude proportional to the distance between them. To create a vector pointing away from the caster with a specificed magnitude, use this formula

(PlayerPosition - CasterPosition).Unit * Magnitude

Where PlayerPosition is the player’s position, CasterPosition is the caster’s position, and Magnitude is the magnitude of your knockback.

1 Like