How can I make a force protrude outwards?

As the title says, how can I make a force that protrudes outwards, then if the player hits it he gets pushed in that direction?

Kind of like this:

Anybody know?

Hey Puppy Do you mind Elaborating more ?

Like if a grenade were to blow up, and a player is on the side they fly away from the grenade

sorry for the crude drawing

To get a vector pointing in the opposite direction, subtract the force’s position from the character’s position, and then take the unit of that vector. Then, multiply that new vector by some magnitude based on the force of the explosion. From there, you can call “ApplyImpulse” on some part within the player’s character, in order to send them flying with that new velocity.

local Direction = (CharacterRoot.Position - ExplosionPosition).Unit
CharacterRoot:ApplyImpulse(Direction * ExplosionForce)

That was what I was thinking, but when I tested it, it didn’t work. But I was using AssemblyLinearVelocity so Ill try it with ApplyImpulse

Make sure that you’re using a sufficient magnitude to actually get the player moving. You might even want to scale the force applied proportional to the character’s mass, if you’re dealing with characters of varying rig types.

1 Like