x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Client Side Jitter when applying constant input

I am trying to create a snake where body links follow the target in front of them, while the head moves forward at a constant rate. However, when playing as a client or with more then 2 clients connected, the body actors will start to jitter.

See video - Two Heads spawn with 20 bodies attached, Left is Server Right is Client. https://www.youtube.com/watch?v=IpbS9E9yIso

The actors that are moving are based off the ACharacter Object and are using the Character Movement component with both Replicates and Replicates movement flagged.

The Follow Code which is currently being called via tick:

if (!IsBody()) { return; }

 if (!Target)
 {
     return;
 }

 FVector TL = Target->GetActorLocation();
 FVector Direction = TL - GetActorLocation();

 Dis = Direction.Size();

 float MoveScale = Dis / IdealDistance;
 if (Target->IsHead())
 {
     MoveScale = 1;
 }

 if (Dis < 0)
 {
     return;
 }

 Direction.Normalize();

 float MoveSpeed = MovementSpeed;
 float DeltaTime = GetWorld()->GetDeltaSeconds();
 if (DeltaTime >= 0.4f)
 {
     return;
 }

 FVector Movement = Direction * MoveSpeed * DeltaTime * MoveScale;
 FRotator Rotation = Direction.Rotation();
 FHitResult Hit(ForceInit);

 GetCharacterMovement()->SafeMoveUpdatedComponent(Movement, Rotation, true, Hit);
 if (Hit.IsValidBlockingHit())
 {
     const FVector Normal = Hit.Normal.GetSafeNormal();
     const FVector Deflection = FVector::VectorPlaneProject(Movement, Normal) * (1.0f - Hit.Time);
     GetCharacterMovement()->SafeMoveUpdatedComponent(Deflection, Rotation, true, Hit);
 }

I have tried calling this with Authority, but that only increases the jitter. If anyone has any suggestions i would appreciate it.

Thanks

Product Version: UE 4.7
Tags:
more ▼

asked Jun 09 '15 at 11:21 PM in C++ Programming

avatar image

Frobozzien
1 1 2

avatar image Frobozzien Jun 11 '15 at 11:52 PM

So i did some more digging into my code, and found that the Server and Client are returning two different values for the line. float MoveScale = Dis / IdealDistance;

As a client this line runs twice, once for the server and once for the client. As the server the value will fluctuate between 140 and 160. When the client runs the line it will be a constant value.

now the question becomes, is there a way i can pass the client data to the server to use over its own?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question