orfeasel

Applying Force to an Actor

Dec 26th, 2015
8,887
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. void AMyProjectCharacter::MoveChosenActor()
  2. {
  3.     //Get the static mesh of the chosen Actor
  4.     UStaticMeshComponent* SM = Cast<UStaticMeshComponent>(ActorToMove->GetRootComponent());
  5.  
  6.     //If the static mesh is valid apply the given force
  7.     if (SM)
  8.     {
  9.         /*When you want to apply a force you always need to multiply it's value by the
  10.         mass of the object that the object is applied to.*/
  11.         SM->AddForce(ForceToAdd*SM->GetMass());
  12.     }
  13.     else GLog->Log("Root component is not a static mesh!");
  14. }
Advertisement
Add Comment
Please, Sign In to add comment