Announcement

Collapse
No announcement yet.

Pawn movement replication not working

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

    Pawn movement replication not working

    I created 2 default pawns(Red and Blue player).So when I open game in 2 windows(Server-client) I can only see server moving on client, but on server I can't see client moving. Everything other works except the movement replication. Here are my pics of Client Movement :

    http://prntscr.com/89tcr8 AND http://prntscr.com/89tcvn

    Please, can anyone help, i am really out of ideas :P

    #2
    In your example you aren't passing the client-side position after AddActorLocalOffset to the server. Then in srvSetActorLocation, you call GetActorLocation but since it executes on the server this is without the effect of AddActorLocalOffset which was called client-side. So to get your current idea working, let the client pass the actor's location after calling AddActorLocalOffset to srvSetActorLocation and then in srvSetActorLocation pass that position to all clients.

    However, UE already has built in functions for character movement (also useful for vehicles) and I advise you to use those. Your manual approach with SetActorLocation isn't good for detecting collisions during movement and you would have to write your own lag compensation.

    To use the built-in movement functionality, make sure Replicated and Replicates Movement are checked on the character blueprint. Then use the character function AddMovementInput which takes a world space vector of the direction you want to move in. You can use this in combination with GetActorForwardVector or GetActorRightVector to get easily get a world space direction relative to the character's facing. Properties like maximum speed, acceleration etc can all be found on the CharacterMovementComponent.
    Last edited by Zhi Kang Shao; 08-29-2015, 10:19 AM.
    Journeyman's Minimap - Available on Marketplace - Forum topic - Video

    Comment


      #3
      Originally posted by NisshokuZK View Post
      In your example you aren't passing the client-side position after AddActorLocalOffset to the server. Then in srvSetActorLocation, you call GetActorLocation but since it executes on the server this is without the effect of AddActorLocalOffset which was called client-side. So to get your current idea working, let the client pass the actor's location after calling AddActorLocalOffset to srvSetActorLocation and then in srvSetActorLocation pass that position to all clients.

      However, UE already has built in functions for character movement (also useful for vehicles) and I advise you to use those. Your manual approach with SetActorLocation isn't good for detecting collisions during movement and you would have to write your own lag compensation.

      To use the built-in movement functionality, make sure Replicated and Replicates Movement are checked on the character blueprint. Then use the character function AddMovementInput which takes a world space vector of the direction you want to move in. You can use this in combination with GetActorForwardVector or GetActorRightVector to get easily get a world space direction relative to the character's facing. Properties like maximum speed, acceleration etc can all be found on the CharacterMovementComponent.
      Thanks that worked, i am using custom pawn, and my project is simple its 1v1. Only thing is AddActorLocalOffset is jittery on server it lags very bad. I know AddMovemntInpit is replicated by it self and best for networking but in my project I use force to move it is like PERFECT for stuff I want to achieve. But force jitters little. Is there a way to do something with that lag caused by Movement with Force. Its not too much like it only lags when you move in every side then player stops and continue getting location from itself again. But I want to clean out all lags if its possible ?

      Comment


        #4
        Rama has looked into replicating physics-based movement a lot. Try checking his stuff out or asking him about it:
        https://forums.unrealengine.com/show...highlight=rama
        Journeyman's Minimap - Available on Marketplace - Forum topic - Video

        Comment

        Working...
        X