Announcement

Collapse
No announcement yet.

Physics - What is the correct way to move pawns.

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

    Physics - What is the correct way to move pawns.

    Hi,

    So im making a game that has a hobercraft except that the craft has to be magnetised to the track - that is even when the craft is upside down in a loop, it will "stick" to the track.

    So anyway, intial attempts were to add force to the static model and set simulate physics to true when the craft got too close to the track and then a force which pulled the craft toward the track when the craft moved too far away. This was done using a line trace and checking the vector length of how far the craft was away from the track. If you use more than one check at different places on the craft and to put force in places other than the center of the craft, you will have physics problems of it flipping over. But there are other issues such as that I need for the craft to rotate based on the slope of the track we are currently hovering over so that if it goes up a hill, the craft will rotate at the same slope as the track.

    Turns out that you cant use simulate physics and setactorlocation or setworldlocation at the same time. So I thought about building my own physics and turning off simulate physics and using pure setworldlocationandrotation instead.

    So I move my craft forward by using setworldlocation on the static mesh. Not using setactorlocation on the pawn. So the way the craft is setup is the root is a pawn class, under that it has a scene component and under that it has a static mesh component. It really confuses me as to what I should be moving to actually move the craft. If I do setactorlocation on the pawn class, the static mesh stays at the same location but the actors/pawns x,y,z coordinates move forward. If i do setworldlocation on the mesh component, the craft moves forward. I think the pawns x,y,z move too but I havnt checked. So it looks like pawn movement should be done on the static mesh? but this sounds wrong to me. Im using unity before and to move an object, we would always move the root (which in this case is the pawn) and all the children would move with it (which is the scene component and the static mesh) but it appears that to move an actor I need to move the static mesh???? very confusing. What is the correct way here..

    #2
    If you move the pawn the static mesh coordinates shouldn't move because they're relative to the parent. But the mesh should still move in the world. What happens if you use set world location on the pawn?

    Comment


      #3
      I played with something similar and also had weird outcomes from time to time.
      It appeared that the "AddWorldOffset"-Nodes work somewhat more reliably, out of what reason so ever^^
      Check out my GTA2 remake in UE4

      Comment


        #4
        So if I use SetActorLocationAndRotation, The pawns x,y,z update but the static meshes x,y,z coordinates get updated in an "inverted" way to make the static mesh not look like its moving. So if the actor is at global/world space 0,0,0 and the static mesh relative/local offset is 0,0,0 and i move the pawn to global/world space 50,0,0 , the static mesh will be at -50,0,0 relative/local offset to push it back to world space 0,0,0.

        Comment

        Working...
        X