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"

Actor tick called twice or more before animation tick?

Hi. I've been developing a first person sword fighting game with LAN connection. One of the players acts as the server too. For moving the sword, we are using blend spaces from pose to pose and we move that position based on input.

For different reasons we are calculating velocity by getting the difference between the position of a socket this frame and the last frame. However, for some reason it looks like this is being called twice and not giving a chance to the animation to move the sword, resulting in velocity being 0 or close to 0 and this screws other calculations based on this value, but the thing is that this only happens on the second player (the player that joins the match).

Here is the code:

 void AWeaponBase::UpdateSocketData()
 {
     
     for (USocketData* socket : sockets)
     {
         socket->UpdateData(WeaponMesh->GetSocketLocation(socket->socketName));
         if (Role == ROLE_Authority)
         {
             ABaS_PlayerController* pC = Cast<ABaS_PlayerController>(ownerKnight->GetController());
             if (pC && pC->playerID == selectedPlayer && socket->socketName.ToString().Contains("tip"))
             {
                 GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, FString::SanitizeFloat(socket->velocity));
             }
         }
     }
 }

Gets called in the tick function:

 void AWeaponBase::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 
     if (Role == ROLE_Authority)
     {
         if (bIsOnCooldown)
         {
             cooldownTimer += DeltaTime;
             //TODO: replace with collisionCooldown variable
             if (cooldownTimer > 0.5f)
             {
                 cooldownTimer = 0;
                 bIsOnCooldown = false;
             }
         }
         UpdateSocketData();
     }
 }
 

USocketData is our own class and this is the function that calculates velocity:

 void USocketData::UpdateData(const FVector& currentLocation)
 {
     currentDirection = currentLocation - lastPosition;
 
     velocity = (currentLocation - lastPosition).Size();
 
     lastPosition = currentLocation;
 }


Here are some screen shots:

This is the player 1 playing an idle animation. Note that the values being printed are never 0

alt text

This is player 2 doing an idle animation as well. Note the zeroes

alt text

This is player 2 again but now he is doing a swing. Note the higher values but there still are some odd zero values in there. alt text

This is really important since we are using this value to calculate damage and this bug is resulting in doing virtually zero damage when it should be otherwise. I've been trying to solve this all day with no success, maybe I'm forgetting something obvious. Any help will be immensely appreciated

Notes:

  • This calculations are server side.

  • All the data comes from server actors, not client actors

  • The screenshots show a stand alone editor window with the server.

Product Version: UE 4.9
Tags:
bs4.png (993.7 kB)
bs3.png (813.8 kB)
bs2.png (1.4 MB)
more ▼

asked Mar 01 '16 at 03:36 AM in C++ Programming

avatar image

MacDx
600 17 9 32

(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