Announcement

Collapse
No announcement yet.

[Tutorial] Smooth movement on Multiplayer while Replicating Movement of a Actor for the Client.

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

  • replied
    Originally posted by Laiebi View Post
    Hey There,
    This looks fine, I got a very similar setup trying to get a vehicle moving as I want to. I got a question concerning your approach:
    You are adding a world transform in Y direction to move your character forward in world space. This means it is only able to move in world Y-direction right?

    Now I want to make it move along the local X direction so that if I rotate my vehicle it moves straight and not sideways in world Y direction. The problem there is that I do not have a previous local position, there is only world space. If I would control all movement through controls I could try to transform the world position to get the local difference out. However I am using physics so I can not set the values for local Y and Z locations (Gravity, collision).
    Do you have an idea how I could handle the same in such a case?

    Thanks and have a happy new year!
    Laiebi
    Hello, if you are not using the vehicle as platform like we are you can use one of the movement components that already exist.

    Leave a comment:


  • replied
    Hey There,
    This looks fine, I got a very similar setup trying to get a vehicle moving as I want to. I got a question concerning your approach:
    You are adding a world transform in Y direction to move your character forward in world space. This means it is only able to move in world Y-direction right?

    Now I want to make it move along the local X direction so that if I rotate my vehicle it moves straight and not sideways in world Y direction. The problem there is that I do not have a previous local position, there is only world space. If I would control all movement through controls I could try to transform the world position to get the local difference out. However I am using physics so I can not set the values for local Y and Z locations (Gravity, collision).
    Do you have an idea how I could handle the same in such a case?

    Thanks and have a happy new year!
    Laiebi

    Leave a comment:


  • replied
    Removed the begin play part that is unnecessary.

    Leave a comment:


  • [Tutorial] Smooth movement on Multiplayer while Replicating Movement of a Actor for the Client.

    All the players execute this part on the Tick when you need to move the Actor. The code make it smooth for the Client by comparing the Actual Position that can be corrected by the server with the Old Position and just adjust how much it need to move.

    • The first part is the Acceleration(you can remove it if not needed).
    • Them you Add Transform to the Actor you want adding the Speed(always based on the Delta Seconds).
    • I added a verification if the player have the Old Location Set.
    • The part that make the correction is just Picking the Actual Position that maybe is correct by the Server Replication and subtract by the Old Location getting the distance that the Server moved the Actor, than subtract again in the Speed making the Actor just moving what it needed.
    • After adding the Speed you just save the Actual Location at the Old Location Var.




    Extra Tip:
    • Make a simple start of Movement for everyone with a Replicated Boolean in the Tick.
    • Mark for the Actor be Replicated and to Replicate Movement.
    Last edited by HeliaXDemoN; 07-12-2019, 12:16 PM.
Working...
X