Some questions regarding forces, applying them and maybe other stuff

A new game that i’m making is gonna use forces, and it’s gonna use them a LOT, so it’s really important for the system to be both consistent and clean. What i wanna do is have it so that every force can firstly fire and then slowly fade out. How would i do that, considering that setting assemblylinearvelocity will just immedeately set the force, not accounting for any other ones? Also, is there a way to, perhaps, rewrite some of the default physics? Cause if not, i could try making a physics system from scratch, which is pretty dang hard so i’d rather not do that.

sorry if i sound weird, i am very tired!!

I’m not entirely sure what you’re trying to do, so I can’t give specifics, but I would check out the physics page of the docs, and if you’re dealing with applying forces then the mover constraints specifically. AssemblyLinearVelocity is still quite useful, for example, in the game I’m working on the lobby in is a sort of void with floating islands, and I use AssemblyLinearVelocity in order to bounce the player back up whenever they fall, but you’re right, unless you manually make a system to do so, it doesn’t take into account other forces. In terms of making forces fade in and out, you should be able to use the TweenService in order to accomplish this, but the TweenService is intended for use with things like visual animations, and I don’t have any experience with using it for physics, so if these fades are critical to your gameplay you might want to do some testing yourself. However, I’d be super careful with fading the forces, as unless if you’re using a LinearVelocity or an AngularVelocity, these constraints apply apply forces, not movement. If you not familiar with physics, forces are more or less the same as acceleration, and so keeping a static acceleration will already cause a fade out in the object’s velocity, and fading the acceleration typically just results in unnatural looking movement. Here’s a Desmos graph to demonstrate what I’m talking about.

Red Line: Distance
Purple Line: Velocity
Green Line: Acceleration

This graph here demonstrates a constant deceleration, notice that while the acceleration is constant, the velocity decreases linearly, and thus the distance travelled starts to taper off near the end, achieving that smooth “fading”. (Desmos)

I was going to make a second graph demonstrating a changing acceleration, but I realised I actually don’t know how to graph it with non-constant acceleration, so you’ll just have to take my word for it, the fade you get at the very end is much more abrupt when you introduce non-constant forces.

Finally, in regards to modifying the physics engine, it depends heavily on what you’re trying to do, so I can’t really say without knowing what you want to modify, sorry about that. I hope this helped clear up any confusion.

2 Likes

it really depends on what you are trying to acheive. you could perhaps tween a parts cframe or position or tween the VectorVelocity of a LinearVelocity constraint. you could also just decrease the MaxForce of the linear velocity to allow more physics influence on it. and lastly you could maybe look into BasePart:ApplyImpulse. its extremely unclear what you want, so it would be great if you could elaborate. refer to these suggestions and @FishermanWWK’s wonderful post for now

1 Like

Okay, so, only now i realized how vague my post was. i will try to elaborate on stuff in it here.

I would want to make a system that takes into account all active forces that are on a part and then applies the resulting force onto the part (here im not sure when i should do it, should i apply the force every Runservice.PreSimulation or every second, or would i only do it once? what im getting at here is that i dont know where to actually use the force.)

And also, regarding the “changing the default physics” part of my post, im not sure why i havent mentioned what exactly i would change, but i meant the friction forces and the drag forces. Is there a way to change their… uhh… coefficients, or something? im not sure.

Also also, that graph really did clear up some of my confusion about acceleration, thanks for making it.

Im really new to physics and i dont quite know how to express what i really want to make, but i hope ive cleared up some of the vagueness of my initial post.

If you’re using the MoverConstraints then you shouldn’t have to reapply the forces at all, they should simply be applying constantly. Something to note however is that the acceleration of the part is dependant on its mass, so if you want to control the acceleration of the part, then you can simply multiply you desired acceleration by the BasePart.AssemblyMass property.

Explanation of why

The amount of force imparted on an object is given by this equation, where F is the force, m is the mass of the object, and a is the acceleration of the object.

F = m * a

Given this, if we know our desired acceleration and our mass, we can simply multiply them together in order to get the force required to achieve that acceleration.

If you want to adjust the amount of friction that a part experiences, then you can simply create a PhysicalProperties object, changing the Friction property to whatever you want, and set the BasePart.CustomPhysicalProperties property to the new PhysicalProperties object. According to their documentation, the resulting friction between the two objects is simply the average of their Friction properties, but this can also be adjusted through the FrictionWeight property, I’d check out the docs for more information. Now, I don’t actually know if the Friction property is measuring the Force of Friction or the Coefficient of Friction, traditional physics says it should be the Coefficient of Friction, but their documentation makes it sound like it’s the Force of Friction, so you might want to do some testing on that. In terms of drag, that’s a whole other beast entirely. The built in Roblox physics engine doesn’t actually have any drag (although I know that they’ve been working on some aerodynamics related stuff, so that might change eventually), so if you wanted drag then you’d have to implement it yourself. That said however, you probably don’t need drag in your game, for a lot of physics we actually just ignore it entirely, and there’s a reason the Roblox engine doesn’t have it. If you do want to go ahead though, there’s some good ideas here such as simply applying a VectorForce opposite to the direction of motion, and this would be an instance where you use RunService.PreSimulation in order to adjust the direction of the VectorForce. While calculating the direction of the force is easy, calculating the magnitude is really difficult, as if you want a realistic drag you have to start getting into the DragCoefficient which is really complicated to compute, so if you want to do that you’re going to have to your own research, sorry. Alternatively, you could do as they did in the post I linked earlier and simply have a static amount of drag, but that sacrifices some realism. Again though, for most applications you probably don’t need drag, friction should be enough. Let me know if there’s any other confusion and I’ll see if I can help.

2 Likes

Huh, i always thought Roblox has some built in drag… I tried to test it too, and, as you’ve said, there is no drag. I’ll also try messing around with physicalproperties, it’s my first time hearing of them. Thanks for your help, dude! One last question: is there a way to make player’s continue moving for a bit after their movements (if they’re not affected by friction)? From what i see, the character, when i stop pressing any wasd key, stops moving IMMEDEATELY. Is there a way to change that?

if you dont have a strong background in physics, i would not advise you to attempt to create your own physics engine. roblox already does the heavy loading. as to applying the resulting force of all active forces, roblox already does all of those calculations. maybe you just need to decrease the MaxForce or MaxAxesForce for enhanced realism.

  1. i think roblox does have drag (air resistance). i believe this is a beta feature right now, not too sure tho. i havent looked into it much but here is the areodynamics release post Introducing Aerodynamic Forces [Studio Beta] - Updates / Announcements - Developer Forum | Roblox.
  2. physical properties are great! you can change the mass and many other things such as FRICTION! friction can be so useful for things like ice, but one thing you have to do is change the friction weight. this essentially just tells how important the friction calculations for that part are and its priority.
  3. the in built roblox character movement system has no way of doing that other than changing the floor friction (maybe you can change the characters friction?) but u can create your own movement system with linear velocity and other constraints. i have done this before and it works extremely well (and its quite fun)

yeah, so drag and lift! pretty cool!

hmm, ill look into linearforces. thanks, people!

no problem!!!

char limit