Announcement

Collapse
No announcement yet.

How to lock / limit max angle of physics object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to lock / limit max angle of physics object

    Hi,

    Does anyone know how I can limit / lock the max angle a physics object can rotate? In my case I would like to use this to make sure the boats of my game never tip over, basically i want to limit the max roll, yaw and pitch. How would I go about doing this?

    #2
    Clamp nodes

    Comment


      #3
      Originally posted by Phantas View Post
      Clamp nodes
      Yes I'm aware of the clamp nodes, but how would i use them to clamp a mesh that is constantly affected by physics? Like If I was moving a mesh with vinterp or something i would be able to use the clamp nodes.

      Or do you mean I should like constantly clamp the mesh on tick, basically overriding the physics as they move beyond their clamped angles? Isn't there some better way to do this?

      Comment


        #4
        try physics constraints.

        Comment


          #5
          You can either do physics constraints as Nawrot says, or write your own system that will keep the boat from rolling over by applying forces to it.

          For the latter, you'd basically calculate how far off vertical it is (arccos of your dot product between the up vector and world right vector, convert radians to degrees), then apply a proportional force to that (so if it's nearly horizontal, the force will be larger than if it tipped only a small amt).
          Storyteller - An immersive VR audiobook player

          Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

          Comment


            #6
            I've tried checking the angles of the physics object and passing it through an angle clamp and this works perfectly. However, I'm actually thinking about dropping the entire physics system and replacing it with a none-physics system for stability sake.

            Comment


              #7
              WixZ, the non-physics route is probably going to be your safest and most stable route. I'm sure we've all seen what happens when physics bug out in a single frame and that would be catastrophic for a whole ship to do that on accident.

              You can still fake in a lot of effects though to make it seem more realistic. You could make some code to scan the immediate surroundings and figure out if you're on a peak of a wave or a trough of a wave and gyrate the ship accordingly. It would get pretty mathy, but I'm just throwing options out there for you.

              Comment


                #8
                Originally posted by IronicParadox View Post
                WixZ, the non-physics route is probably going to be your safest and most stable route. I'm sure we've all seen what happens when physics bug out in a single frame and that would be catastrophic for a whole ship to do that on accident.

                You can still fake in a lot of effects though to make it seem more realistic. You could make some code to scan the immediate surroundings and figure out if you're on a peak of a wave or a trough of a wave and gyrate the ship accordingly. It would get pretty mathy, but I'm just throwing options out there for you.
                Yeah my thoughts exactly. The physic based boats are neat sometimes but it's more ideal for smaller / visual things. Bigger ships and stuff need to be much more reliable and stable. And yes, the physics twerks have happened, especially when the server gets a lag spike the physics sometimes start flipping out. This happened extremely rarely though. Overall we haven't really encountered that much issues with the physics based boats, but we can't take any chances and we need more control which is why we are definitely going to drop the physics system and go for a none physics one. It will be more work to get everything looking the way we want, but in the end it will be much safer and better solution.

                Comment

                Working...
                X