Use a bodyvelocity and bodyforce on an object simultaneously?

Right now I have a player flying around using a bodyvelocity, and then I want a bodyforce to push him away from something if he gets too close (like an air vent mechanic). Right now it seems the bodyvelocity just overrides the bodyforce, and the vent mechanic works fine when he’s not flying.

Any ideas?

1 Like

Having a BodyVelocity be offset by another force doesn’t make sense because its job is to force a certain velocity, so the behavior you’re seeing now is reasonable. You need to either build the vent mechanic into the BodyVelocity (velocity = flyDir*speed + ventVelocity on Stepped) or use a force for flying. I would recommend the latter, as that way you don’t have compatibility issues every time you want to apply a force while the player is flying.

And if you’re going to use force, use VectorForce instead of BodyForce – PGS constraints are more stable than legacy constraints (which are also no longer supported), and aside from having to set up attachments beforehand, the API is the same for VectorForce so it’s an easy drop-in replacement.

3 Likes

Question.

Constant force for, say, running would cause constant increase in velocity, so the player would walk on ice, but also reach light speed at some point. How do you prevent this?

Before you say friction, the goal here is to have in control the overall velocity even in air, so if I jump during this friction + constant force, I would shoot in the force direction super quick.

I could clamp the character’s net Velocity, but then I won’t be able to apply external forces like maybe an exploding bomb nearby, because the net velocity would be clamped.

Since I cannot use BodyVelocity with Forces, what do you suggest I use for sudden impacts like the bomb mentioned above?