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"

How to replicate location

Hi everyone, I am just starting with replication and dedicated server architecture. I have a custom pawn class which is used as a base for planets put in the game. I have a loop that ticks every second which calls methods responsible for the movement of the planet around itself and around it's sun. What I want to achieve is this. The loop should be called on the server only and then the new location of the planet to be replicated to all the clients. What I did try was this:

.h

 UFUNCTION()
     void UpdateActor(float dt);
 UFUNCTION(Reliable, Server, WithValidation)
     void Server_UpdateActor(float dt);
     virtual void Server_UpdateActor_Implementation(float dt);
     virtual bool Server_UpdateActor_Validate(float dt);

.cpp

 // Called every frame
 void ATC_SO_PlanetBase::Tick(float dt)
 {
     Super::Tick(dt);
     Server_UpdateActor(dt);
 }
 
 bool ATC_SO_PlanetBase::Server_UpdateActor_Validate(float dt)
 {
     return true;
 }
 
 void ATC_SO_PlanetBase::Server_UpdateActor_Implementation(float dt)
 {
     if (Role == ROLE_Authority)
     {
         GetCurrentWorldRotation(dt);
         GetCurrentLocalRotation(dt);
         SetLocation(dt);
         SetWorldRotation(dt);
         SetLocalRotation(dt);
     }
 }

I also checked the following properties in the editor: Replicates, Replicated Movement, Always Relevant. Can someone explain how should I achieve this. Any help would be appreciated. If the other part of the code is needed I will post it.

Product Version: UE 4.8
Tags:
more ▼

asked Jul 16 '15 at 10:51 AM in C++ Programming

avatar image

gogata258
110 35 28 33

(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