Preventing Angular Motor Rotation of axles from rotating entire vehicle

Good afternoon,

I am in the infancy with my unreal skills and project overall.

I have a Mine cart that I am trying to move across some rail s

Requirement s:

As realistic as possible, no spline/timeline followi ng.

The cart has its Body, Axles, and Wheels as separate static meshes that are held together with Physics Constrai nts.

Problem: The rotation torque of the Angular Twist Drive is causing the Mine cart itself to flip. I have played wth various sizes of forces and the cart will ei ther:

  1. stand still (not enough force to overcome weight and fri ction)

  2. Do backflips, even if VERY slowly

I disabled gravity on all static meshes and the cart does backflips in place with the wheels r otating,

Attempted s olutions:

  1. Lower COM to - 50 to -100

  2. Cart mass 3000kg

  3. Axles 300 kg

  4. wheels 100 kg

  5. Reorganizing static mesh/Physics constraint hierarchy so Physics Constraints ar e not parents.

  6. Physics Material on the wheels - f riction 5 to 10

Ill include some ph otos and videos.

I can get the desired outcome using a crazy high number like 100000000 in “add impulse” to the forward vetor of the mine cart. But I want the drive to be derived from the a xles of the cart.

Chat GPT says the sytem is “too perfect”, not enough give or something, i dont a ccept that answer.

Side note: I am aware of the chaos vehicle system but cant for the life of me get the skeletal mesh of a static mesh imported from blender in unreal.

Any ideas? Photos and videos are attached.

Mi necart Heiarchy

I would post a video but the forum isnt letting me, also cant post more than one photo.

So as i understood you are doing a full physics simulation, vanilla without anything (Correct me if I understood it not correctly).

Thats ok should work.

1 - First things first do enable gravity on all simulated physics bodies.
Not because gravity is required for the cart to be balanced, but to keep the system consistent with the world forces. If gravity is disabled the constraint motors and torques can behave a bit misleading since there is no constant downward force.

2- Make your chasis fully aligned in positions relative. Thats important for overall stability.
Ex :
WheelFR( 100,50,0) - WheelFL (100, -50,0)
WheelBR( -100,50,0) - WheelBL (-100, -50,0)

MineCarts Static Mesh origin is 0 ,0.

3 - Designate the main carts CoM as center of mass of all simulated bodies. Since you are using pure physics bodies (body + axles + wheels) its generally good if the overall center of mass ends up near the middle of the cart and slightly lower on Z for stability.

Example : if your cart body relative position is (0,0,0) and your WheelRight position is (100,50,0) then overall mass distribution should still keep the center around the body and not drifting too much to any side. A slightly lower Z center of mass usually helps stability.

Since this is a mine cart the system should be fairly stable if wheels have a decent edge collision and a medium friction and damping on the physics material.

4- Make a singe force applied for movement. Since this is a mine cart it can only pushed or pulled. Designate a force direction (ActorForward) x ForceScalar and maybe lets do with impulse.

Location = ActorLocation  + ActorForward x Distance
// Apply forward or backward slightly outside of the cart. If cart length is 100 then 101-150 should be fine. Negative number if pull so you pull from behind lowering torque, pulling with a rope / lazy move)
// Location = ActorLocation + ActorForward x 150

TargetImpulse = ActorForward x ImpulseStrength
// Try and error could require a big number but something makes sense.

OnTick->AddImpulseAtLocation (Location , TargetImpulse)

Using angular forces on wheels is something different and requires a different logic. If you apply torque on the wheels through constraints, remember that the torque you apply on the wheel will also be applied back negatively to the parent body (the cart) because of the constraint. So the system will try to rotate both bodies unless something counteracts it. For every action there is a reaction so to nullify that reaction you have to manually add counter forces on parent body. If things balanced very nicely sometimes even that is not required but if torque is minor masses are already overcoming that issues (Wheel of a locomotive). For those you can use force limits on the contraints also contraints parent dominates bool kinda works sometimes.

Chaos vehicle works on this principle so its more accurate in terms of force application. However for a mine cart you might also want to consider how these carts usually move in reality. They normally dont steer and dont have motors, they are generally pushed or pulled, so sometimes a single directional force can be enough depending on your design.

Apply these forces on tick, preferable you can make interpolation of forces gradually increasing
FinterpTo ( CurrentImpulse , TargetImpulse )

5- Adding additional forces on the vehicle : As I understand you are making an anti roll torque on vehicle. If thats the case try to scale this forces by vehicles lateral velocity.

If the game is more arcade like and there are turns, loops or you want to keep the vehicle on the tracks you can also consider some spoiler type force pushing the cart down. This is not really to fix backflips but more like an extra stabilizing force.

