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"

Can the game only accept one AddActorWorldOffset() per tick?

I wrote a moving platform with the following code:

 void AMovingPlatformActor::Tick(float DeltaTime)
 {
     Super::Tick(DeltaTime);
 
     ///move if not reached full distance or wall.
     if (LastStopTime + WaitTime < GetWorld()->GetTimeSeconds())
     {
         
         if (((LastStoppedPosition - GetActorLocation()).SizeSquared() >= MoveDistance * MoveDistance) || bWallHit)
         {
             TranslationDirection = TranslationDirection * -1.0f;
             LastStopTime = GetWorld()->GetTimeSeconds();
             LastStoppedPosition = GetActorLocation();
             bWallHit = false;
         }
         FHitResult* PlatformHit = new FHitResult(ForceInit);
         AddActorWorldOffset(DeltaTime * MoveSpeed * TranslationDirection, true, PlatformHit);
         AActor* HitActor = PlatformHit->GetActor();
         if (PlatformHit->IsValidBlockingHit())
         {
             //force move platform
         AddActorWorldOffset(DeltaTime * MoveSpeed * TranslationDirection, false);
         }
     }
 }

To summarize this code: First call AddActorWorldOffset() with sweep. Then if there is a hit, call it again without sweep. This platform will not go through objects even though the second time AddActorWorldOffset() is called, it is without sweep.

Then I compared it to a simplified version:

    void AMovingPlatformActor::Tick(float DeltaTime)
     {
         Super::Tick(DeltaTime);
     
         ///move if not reached full distance or wall.
         if (LastStopTime + WaitTime < GetWorld()->GetTimeSeconds())
         {
             
             if (((LastStoppedPosition - GetActorLocation()).SizeSquared() >= MoveDistance * MoveDistance) || bWallHit)
             {
                 TranslationDirection = TranslationDirection * -1.0f;
                 LastStopTime = GetWorld()->GetTimeSeconds();
                 LastStoppedPosition = GetActorLocation();
                 bWallHit = false;
             }
             //force move platform
         AddActorWorldOffset(DeltaTime * MoveSpeed * TranslationDirection, false);
         }
     }

This code only calls AddActorWorldOffset once, without the sweep. This platform will go through walls, floor, etc. but not the player Character, which it bumps.

What's going on here?

Note that this is a simplified version of my code, but still the one I am currently testing with; the original functionality was to change direction at walls and bump player characters that were hit, but I found the player character was still somehow blocking the platform and making it fall behind (the timing of platforms is important for my game). Also: yes I know how I should use a timer, that's the next thing I'll implement, I swear it!

Product Version: UE 4.20
Tags:
more ▼

asked Nov 07 '18 at 06:00 AM in C++ Programming

avatar image

Dragon Slave
43 3 7

avatar image Brian Johnstone Nov 08 '18 at 04:21 PM

If you change the platform's collision settings to no longer collide with pawns does the sweep stop bumping the character in the 2nd case?

(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