当前位置: 首页>>代码示例>>C++>>正文


C++ FRotator::Add方法代码示例

本文整理汇总了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;
}
开发者ID:THEOUTCASTSAREGOINGTOKICKYOURASS,项目名称:Bouncer-Ball,代码行数:21,代码来源:Ball.cpp

示例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);
}
开发者ID:belkacemlahouel,项目名称:puzzors,代码行数:21,代码来源:RotableActor.cpp

示例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));
	}
}
开发者ID:EdwardCoughlan,项目名称:TwinStickShooter,代码行数:63,代码来源:TwinStickShooterPlayerController.cpp


注:本文中的FRotator::Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。