Character being Moved with BodyVelocity bugging when coming in contact with a wall

So uh.
I have a attack move that knocks back the enemy when hit.
But when the enemy gets knocked into a wall, it sometimes flings the enemy
Im not entire sure how to fix this

Video:

-ps. the link is a link to streamable which has the video

Im not looking for a person to script an entire system, i just want an idea/way to fix this.

I think you should try to use LinearVelocity instead because BodyVelocity is being deprecated and not much information can be found about it now

Also the reason the enemy gets flung might be because of the MaxForce, try setting it to a lower value?

Sorry for the late reply.

  1. I dont think its the max force, as im pretty sure ive set it lower and it still does this same thing.

  2. Ive never really tried linear velocities, but I did once and it seemed overly complicated for a velocity
    I’ll give the linear velocity a whirl and see if it works. Thanks for the reply!

Yeah defiantly try linear velocity, it can be a little scary but its worth a shot, I dont think code could fix your problem unless you want to destroy the body velocity when hitting somehting

I tried and couldnt figure it out (:sob:) and I tried searching for some tutorials but didn’t find anything, so im going to stick to BodyVelocitys for now.
Im thinking raycasts could do this, but i’m not exactly sure how…
You got any ideas?

Hmm well with body velocity you could collide with anything and this would happen, floor, ceiling, etc.
So you could use workspace:GetPartsBoundInBox()

Hmm, yeah I suppose that could work. So you thinking if a part enters the box it stops the velocity?

basically yes. In theory that should work

Im thinking of using a part to do this because I dont wanna loop a for loop to constantly check for parts

1 Like

This is just how physics works in Roblox. The velocity at that distance is too high and it causes the character to overlap with the wall for (likely) a sub-step of the Physics pipeline, which is hard to normalize for force and correct the collision, so the physics engine ends up with a weird normal vector along the collision faces.

…Which when resolving shoves the corner of the part down, up, left, right, backwards, forwards, you can phase through walls, etc.

It can be observed by simply setting your walkspeed to something high, not even all that absurd, and smacking into a wall. If the wall is too thin and you’re going too fast, you will quite literally go through it. Otherwise, you might see the moon.