本文整理汇总了C++中FRotator::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ FRotator::Add方法的具体用法?C++ FRotator::Add怎么用?C++ FRotator::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FRotator
的用法示例。
在下文中一共展示了FRotator::Add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Sets default values
ABall::ABall() :ZPos(0.f)
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
FRotator Rotator;
Rotator.Add(0.f, FMath::Rand() % 360,0.f);
SetActorRotation(Rotator);
MovementComponent = CreateDefaultSubobject<UProjectileMovementComponent>(
TEXT("MovementComponent"));
MovementComponent->ProjectileGravityScale = 0.0f;
MovementComponent->bShouldBounce = true;
MovementComponent->Bounciness = 1.0f;
MovementComponent->Friction = 0.0f;
MovementComponent->BounceVelocityStopSimulatingThreshold = 0.0f;
MovementComponent->MaxSpeed = 1000.f;
bStartedMoving = false;
}
示例2: Rotate
void URotableActor::Rotate(const FRotator& _rotator)
{
FRotator rot = GetOwner()->GetActorRotation();
rot.Add(_rotator.Pitch, _rotator.Yaw, _rotator.Roll);
float pitch = rot.Pitch;
if (pitch > 20)
pitch = 20;
else if (pitch < -20)
pitch = -20;
float roll = rot.Roll;
if (roll > 20)
roll = 20;
else if (rot.Roll < -20)
roll = -20;
FRotator rot2(pitch, rot.Yaw, roll);
this->GetOwner()->SetActorRelativeRotation(rot2);
}
示例3: LookAtMouseCursor
void ATwinStickShooterPlayerController::LookAtMouseCursor()
{
ATwinStickShooterCharacter* const MyPawn = (ATwinStickShooterCharacter*)GetPawn();
if (MyPawn)
{
// Trace to see what is under the mouse cursor
FHitResult Hit;
GetHitResultUnderCursor(ECC_Visibility, false, Hit);
//Gets player rotation
FRotator PlayerRot = MyPawn->GetActorRotation();
//Gets the Directional Vector Ranging from -1 to 1
FVector PlayerDirection = PlayerRot.Vector()*-1;
//Get The right vector for your character
FRotator PlayerRightRot = PlayerDirection.Rotation();
PlayerRightRot.Add(0, 90, 0);
FVector RightVector = PlayerRightRot.Vector();
//Gets the players current location minus the Z
FVector PlayerLoc = MyPawn->GetActorLocation() * FVector(1, 1, 0);
//Gets Mouse location minus the Z
FVector MouseLoc = Hit.ImpactPoint * FVector(1, 1, 0);
//Find the Desired angle of rotation between the Player and Mouse
FRotator PlayerDesiredRot = (PlayerLoc - MouseLoc).Rotation();
//float FaceToAngle = PlayerDesiredRot.Clamp().Yaw;
//Gets a Directional Vector Ranging from -1 to 1 in screenspace for the mouse from the character
FVector MouseDirection = PlayerDesiredRot.Vector();
//The Aim at angle for the character
MyPawn->AimAtAngle = ((acosf(FVector::DotProduct(PlayerDirection, MouseDirection))) * (180 / 3.1415926));
//Calculate the distances from all angles
float RDist = FVector::Dist(MouseDirection, RightVector);
float LDist = FVector::Dist(MouseDirection, RightVector*-1);
float FDist = FVector::Dist(MouseDirection, PlayerDirection);
float BDist = FVector::Dist(MouseDirection, PlayerDirection * -1);
//Set bools
if (RDist <= LDist)
{
MyPawn->bLookRight = true;
}
else
{
MyPawn->bLookRight = false;
}
if (FDist <= BDist)
{
MyPawn->bLookForward = true;
}
else
{
MyPawn->bLookForward = false;
}
//GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::Printf(TEXT("Aim Right : %d :: Aim Forward : %d ::"), bLookRight, bLookForward));
}
}