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"

Networked Attach Player Not Behaving Correctly on Server

I am trying to attach a player's character to a vehicle when entering the vehicle. The code i have works fine when running a local game, but the problem i have is that when running this in a networked game, the character is not being attached to the vehicle.

Below is some code that is called on the server when a player enters a vehicle and when the bIsInVehicle variable is OnRep'd to clients:

 SetActorEnableCollision(false);  
 
 // Do not allow the character to attempt to walk whilst in the vehicle
 GetCharacterMovement()->SetMovementMode(MOVE_None);
 GetCharacterMovement()->Deactivate();
 
 
 // Attach to the vehicle at seat socket
 FString SocketName = "Seat_";
 SocketName.AppendInt(VehicleSeat);
 AttachToComponent(CurrentVehicle->GetMesh(), FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), FName(*SocketName));

This is only a problem when running a dedicated server.

While debugging this, i made the server log the player's position while he's in the vehicle as you can see below: https://gyazo.com/f8efe03601a481c4dee46ff6489eb7de

This suggests the player is either not properly attached or there is some kind of collision or physical happening going on somewhere.

Is there anything i am doing wrong here?

Product Version: UE 4.15
Tags:
more ▼

asked Mar 10 '17 at 04:38 PM in C++ Programming

avatar image

KieranChandler
128 10 17 20

avatar image KieranChandler Mar 10 '17 at 04:53 PM

After further debugging, it seems that even if i make the attachment code run only on the server, i can see from Client 2 that the player's mesh is attached to the vehicle.

So it seems like the player is being moved, but the log indicates differently

(comments are locked)
10|2000 characters needed characters left

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