Physics movement calculations

I couldn’t find an appropriate forum section for this (can’t see any maths/physics section), and figured this might be the closest I get… well, I’m using blueprints for my project at least. :smiley:

My current project involves the player piloting a spaceship (or spaceplane for that matter; constant forward thrust, no hovering or VTOL). I’m going back and forth between whether I should manually move my ship with AddActorWorldOffset nodes and such, or to actually use the physics (with AddForce, AddTorque and such).

I have a fairly working setup using manual movement. I’d also like to create a physics based prototype to better understand the advantages and drawbacks of each system. My biggest hurdles in creating a physics prototype is, lo and behold, the maths. Long story short, it has never been my strong suite. So, the questions go as follows:

  1. Assuming I know what target speed I want my spaceship to move at (e.g. 1500 cm/s), and I’m sure mass will need to be considered as well (let’s assume 1200 kg as an example number), how would I calculate the correct amount of force I’d have to add in order for the ship to be able to reach said top speed?
  2. Similar question for torque. Say I know the amount of degrees per second I want the ship to be able to roll… or yaw or pitch for that matter (say roll 75 degrees per second), how would I calculate the amount of torque that is needed to achieve this rotational speed?
  3. Assuming I can get these two questions cracked open and a grasp around it, what happens when I add an additional factor - acceleration speed? I assume, in the case of force and linear velocity, I’d have to adjust the amount of force I output based on the current speed… am I right? Any good suggestions on how to go about this (I assume we are talking complex mathematics at this point, and that unless I have a decent grasp on maths, I’d achieve results faster through experimenting with numbers)?
  4. Edit: With the prototype I have set up a few minutes ago, I basically add a specific amount of force every tick, then add torque based on input for roll, pitch and yaw. I’ve disable gravity in the root component (a static mesh) in the blueprint. There is one pecularity I don’t know how to do something with though. Using a GetVelocity node fed through a VectorLength node, I’m reading off the current velocity. In a straight line it peaks at about 991 cm/s. Once I add torque to yaw, pitch or roll (most for the first two), I end up losing speed, at worst falling down to 900 cm/s. Is this a matter of reading off the current velocity in an incorrect matter? I’m aiming for a more arcade type flying style here (think along the lines of Terminal Velocity and Fury³). Assuming I am reading off velocity correctly, is there a way to ensure I keep the same velocity even when adding torque?
  1. The question is in how many seconds do you want to achieve 15m/s (switching to SI for the sake of the formulas). Since you probably don’t want acceleration to be constant and level off slightly so you know your acceleration won’t but some absolute value, but a function in terms of time.
    F = ma but a would probably look like a = c/t or something like that. You will need to integrate it to find c (some constant… I can do that for you if you tell me how long it will take to go from 0 to 15 :slight_smile: )

  2. Need to find my physics book. Lol

  3. Calculus. If you know it take a stab at it, otherwise if you let me know what kind of acceleration curve you want, I could take the stab.

  4. It sounds like you are using physics to do this movement. Do you have linear dampening set? Not sure why that is happening. You would have to be applying the force in the opposite direction somehow to cause it to slow down.

Edit: You may be able to simplify it by using timelines for you variable acceleration…assuming you want variable acceleration.
Also this might help: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

I realized while testing that I will probably have to take into account Delta Seconds. During testing, I set Linear Damping to 0, and suddenly I was at 30000 cm/s and counting… I’ll add a screenshot of the blueprint to the end of the post to make it easier for you to see what I have set up.

Apologies if this comes of rude in any way - which is not the intention - I absolutely appreciate you taking your time to help. Unfortunately once you started using abbreviations, you lost me. Simply put, I ended up dropping out of math (since I was flunking anyway) in my country’s equivalent of high school. The teacher was horribly bad at teaching things to people who didn’t instantly get things, and well, I need a bit of spoonfeeding - bad combo. Not going for a sob story here, just trying to set the bar for what level I’m currently at. :stuck_out_tongue:

So, to answer the questions:

  1. As mentioned, you lost me with the abbreviations. I should note that my first question was just about top speed really. Basically, how do I calculate a single, static number for the force needed to achieve a certain top speed?
  2. Hehe.
  3. The reason why my first question is only about the formula to find the “peak, static force” is to avoid moving too fast for my comprehension. Sure, getting it handed to move solves the problem per se, but if I can understand it at the same time then it is all the better, and I might be able to apply it myself in the future. Unfortunately, calculus is something I have yet to grasp properly. There’s a lot of learning material out there, but I haven’t found anything that is written in a way that it doesn’t speed past me in the first corner so to speak.
  4. While experimenting earlier, I had set Linear Damping and Angular Damping to 1.0. I don’t think I can easily explain what is going on, so I think it is better if I just show you the blueprint setup. I experimented with the numbers for Force to get a minimum speed of approx. 750 cm/s and maximum of approx. 1500 cm/s.


Default values for preset variables (variables not mentioned simply start at 0 and are calculated along the way):

  • ThrustDigitalMultiplier: 0.005
  • AccelerationForceMin: 75632.0
  • AccelerationForceMax: 151265.0
  • TorqueBase: 150000.0

Other settings worth mentioning (on root Static Mesh component):

  • Simulate Physics: True
  • Mass in KG (overriden): 100.0 Kg
  • Linear Damping: 1.0
  • Angular Damping: 1.0
  • Enable Gravity: False

EDIT: Just saw your edit. I did use that tutorial as a starting point, but setting the velocity (both linearly and angularly) directly like that led to a whole host of problems once you arrive at collisions. Hence why I am now trying to figure out all these Force and Torque calculations. As for Timelines, they are useful but I am trying to avoid them as they aren’t the most portable tool. It is a nightmare if you end up wanting to use the same curve for multiple blueprints (irrespective of whether it plays in sync or seperately).

You need to apply a force over a certain time period in order to get to a certain speed. Unless you just outright set its velocity, you will need to know how long it will take from rest to achieve that top speed similar to how in America they give a car’s “0 to 60mph” time.

You can apply any force greater than 0 and get to the speed you want as long as you give it enough time.

It also doesn’t look like there is any way for it to stop accelerating.

Aye, it’ll keep accelerating, assuming there are no “counterforces” (not sure what the correct technical term is). So, I guess that means one would also have to add Damping to the formula. I take it Damping isn’t a real counterforce per se, but meant as a representation of the various potential factors that come into play (drag and air resistance and whatnots)? As soon as you add damping you seem to end up with a top speed. I assume Damping generates counterforces that scale with the ships velocity?

Let’s see if I understand this correctly. So, random example numbers (since I don’t know any accurate formula), I keep adding for example 110000 units of force to a ship (not sure what units the game uses for that) every tick. At the point in time my ship is at 900 m/s the Damping might generate 50000 units of counterforce, meaning I can still accelerate on the 60000 force units difference. After reaching say 1200 m/s Damping now generates 110000 units of counterforce, essentially creating a top speed as the force I push with and the force that Damping pushes back with cancel each other out?

Even if the numbers might be off, am I understanding the base concept correctly here? So, essentially I need to either take damping into account with the formula, or manually generate counterforces when reaching the desired speed?

I suppose you could do that, but it would be better to just not apply any forces at all once it is at the speed you want. In space, an object can continue moving at its current speed without any outside forces. It is only when you need a change in speed that you need a force.

What you should do is put a branch in front of the apply force and check to see if the current speed is less than the max speed. If true, apply force, if false, nothing.

…assuming combat always occurs in space and there is no need for Damping forces.

That all said and done, I am still at a loss as to what kind of formulas I can apply to achieve more precise results other than just randomly entering numbers until it seems ok.