PhysX Thrusters/Motors Instable using AddForce

Hello!

I am developing a game where a person can create their own drone. The editor is setup, the joints are fixed, but when i fire up the thrusters, which are positioned precisely opposite each other and give EXACTLY the same amount of thrust, the drone leans heavily sideways, instead of going directly up. I am using AddForce with transform.up .

Dropbox - File Deleted - Simplify your life (This picture is when i applied max thrust with no other input.)

All parts are individual rigidbodies set together with a breakable (fixed) configurable joint, which have a common parent.

Does anybody have any tips on this?

Thank you very much,
Nikita Makarov

yep… add some stabilisation forces in there :wink:

Physics are not predeterministic. This means that there is not an “exact” way physics will react, and doing the same simulation twice can give different results.

So even though mathematically your sideways forces should be canceling each other out, on the computer there will be slight differences. Over time these slight differences can add up pretty quickly causing your drone to start rotating.

This means either don’t use physics where you need exact interaction, or use JamesLeeNZ’s excellent idea and counter-balance the discrepancies.

Thanks for the quick replies!

In theory, how would i cancel these processes?

It should work… are you sure your thrusters are absolutely in right places? They need to be exactly opposite places from center of mass. You say you use rigidbodies in your thrusters, so check you got exactly same settings with all of them.

Just found out it has something to do with the configurable joints. Does anybody know the EXACT definition of the following variables (the documentation is quite bad on configurable joints):

  • Axis
  • Auto Configure Connected Anchor
  • Connected Anchor
  • Secondary Axis

Thanks!

Do you really need to use rigidbodies and joints with your thrusters? My quadcopter simulator was similar to your drone, but my setup was different:

R1 R2
X
R3 R4

Where r1-4 are rotors and they are child of X (the body). Only X has a rigidbody, and r1-4 are places what i use to add force (rigidbody.AddForceAtPosition). Works well, and copter hovers like without any problems. Perhaps you should try similar setup?

edit: X should be in center …but forumsoft doesnt seems to like spaces

My aim is to create a game where the player can design their own drone. I’m thinking of maybe using my own system to simulate the flying physics, as i don’t need it too precise.

if it doesnt need to react like it would IRL

just simulate the whole thing without the use of joints…

The problem is that it should react to the environment with physics, but it can fly arcady. I hope you get what i mean :slight_smile:

So anybody know what connected anchor is? :smile:

You dont need joints to react with the environment

In an early development of my game I wrote a system that allowed parts of my ships to get smashed off when they collided with something. There were not joints involved, I just used the contact data in the collision event

Thats actually a good idea :smile:
What would be the best procedure: using parenting or coding to make them stick together?

I would still need plausible looking physics for my motors (eg. that if a motor gets smashed off, the drone starts spinning), so any theories on how to apply that? Should i use built in functions or write my own?

Thank you!

I would go with parenting, so that if a parent gets smashed off, it takes the children with it, which is a more realistic result (otherwise you might end up with children floating in the air not attached to anything).

I would go with something custom… every part creates directional forces… ie a helicopter rotor would create up + right forces (clockwise)

A tail rotor creates -right forces.

so when you calculate your up/right/down/etc forces, you just add up the totals and then add force based on the results.

so it might look like this
Rotor +10 up, +5 right
Tail -5 right

adding them together you would get +10 up, 0 right, so you only add lift, however, you smash off the tail rotor you end up with +10 up, +5 right, making it climb but also spin uncontrollably.

Thank you very much! The Unity community really is the best on the planet!

I’ll try it out tommorow.

np… if you get stuck show us your codes :wink:

I got a couple of questions now :smile:

  1. What would be the best way to apply the calculated forces? Through the transform or kinematic rigidbody? Directly changing values or through helper functions?

  2. Where should i apply the forces: to the centre of gravity or to the main parent?

Thanks!

  1. AddForce, AddTorque, etc. If you want realistic physics that is. If you go kinematic its easier, but you have to control everything.

  2. I would do it on the parent for simplicity. If you start offsetting the force centers, you will have to use more complex values to counter balance any force you apply