Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. void handle_WorldObjects()
  2. {
  3.     // if the player gets too far from the origin, lets use the x axis
  4.     if(playerLoc.X >= furtherestBound)
  5.     {
  6.         // move the player back to the origin
  7.         // This will keep their forward movement
  8.         if(player && player->IsValidLowLevel())
  9.         {
  10.             // Save the dist for objects and set the players location
  11.             playerDist = playerLoc.X;
  12.             player->SetActorLocation(FVector(0.f, 0.f, 0.f));
  13.         }
  14.    
  15.         // Lets assume you store all objects in the world
  16.         // Lets also assume we assume we have a few segments spawned
  17.         if(listOfObjects)
  18.         {
  19.             for(int32 i = 0; i < listOfObject.Num() -1; i++)
  20.             {
  21.                 // move the object toward the origin,
  22.                 // make sure to keep the spacing so the illusion is not lost
  23.                 FVector newLoc =  FVector(listOfObject[i]->GetActorLocation().X - playerLoc.X, listOfObject[i]->GetActorLocation().Y, listOfObject[i]->GetActorLocation().Z);
  24.                 listOfObject[i]->SetActorLocation(newLoc);
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement