Advertisement
Guest User

Fixed it

a guest
Oct 27th, 2015
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. if (ProjectileClass != NULL)
  2. {
  3. // Get the camera transform
  4. FVector CameraLoc = this->GetActorLocation();
  5. FRotator CameraRot = this->GetActorRotation();
  6. // MuzzleOffset is in camera space, so transform it to world space before offsetting from the camera to find the final muzzle position
  7. FVector const MuzzleLocation = CameraLoc + FTransform(CameraRot).TransformVector(GunOffset);
  8. UWorld* const World = GetWorld();
  9. if (World)
  10. {
  11. FActorSpawnParameters SpawnParams;
  12. SpawnParams.Owner = this;
  13. SpawnParams.Instigator = Instigator;
  14. // spawn the projectile at the muzzle
  15. ABlueLazorProjectile* const Projectile = World->SpawnActor<ABlueLazorProjectile>(ProjectileClass, MuzzleLocation, CameraRot, SpawnParams);
  16.  
  17. FVector const LaunchDir = CameraRot.Vector();
  18. Projectile->InitVelocity(LaunchDir);
  19.  
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement