本文整理汇总了C++中GetActorRotation函数的典型用法代码示例。如果您正苦于以下问题:C++ GetActorRotation函数的具体用法?C++ GetActorRotation怎么用?C++ GetActorRotation使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetActorRotation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNearbySocket
void ACoverActor::DetermineMovementDirection(FVector& MovementDirection, FRotator& FacingDirection)
{
FName NearbySocket = GetNearbySocket();
AActor* Char = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
//Determine the movement and facing direction of the player, based on the described logic
//The way that we're deciding the facing direction is similar to the way we've decided
//the movement direction
if (NearbySocket.IsEqual("ForwardSocket"))
{
MovementDirection = -GetActorRightVector();
FacingDirection = GetActorRotation();
}
else if (NearbySocket.IsEqual("BackwardSocket"))
{
MovementDirection = GetActorRightVector();
FacingDirection = GetActorRotation() + FRotator(0, 180, 0);
}
else if (NearbySocket.IsEqual("RightSocket"))
{
MovementDirection = GetActorForwardVector();
FacingDirection = GetActorRotation() + FRotator(0, 90, 0);
}
else
{
MovementDirection = -GetActorForwardVector();
FacingDirection = GetActorRotation() + FRotator(0, -90.f, 0);
}
}
示例2: FObjectAction
void ABrainNormalInteractiveObject::BeginPlay()
{
Super::BeginPlay();
int8 flags = (_canBeRotate ? EAction::ROTATE : 0)
| (_canBeTranslate ? EAction::TRANSLATE : 0)
| (_canBeScale ? EAction::SCALE : 0)
| (_canBeShear ? EAction::SHEAR : 0);
_actions = FObjectAction(flags);
// Init Rotate
_currentRotation = GetActorRotation();
_targetRotation = GetActorRotation();
// Init Translate
_currentTranslation = GetActorLocation();
_targetTranslation = GetActorLocation();
// Init Scale
_targetScale = _initScale;
_currentScale = _initScale;
// Init Shear
_currentShearFirstAxis = 0;
_currentShearSecondAxis = 0;
_targetShearFirstAxis = 0;
_targetShearSecondAxis = 0;
_cachedTransform = GetTransform();
if (this->GetClass()->ImplementsInterface(UBrainSaveInterface::StaticClass()))
Load();
}
示例3: UE_LOG
void AZombieShooterCharacter::ServerPerformAttack_Implementation(){
//Perform the actual attack here
UE_LOG(LogTemp, Warning, TEXT("Server Performing attack!"));
//In final product, will call the currently equipped weapon's fire function
//For now, just fire a basic projectile
if (ProjectileClass != NULL)
{
//MuzzleRotation.Pitch += 10.0f;
UWorld* const World = GetWorld();
if (World)
{
FActorSpawnParameters SpawnParams;
SpawnParams.Owner = this;
SpawnParams.Instigator = Instigator;
//Spawn projectile at muzzle
FVector FireLocation = GetActorLocation() + FTransform(GetActorRotation()).TransformVector(FVector(25.0f, 0.0f, 0.0f));
Projectile = World->SpawnActor<AProjectile>(ProjectileClass, FireLocation, GetActorRotation(), SpawnParams);
if (Projectile)
{
//Find launch direction
FVector const LaunchDir = GetActorRotation().Vector();
//FVector const LaunchDir = CameraBoom->GetComponentRotation().Vector();
Projectile->SetReplicates(true);
Projectile->InitVelocity(LaunchDir);
}
}
}
}
示例4: GetWorld
void AFireDart::OnHit_Implementation(AActor * OtherActor)
{
if (OtherActor != GetOwner())
{
ABanditCharacter* Bandit = Cast<ABanditCharacter>(OtherActor);
ABaseTicker* Ticker = Cast<ABaseTicker>(OtherActor);
if (Bandit)
{
if (Explosion)
{
UWorld* const World = GetWorld();
const FVector SpawnLocation = GetActorLocation();
const FRotator SpawnRotation = GetActorRotation();
World->SpawnActor<AActor>(Explosion, SpawnLocation,SpawnRotation);
UGameplayStatics::ApplyDamage(Bandit, Damage, this->GetInstigatorController(), this, UDamageType::StaticClass());
this->Destroy();
}
}
else if (Ticker)
{
if (Explosion)
{
UWorld* const World = GetWorld();
const FVector SpawnLocation = GetActorLocation();
const FRotator SpawnRotation = GetActorRotation();
World->SpawnActor<AActor>(Explosion, SpawnLocation, SpawnRotation);
UGameplayStatics::ApplyDamage(Ticker, Damage, this->GetInstigatorController(), this, UDamageType::StaticClass());
this->Destroy();
}
}
}
}
示例5: FName
void ADuckTower::Shoot(float distance)
{
/*
const FName filename = FName(TEXT("Blueprint'/Game/Blueprints/PickUp.PickUp'"));
FVector loc = GetAttachParentActor()->GetActorLocation();
FRotator rot = GetAttachParentActor()->GetActorRotation();
SpawnBP(GetWorld(), (UClass*)LoadObjFromPath<UBlueprint>(&filename), loc, rot);
*/
APawn *player = UGameplayStatics::GetPlayerController(GetWorld(), 1)->GetControlledPawn();
int randomValue = distance / 10000;
FVector vec = player->GetActorLocation() + FVector(FMath::RandRange(-randomValue, randomValue), FMath::RandRange(-randomValue, randomValue), 0.0f); //+ player->GetRootPrimitiveComponent()->GetPhysicsLinearVelocity() *DeltaSeconds * 10;
FVector vec2 = GetActorLocation();
FVector Direction = vec - vec2;
FRotator test = FRotationMatrix::MakeFromX(Direction).Rotator();
FRotator test2 = FRotator(1.0f, 0.0f, 0.0f);
FRotator finalrot = FRotator(test.Quaternion() * test2.Quaternion());
FVector forward = GetActorForwardVector();
finalrot.Roll = -finalrot.Roll;
finalrot.Yaw = -finalrot.Yaw;
finalrot.Pitch = -finalrot.Pitch;
FVector loc = GetActorLocation() + forward * 500.0f;
FRotator rot = GetActorRotation();
AActor* actor = GetWorld()->SpawnActor<AActor>(BulletBlueprint, loc, GetActorRotation());
actor->SetActorScale3D(FVector(3.0f, 3.0f, 3.0f));
//actor->GetRootPrimitiveComponent()->AddImpulse(actor->GetActorForwardVector()* 5000.0f);
//actor->GetRootPrimitiveComponent()->SetPhysicsLinearVelocity(actor->GetActorForwardVector()*10000.0f); //* (distance/10000 * 1.0f));
}
示例6: SetActorRotation
FRotator AGGJ16_Player::CalculateTargetRotation()
{
float Yaw = FMath::RadiansToDegrees(FMath::Atan2(CurrentInputRotation.Y, CurrentInputRotation.X));
SetActorRotation(FMath::Lerp(GetActorRotation(), FRotator(0.f, Yaw, 0.f), RotationAlpha));
return GetActorRotation();
}
示例7: GetActorRotation
// Called when the game starts or when spawned
void AInteractDoors::BeginPlay()
{
Super::BeginPlay();
bIsOpen = false;
rotationClosed = GetActorRotation();
rotationOpen = GetActorRotation();
rotationOpen.Yaw += 90;
}
示例8: GetActorRotation
void ACloud10Character::DiveRight(float Value, float deltaSeconds)
{
float prevYaw = GetActorRotation().Yaw;
float minDeltaYaw = minYaw - prevYaw;
float maxDeltaYaw = maxYaw - prevYaw;
//roll character in an angle front and back
curYawAmt = Value;
/*
const FRotator Rotation = GetActorRotation();
FRotator dRotation(0, 0, 0);
//curYawAmt * rotationRate
const FVector Direction = FVector(0.0f, (curYawAmt * rotationRate), 0.0f) ;//= FRotationMatrix(Rotation).GetUnitAxis(EAxis::Z);
dRotation = Direction.Rotation();
dRotation.Yaw = FMath::ClampAngle(dRotation.Yaw, minDeltaYaw, maxDeltaYaw);
//dRotation.Yaw = curYawAmt + Direction.Z;//FMath::ClampAngle(curYawAmt * Direction.Z, minDeltaYaw, maxDeltaYaw);
//Controller->SetControlRotation(dRotation);
//AddControllerYawInput(dRotation.Yaw);
FRotator tempRotation = FMath::RInterpTo(Rotation, dRotation, 3, 0);
AddActorLocalRotation(tempRotation);
//AddActorWorldRotation(dRotation);
*/
FRotator Rotation = GetActorRotation();
FVector moveDirection = FRotationMatrix(Rotation).GetUnitAxis(EAxis::Z);
//velocity movement based upon forward vector in left/right direction
const FVector ForwardDir = GetActorForwardVector();
FVector AddPos = ForwardDir;
AddPos = moveDirection * AddPos;
//add forward velocity and value of direction
AddMovementInput(AddPos, Value);
//adjust yaw
/*float val = 30;
float axisVal;
UStaticMeshComponent* smc = Cast<UStaticMeshComponent>(RootComponent);
axisVal = Value * val;
//add tilting movement control on left & right
FRotator Rotation = GetActorRotation();
Rotation.Roll = Value;
AddActorLocalRotation(Rotation);*/
//curRollAmt = Value;
// find out which way is right
/*const FRotator Rotation = Controller->GetControlRotation();
const FRotator YawRotation(0, Rotation.Yaw, 0);
// get right vector
const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
//smc->SetPhysicsLinearVelocity(Direction * axisVal);
AddControllerYawInput((Direction * axisVal));*/
}
示例9: GetWorld
void AdeezProjectile::OnHit(UPrimitiveComponent* ThisComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)
{
if ((OtherActor != NULL) && (OtherActor != this) && (OtherComp != NULL))
{
// spawn FX
AImpactFX* FX = GetWorld()->SpawnActorDeferred<AImpactFX>(ImpactTemplate, FTransform(Hit.Normal.Rotation(), Hit.Location), nullptr, Instigator, ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
if (FX)
{
FCollisionQueryParams Params = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);
Params.bTraceComplex = true;
Params.bTraceAsyncScene = true;
Params.bReturnPhysicalMaterial = true;
FHitResult secondHit(ForceInit);
FVector StartTrace;
FVector EndTrace;
StartTrace = GetActorLocation() - GetActorRotation().Vector() * 50;
EndTrace = GetActorLocation() + GetActorRotation().Vector() * 200;
GetWorld()->LineTraceSingleByChannel(secondHit, StartTrace, EndTrace, COLLISION_Weapon, Params);
FPointDamageEvent PointDmg;
//PointDmg.DamageTypeClass = DamageType;
PointDmg.HitInfo = secondHit;
PointDmg.ShotDirection = this->GetActorForwardVector();
PointDmg.Damage = Damage;
if (this->GetOwner() && this->GetOwner()->GetInstigatorController())
{
OtherActor->TakeDamage(Damage, PointDmg, this->GetOwner()->GetInstigatorController(), this->GetOwner());
}
if (secondHit.bBlockingHit)
{
FX->SurfaceHit = secondHit;
UGameplayStatics::FinishSpawningActor(FX, FTransform(FX->SurfaceHit.Normal.Rotation(), FX->SurfaceHit.Location));
}
// simulate impact
if (OtherComp->IsSimulatingPhysics())
{
OtherComp->AddImpulseAtLocation(GetProjectileMovement()->Velocity * MassMultiplier, GetActorLocation());
}
}
}
Destroy();
}
示例10: SetActorRotation
// Called every frame
void AInteractDoors::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
if (bIsOpen)
{
SetActorRotation(FMath::RInterpTo(GetActorRotation(), rotationOpen, DeltaTime, 5.f));
}
else
{
SetActorRotation(FMath::RInterpTo(GetActorRotation(), rotationClosed, DeltaTime, 5.f));
}
}
示例11: FRotator
void APlayerShip::Tick(float DeltaTime)
{
// 회전
Super::Tick(DeltaTime);
if (HandleStick->GetNormalizedFacingVector().IsZero())
{
if (RotatorSize(CurrentRotationSpeed) > DeltaTime*RotationDeccelration)
CurrentRotationSpeed -= DeltaTime*RotationDeccelration / (RotatorSize(CurrentRotationSpeed))*CurrentRotationSpeed;
else
CurrentRotationSpeed = FRotator::ZeroRotator;
}
else
{
TargetRotationSpeed = FRotator(-MaxRotationspeed*HandleStick->GetNormalizedFacingVector().X, MaxRotationspeed*HandleStick->GetNormalizedFacingVector().Y,0.0f);
CurrentRotationSpeed += DeltaTime*RotationAcceleration / RotatorSize(TargetRotationSpeed - CurrentRotationSpeed)*(TargetRotationSpeed - CurrentRotationSpeed);
//CurrentRotationSpeed += DeltaTime*RotationAcceleration*FRotator(-HandleStick->GetNormalizedFacingVector().X, HandleStick->GetNormalizedFacingVector().Y, 0);
//if (RotatorSize(CurrentRotationSpeed) > MaxRotationspeed)
// CurrentRotationSpeed = MaxRotationspeed / RotatorSize(CurrentRotationSpeed)*CurrentRotationSpeed;
}
if (GetActorRotation().Pitch > PitchClamper)
CurrentRotationSpeed.Pitch = fmin(0, CurrentRotationSpeed.Pitch);
if (GetActorRotation().Pitch < -PitchClamper)
CurrentRotationSpeed.Pitch = fmax(0, CurrentRotationSpeed.Pitch);
SetActorRotation(GetActorRotation() + DeltaTime*FRotator(CurrentRotationSpeed.Pitch, CurrentRotationSpeed.Yaw, 0));
//전진
//if (IsAccelerating)
// CurrentSpeed += DeltaTime*Acceleration;
//else
// if (CurrentSpeed > DeltaTime*Decceleration)
// CurrentSpeed -= DeltaTime*Decceleration;
// else
// CurrentSpeed = 0;
// 전방방향 이동
// 엑셀 밟고 있을때
if (HandleStick->GetisPushingSecond())
{
CurrentSpeed = (CurrentSpeed + DeltaTime*Acceleration > MaxSpeed) ? MaxSpeed : CurrentSpeed + DeltaTime*Acceleration;
}
else
{
CurrentSpeed = (CurrentSpeed - DeltaTime*Decceleration < 0) ? 0 : CurrentSpeed - DeltaTime*Decceleration;
}
AddActorLocalOffset(FVector(CurrentSpeed*DeltaTime, 0, 0));
//AddActorLocalRotation((DeltaTime*CurrentRotationSpeed).Quaternion());
//AddActorWorldRotation(FRotator(0,0,GetActorRotation().Roll));
//SetActorRotation(FRotator(GetActorRotation().Pitch, GetActorRotation().Yaw,0.0f));
//AddActorLocalRotation(FRotator(0,0, GetActorRotation().Roll));
}
示例12: GetActorRotation
// Called every frame
void APawnWithCamera::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
//zooming in and out code
if (bZoomingIn)
{
ZoomFactor += DeltaTime / 0.5f; //zoom in over half a second
}
else
{
ZoomFactor -= DeltaTime / 0.25f; // zoom out over a quarter of a second
}
ZoomFactor = FMath::Clamp<float>(ZoomFactor, 0.0f, 1.0f);
//blend our camera's FOV and our springArms length based on zoomfactor
OurCamera->FieldOfView = FMath::Lerp<float>(90.0f, 60.0f, ZoomFactor);
OurCameraSpringArm->TargetArmLength = FMath::Lerp<float>(400.0f, 300.0f, ZoomFactor);
//camera control code
{
//rotate our actor's yaw which will turn our camera because we're attached to it
FRotator newRot = GetActorRotation();
newRot.Yaw += CameraInput.X;
SetActorRotation(newRot);
//rotate the camera's pitch, but limit it so we're always looking downward
FRotator newRot2 = OurCameraSpringArm->GetComponentRotation();
newRot2.Pitch = FMath::Clamp(newRot2.Pitch + CameraInput.Y, -80.0f, -15.0f);
OurCameraSpringArm->SetWorldRotation(newRot2);
FRotator newRot3 = OurCamera->GetComponentRotation();
newRot3.Roll = FMath::Lerp<float>(newRot.Roll, 120.0f * MovementInput.Y, DeltaTime);
OurCamera->SetWorldRotation(newRot3);
}
//handle movememnt based on out movex and movey axes
if (!MovementInput.IsZero())
{
//scale our moevement input axis values by 100 units per second
MovementInput = MovementInput.GetSafeNormal();
FVector newLoc = GetActorLocation();
newLoc += GetActorForwardVector() * MovementInput.X * DeltaTime * ForwardSpeed;
newLoc += GetActorRightVector() * MovementInput.Y * DeltaTime * StrafeSpeed;
SetActorLocation(newLoc);
//also slightly roll the camera when the player strafes
FRotator newRot = FRotator(GetActorRotation().Pitch, GetActorRotation().Yaw, 0.0f);
newRot.Roll += MovementInput.Y * DeltaTime * StrafeSpeed;
}
}
示例13: GetActorRotation
void AActor::EditorApplyRotation(const FRotator& DeltaRotation, bool bAltDown, bool bShiftDown, bool bCtrlDown)
{
if( RootComponent != NULL )
{
const FRotator Rot = RootComponent->GetAttachParent() != NULL ? GetActorRotation() : RootComponent->RelativeRotation;
FRotator ActorRotWind, ActorRotRem;
Rot.GetWindingAndRemainder(ActorRotWind, ActorRotRem);
const FQuat ActorQ = ActorRotRem.Quaternion();
const FQuat DeltaQ = DeltaRotation.Quaternion();
const FQuat ResultQ = DeltaQ * ActorQ;
const FRotator NewActorRotRem = FRotator( ResultQ );
FRotator DeltaRot = NewActorRotRem - ActorRotRem;
DeltaRot.Normalize();
if( RootComponent->GetAttachParent() != NULL )
{
RootComponent->SetWorldRotation( Rot + DeltaRot );
}
else
{
// No attachment. Directly set relative rotation (to support winding)
RootComponent->SetRelativeRotation( Rot + DeltaRot );
}
}
else
{
UE_LOG(LogActor, Warning, TEXT("WARNING: EditorApplyRotation %s has no root component"), *GetName() );
}
}
示例14: GetActorLocation
bool ARobot::isObjectVisible(FVector objectPosition)
{
FVector ownLocation = GetActorLocation();
FRotator ownRotation = GetActorRotation();
float distance = sqrt(pow(ownLocation.X - objectPosition.X, 2) + pow(ownLocation.Y - objectPosition.X, 2));
if (distance < 500) //See everyting in a distance of 5 meter
{
return true;
}
//See everypting in the field of view
float angle = FMath::RadiansToDegrees(atan2(ownLocation.Y - objectPosition.Y, ownLocation.X - objectPosition.X));
float deltaAngle = angle - ownRotation.Yaw + 180;
if (deltaAngle < -180) deltaAngle += 360;
{
if (deltaAngle > 180) deltaAngle -= 360;
{
if (FMath::Abs(deltaAngle) <= HalfFieldOfView)
{
return true;
}
}
}
return false;
}
示例15: GetMaxHealth
void ANimModCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (Role == ROLE_Authority)
{
Health = GetMaxHealth();
SpawnDefaultInventory();
}
// set initial mesh visibility (3rd person view)
UpdatePawnMeshes();
// create material instance for setting team colors (3rd person view)
for (int32 iMat = 0; iMat < GetMesh()->GetNumMaterials(); iMat++)
{
MeshMIDs.Add(GetMesh()->CreateAndSetMaterialInstanceDynamic(iMat));
}
// play respawn effects
if (GetNetMode() != NM_DedicatedServer)
{
if (RespawnFX)
{
UGameplayStatics::SpawnEmitterAtLocation(this, RespawnFX, GetActorLocation(), GetActorRotation());
}
if (RespawnSound)
{
UGameplayStatics::PlaySoundAtLocation(this, RespawnSound, GetActorLocation());
}
}
}