Announcement

Collapse
No announcement yet.

Physics Constraint Rotation Problem!

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

    Physics Constraint Rotation Problem!

    Hey people. Had a smooth 2 months without any problems, but here we are once again - this time, a problem with physics simulation.
    We have these stairs in the game, that need to be moved around. The character cannot jump, so they are extremely important. Followed a tutorial by Tesla, and got it to work pretty well! (here's the tutorial : https://www.youtube.com/watch?v=OltZ-xFz8IQ)

    So now we could move the stairs around the room. Next, we adjusted a few things :

    Click image for larger version

Name:	StairsPhysicsTab.png
Views:	1
Size:	43.7 KB
ID:	1212774

    Linear and Angular damping were increased, to add some friction with the ground. We want the object to stay in one place as soon as it's released (since there's carpet below it, it shouldn't slide the way it initially did). We also locked the Z position, since the object shouldn't go up and down at all - it's in the right height. We also locked the X and Y rotations, to avoid the object being rotated in a weird way, that would make it impossible to use the stairs.
    Here's an image of the object to get a better idea :

    Click image for larger version

Name:	Stairs.png
Views:	1
Size:	717.4 KB
ID:	1212775

    The idea is, that the player can pick up these stairs and move them around the room, so he can open the drawers near the ceiling, and escape into the vent in the end.
    At this point, we could grab and release the stairs (this worked perfectly), and the constraints worked perfectly too - no weird rotations, and they stay in the same Z transformation! Next, we decided to fix the collisions - we wanted the stairs to have no collision with the pawn while they're being moved around. This would fix any weird 'stairs-hit-player-and-send-him-to-space' issues. Managed to do that as well :
    Click image for larger version

Name:	StairsCollision.png
Views:	1
Size:	106.2 KB
ID:	1212776

    (This is the stairs blueprint)

    Now, here's where the weird part comes. Let me first post screenshots of the whole set-up. First Person Character's Blueprint :

    Click image for larger version

Name:	StairsBlueprintSetUp.png
Views:	1
Size:	299.1 KB
ID:	1212777
    Click image for larger version

Name:	StairsRotateBlueprintTick.png
Views:	1
Size:	208.7 KB
ID:	1212778

    Where the tutorial ends, we added the part in the event tick picture - the one with the mouse. Since our X and Y rotations are constrained, we wanted the mouse's X position to control the Z rotation of the stairs, but only if Shift is pressed as well. For some reason it won't work however... I press shift, and move the mouse, but the objects acts as if I'm not doing anything. I thought it could be the angular damping, but even if it's on 0, the same behavior happens. The object will simply not rotate. It might be some of the constraints I've set up (that's why I've posted everything to do with this problem), but I have no idea if I'm doing it wrong or not... Any help would be very welcome! Thanks!

    Also, I would like to add something to the code, and I have no idea where and how to. Right now if I release the stairs, the collision is set to block the pawn, resulting in weird interactions. Here's what I'd like to happen :
    If the stairs are overlapping with the character upon releasing, they should ignore each other until they are no longer overlapping. Once they are no longer overlapping, they should block each other. Any thoughts on that too?
    Last edited by Todor Kostov; 03-09-2017, 08:05 AM.

    #2
    Update : I still have no idea how to fix the original problem, but now I'm even more surprised, that I couldn't make up how the second part of my question should work...
    I tried adding something, which had to work, but it didn't - when I release the stairs, the collision should still be set to 'ignore' as long as the character overlaps with the stairs... but that's not what happens. When I release the stairs, the collision pushes the character back. Any thoughts on that?

    Click image for larger version

Name:	StairsCollision2.png
Views:	1
Size:	130.5 KB
ID:	1124532

    Comment


      #3
      Bump... could somebody try to help me please? I am really at a lost here...

      Comment


        #4
        Hey people, not to be a nuisance, but I really need to get this working... Any help is appreciated!

        Comment


          #5
          I'm just wondering, is the ladder supposed to always simulate physics, even when the player is not moving it? Can the player bump into the ladder and have it move, or does it move only when the player 'lifts' it?
          It may not be what you're looking for, but I probably wouldn't use physics at all, just have the player move the mesh around.
          An alternative might be to disable physics when the player places it and enabling physics when they lift it?

          Comment


            #6
            I do not understand how will this solve my issues? If the ladder is lifted, I need it to rotate when I press shift + rotate the mouse, and whether it's a physics object or not, I don't think it makes a difference. Also to answer your question, no, the player won't be able to move it while it isn't lifted.

            Edit : The simulating physics part is mainly to set the object aside of all the other objects in my game (used it in the branch before the pick-up works). This is my only simulate physics object, so the game knows I can pick it up that way.

            Comment


              #7
              So I threw together a quick fps template project and I see what's going wrong. You can visualize it by adding an arrow component, uncheck the "hidden in game", and parenting it to the scene component "held object". The scene component is rotating, but not the physics object.
              A solution is to promote the Hit Component in the hit result to a variable, and setting the rotation of that, instead of the scene component.
              Though you want to adjust the X value and what not.

              As for your second problem:
              -The first collision response, set it to overlap.
              -Remove the connection between the first collision response and the true branch pin.

              Or, to avoid a tick inside the stairs you could try the following tight setup:

              Click image for larger version

Name:	physoverlap.png
Views:	1
Size:	402.8 KB
ID:	1124614

              Comment


                #8
                Thanks a ton for those ste1nar. I will try them tomorrow and let you know how it goes (away from the computer today). I really hope this will work, and the variable solution actually makes sense to me now - you need to rotate the object rather than the scene component.

                Comment


                  #9
                  I did notice a minor thing - as the player rotates the physics object, there will come a point when it stops rotating - that's because the invisible cursor has hit the edge of the screen.
                  Maybe it's not an issue? But I currently have no suggestion on that front.

                  Comment


                    #10
                    Thank you a ton for the help! The rotation problem is now fixed, but the collision problem isn't. I didn't do it with a variable, instead, I tried what you suggested :
                    -The first collision response, set it to overlap.
                    -Remove the connection between the first collision response and the true branch pin.

                    Problem persists. I noticed another problem with this whole thing today too - when I climb the stairs everything is fine, when I press crouch everything is fine too, but when I release crouch, the stairs start moving in random directions (and sometimes throw you really high up, other times they go inside walls, all sorts of collision issues). Any ideas?

                    Comment


                      #11
                      I was a bit unclear I notice now, this is what I meant:

                      Click image for larger version

Name:	someimage.png
Views:	1
Size:	70.3 KB
ID:	1124832

                      Doing that solved it for me with the collision detection when overlapping the physics object.

                      I guess that un-crouching perhaps changes the location of the collision capsule somehow, even if its just by a pixel, causing the physics object to scream "physics overlap!" and go crazy..
                      I don't really know.
                      The only solution I can think of is disabling physics for it when you place it, and enable when you lift it.
                      Or maybe, when uncrouching, teleport the character a tiny amount on z up.

                      Comment


                        #12
                        I am quite sure I did exactly this yesterday too, but it didn't work for some reason...
                        It did work now though! Thank you very much ste1nar, you've really saved my butt! Also, to make sure the stairs stay static while they're not being held, I made 2 variables - one to save the location, and one for the rotation. Then, in event tick I would teleport the stairs to those variables. It will be way more demanding on the computer than it normally would, but that's the only way I could think of, that would allow me to still have physics object on at all times.

                        Comment

                        Working...
                        X