Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (ProjectileClass != NULL)
- {
- // Get the camera transform
- FVector CameraLoc = this->GetActorLocation();
- FRotator CameraRot = this->GetActorRotation();
- // MuzzleOffset is in camera space, so transform it to world space before offsetting from the camera to find the final muzzle position
- FVector const MuzzleLocation = CameraLoc + FTransform(CameraRot).TransformVector(GunOffset);
- UWorld* const World = GetWorld();
- if (World)
- {
- FActorSpawnParameters SpawnParams;
- SpawnParams.Owner = this;
- SpawnParams.Instigator = Instigator;
- // spawn the projectile at the muzzle
- ABlueLazorProjectile* const Projectile = World->SpawnActor<ABlueLazorProjectile>(ProjectileClass, MuzzleLocation, CameraRot, SpawnParams);
- FVector const LaunchDir = CameraRot.Vector();
- Projectile->InitVelocity(LaunchDir);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement