Search Unity

Question Making a catapult

Discussion in 'Physics for ECS' started by argibaltzi, Oct 20, 2022.

  1. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    Hi gyes
    I am trying to make a catapult and have some issues i am trying to solve

    The catapult more or less works but there is strong jitter(at start of video)
    https://clipchamp.com/watch/c2ZUKATaXHe

    I am applying a one off angular impulse on the z axis on the 2 dark gray blocks

    The two dark gray blocks are connected with fixed joints to the long catapult log and with a ball & socket(x,y restricted) to the main catapult body

    When i apply the force the blocks get knocked out of position for a bit which causes the projectile to go in wrong direction.

    Is this is a good way to make a catapult using HAVOK? Are there any preferred ways to have more stable behaviour?

    Thanks!!
     
    Last edited: Oct 20, 2022
  2. elJoel

    elJoel

    Joined:
    Sep 7, 2016
    Posts:
    125
    I would probably just rotate the arm directly without physics, then at a specific angle you shoot out the projectile with a specific force. (At the angle you hide the non physics rock and instantiate a physics rock at its place)
    Or animate the catapult and shoot it out at the correct place, like i've done here:
     
  3. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    I am using a system similar to besiege, scrap mechanic and things are made out of blocks. I am trying to use physics as much as possible.

    EDIT: i dug through the forums and found a solution by setting the inverse inertia of the rotator block X=0, Y=0
    thanks to @steveeHavok
     
    Last edited: Oct 21, 2022