Depending on the game this can be a constraint which i dont like because it feels like artificial gravity. I usually prefer using an angle approach.

Simply get the lean of the vehicle against world Z (default gravity) and scale the spoiler force with the lean. The more it leans the stronger the force pushing the cart down into the tracks.
Example :

OnTick->AddImpulseAtLocation(ActorLocation, Dot(ActorRight, FVector(0,0,-1)) * SpoilerForce * ActorUp)

You can play with spoiler force x speed and direction this can even when correctly calculated can keep vehicle upside down for a while if you have loops :slight_smile:

Let me know and would be great if you can put some more screen shots.

Thank you for the quick reply.

I would post more photos/videos but the forum only allows me one photo per post because I am a “new user”. If there is anyway you can change that please do and I would be happy to give you every detail in a single post.

  1. I had disabled gravity on the mine cart body in order to better see the torque being applied to the cart, it will be enabled for the end concept
  2. All placements are of wheels and axles are correct/ equal distance from cart origin
  3. I lowered the COM of the wheels and axle of to match that of the mine cart and the instability grew, the cart “dances” lol. (Let me know if I misunderstood your instructions)
  4. I will save your Impulse equation in my back pocket, I would like to get the movemnt form the axles solved because I eventually want to derail the trains and dont want to include a calculation to determine whether all wheels are in contact with the rails → then apply force.
  5. With the addition of forces, the idea is similar to 4: I want to derail, and fear that adding forces to counter axle rotation could inhibit that.
  6. I Enabled “Parent Dominates” on the Physics Constraint but the cart just sat there, no rotation or anything interestingly enough

I think you hit the issue on the head:

I believe the question is, how can I nullify the “negative torque” being applied.

A possible solution: Perhaps the wheelbase is just too short for this type of tourque -

It is only 70uu so maybe if I applied this Anuglar Motor to an acutal train engine/locomotive with a larger wheelbase I wouldnt have this issue?

Currently testing this with a static mesh of the cart the is scaled out 4 times so the wheelbase is 700 nstead of 70 but the cart is freaking out/breaking and will require further investigation at this time.

I will also play with angular dampening on the mine cart main body

I would like to upload a video of the current performance however, when attempting, the system says “Sorry, new users cannot upload attachments” (I am allowed 1 photo tho, if you can change/fix please do.)

Here is my one allotted photo: it is of the angular motor logic.

I hope you can zoom in on it:

Please let me know if any other details you require.

And thank you very much for your expertise.

Thanks for confirmation of the points. Thosse need to be done in the fist place generally that why mentioned those since It would lower debugging effort and actually delivering something works fine.

I lowered the COM of the wheels and axle of to match that of the mine cart and the instability grew, the cart “dances” lol. (Let me know if I misunderstood your instructions)
This is interesting to be honestly but lets leave it to the side for now, if center of masss (Com) is in meaningfull place, mass of tires are lower thaan actual body chasis, it shouldn’t behaave crazy this tells me there could be some scaling problem on overall setup but lets move for a second.

So lets focus on doing forces from the axle side as you describe maybe if necesssary wefocus on applying counter torques. Angular motor reaction torque is real however before we diving into that solution with respect I preferr to diagnose why it happens. That would be the sane path to move.

So Before diving this really suspicious.

I Enabled “Parent Dominates” on the Physics Constraint but the cart just sat there, no rotation or anything interestingly enough

That also gives me a lot of possible scenarios. So once the parent stopped absorbing / showing that reaction, the remaining motor output may simply not be enough to overcome: There can be a lot of things when parent dominates however complete stop is not something i would expect

  • Can be cause of wheel contact shape Collision shape
  • Very big mass or inertia, very high friction coefficient maybe with static even.
  • Or misconfigured constraints.

Since with some setup the wheels atleast should try to turn. Please do check these (as checklist again). A quick test I would do :slight_smile: put cart upside down and examine if there is any movement available. Atleast try try attempt to turn or struggle. Especcially SScaling can cause many issues so i suspect that quite a bit.

So I made a wheel on my side, added a body box 250kg each wheel 50 kg. 4 constraints all locked just swing 2 free besides everything default value. Positions are equal (square) constraints again aligned, no center of mass changes etc everything default.

OnTick add torque. I have a switch to negate a vector since i rotated my wheels.Also thats why I get forward vector should be right vector normally.

No issues with even no additional torque

1

But just to be sure we can also accumulate torques which is 4x and negate on body

also lets be sure that we do not use bAccelChange =true since that would neglect mass entirely.

Also if you are using asyncs maybe do on async tick

As prototype with nice collisions, spline creation it works ofcourse gameplay wise would need much more but it works. What I would add to previous post, scaling and collisions really can be important on this setup so try manipulating meshes rather than scales and be sure you have smooth collisions and proper tires.