Search Unity

Thrusters attached to an object - dynamically movable

Discussion in 'Physics' started by GameDevCouple_I, Aug 23, 2019.

  1. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,989
    Lets say I had a thruster object that I want to place somewhere on a parent ship object and then have it add force to make the ship fly.

    Normally I would have them as children, and a rigidbody on the parent, apply a force to parent perhaps relative to coordinate system and away we go.

    However, lets say I would like to be able to place these thrusters anywhere on the ship and have the position, direction and amount of them affect the ship. So if you placed 4 thrusters underneath it would provide lift at those 4 places , if I placed them all on one side it would cause the ship to react accordingly etc:

    So my question: is it better (not for performance, purely in terms of getting the direction of travel expected) to have a single rigidbody, thrusters simply as visual objects + for locating and then do everything with calls to AddForceAtPosition or similar?

    OR

    Would it be better to have the thrusters as their own objects with rigidbodies on them, attach using joints and then apply the force to the thruster itself which would then apply to the attached object?

    Basically if I put thrusters on the object in a crazy way like all along one side I would expect the ship to do somersaults if the thrust is applied correctly.

    Right now I am leaning towards the joint method, thoughts?

    And yes I realise this is a pretty basic question but its late and hot on a friday and my brain has been reduced to putty :confused:
     
  2. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    1,989
    Actually both methods work.

    If anyone has any comment on which they think would be better (in any terms, performance, physics solving quality, workflow) then please do chime in, otherwise I will proceed with fixed joints
     
  3. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,555
    I'd use the first method. I don't see a reason to use rigidbodies+joints in this case. AddForceAtPosition would do a perfect job, being both more efficient and less prone to issues in general.
     
  4. grizzly

    grizzly

    Joined:
    Dec 5, 2012
    Posts:
    271
    You'll certainly save overhead by avoiding additional rigidbodies and joints with the first option. The second option would be better if you require them to be detachable.
     
    Edy likes this.
  5. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,555
    And even in that case you may keep a single rigidbody and just instance the detached thruster in runtime when needed.
     
    GameDevCouple_I likes this.