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


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

本文整理汇总了C++中FRotator::Vector方法的典型用法代码示例。如果您正苦于以下问题:C++ FRotator::Vector方法的具体用法?C++ FRotator::Vector怎么用?C++ FRotator::Vector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FRotator的用法示例。


在下文中一共展示了FRotator::Vector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AimWithPlayerController

void AGameplayAbilityTargetActor_Trace::AimWithPlayerController(const AActor* InSourceActor, FCollisionQueryParams Params, const FVector& TraceStart, FVector& OutTraceEnd, bool bIgnorePitch) const
{
	if (!OwningAbility) // Server and launching client only
	{
		return;
	}

	APlayerController* PC = OwningAbility->GetCurrentActorInfo()->PlayerController.Get();
	check(PC);

	FVector ViewStart;
	FRotator ViewRot;
	PC->GetPlayerViewPoint(ViewStart, ViewRot);

	const FVector ViewDir = ViewRot.Vector();
	FVector ViewEnd = ViewStart + (ViewDir * MaxRange);

	ClipCameraRayToAbilityRange(ViewStart, ViewDir, TraceStart, MaxRange, ViewEnd);

	FHitResult HitResult;
	LineTraceWithFilter(HitResult, InSourceActor->GetWorld(), Filter, ViewStart, ViewEnd, TraceProfile.Name, Params);

	const bool bUseTraceResult = HitResult.bBlockingHit && (FVector::DistSquared(TraceStart, HitResult.Location) <= (MaxRange * MaxRange));

	const FVector AdjustedEnd = (bUseTraceResult) ? HitResult.Location : ViewEnd;

	FVector AdjustedAimDir = (AdjustedEnd - TraceStart).GetSafeNormal();
	if (AdjustedAimDir.IsZero())
	{
		AdjustedAimDir = ViewDir;
	}

	if (!bTraceAffectsAimPitch && bUseTraceResult)
	{
		FVector OriginalAimDir = (ViewEnd - TraceStart).GetSafeNormal();

		if (!OriginalAimDir.IsZero())
		{
			// Convert to angles and use original pitch
			const FRotator OriginalAimRot = OriginalAimDir.Rotation();

			FRotator AdjustedAimRot = AdjustedAimDir.Rotation();
			AdjustedAimRot.Pitch = OriginalAimRot.Pitch;

			AdjustedAimDir = AdjustedAimRot.Vector();
		}
	}

	OutTraceEnd = TraceStart + (AdjustedAimDir * MaxRange);
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:50,代码来源:GameplayAbilityTargetActor_Trace.cpp

示例2: GetActorInView

AActor* USCarryObjectComponent::GetActorInView()
{
	APawn* PawnOwner = Cast<APawn>(GetOwner());
	AController* Controller = PawnOwner->Controller;
	if (Controller == nullptr)
	{
		return nullptr;
	}

	FVector CamLoc;
	FRotator CamRot;
	Controller->GetPlayerViewPoint(CamLoc, CamRot);

	const FVector TraceStart = CamLoc;
	const FVector Direction = CamRot.Vector();
	const FVector TraceEnd = TraceStart + (Direction * MaxPickupDistance);

	FCollisionQueryParams TraceParams(TEXT("TraceActor"), true, PawnOwner);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = false;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingle(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);

	//DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);

	return Hit.GetActor();
}
开发者ID:Magicmay,项目名称:EpicSurvivalGameSeries,代码行数:29,代码来源:SCarryObjectComponent.cpp

示例3: OnTakeCoverPressed

void ASoftDesignTrainingPlayerController::OnTakeCoverPressed()
{
    APawn* const Pawn = GetPawn();

    if (Pawn)
    {
        FVector actorLocation = Pawn->GetActorLocation();
        FRotator actorRotation = Pawn->GetActorRotation();
        FVector coverTestStart = actorLocation;
        FVector coverTestEnd = actorLocation + 400.0f * actorRotation.Vector();

        UWorld* currentWorld = GetWorld();

        static FName InitialCoverSweepTestName = TEXT("InitialCoverSweepTest");
        FHitResult hitResult;
        FQuat shapeRot = FQuat::Identity;
        FCollisionShape collShape = FCollisionShape::MakeSphere(Pawn->GetSimpleCollisionRadius());
        FCollisionQueryParams collQueryParams(InitialCoverSweepTestName, false, Pawn);
        currentWorld->DebugDrawTraceTag = InitialCoverSweepTestName;
        FCollisionObjectQueryParams collObjQueryParams(ECC_WorldStatic);
        
        UDesignTrainingMovementComponent* charMovement = Cast<UDesignTrainingMovementComponent>(Pawn->GetMovementComponent());

        if (currentWorld->SweepSingleByObjectType(hitResult, coverTestStart, coverTestEnd, shapeRot, collObjQueryParams, collShape, collQueryParams))
        {
            if (charMovement->ValidateCover(hitResult))
            {
                MoveToCoverDestination(hitResult.Location);
            }
        }
    }
}
开发者ID:UbisoftDirMet,项目名称:SoftDesignTraining,代码行数:32,代码来源:SoftDesignTrainingPlayerController.cpp

示例4: FindDeathCameraSpot

bool AKinectPlayerController::FindDeathCameraSpot(FVector& CameraLocation, FRotator& CameraRotation)
{

	const FVector PawnLocation = GetPawn()->GetActorLocation();
	FRotator ViewDir = GetControlRotation();
	ViewDir.Pitch = -45.0f;

	const float YawOffsets[] = { 0.0f, -180.0f, 90.0f, -90.0f, 45.0f, -45.0f, 135.0f, -135.0f };
	const float CameraOffset = 600.0f;
	FCollisionQueryParams TraceParams(TEXT("DeathCamera"), true, GetPawn());

	for (int32 i = 0; i < ARRAY_COUNT(YawOffsets); i++)
	{
		FRotator CameraDir = ViewDir;
		CameraDir.Yaw += YawOffsets[i];
		CameraDir.Normalize();

		const FVector TestLocation = PawnLocation - CameraDir.Vector() * CameraOffset;
		const bool bBlocked = GetWorld()->LineTraceTest(PawnLocation, TestLocation, ECC_Camera, TraceParams);

		if (!bBlocked)
		{
			CameraLocation = TestLocation;
			CameraRotation = CameraDir;
			return true;
		}
	}

	return false;
}
开发者ID:Bnsca,项目名称:Kinect4UE4Plugin,代码行数:30,代码来源:KinectPlayerController.cpp

示例5: GetUsableItemInView

AInventoryItem* APlayerCharacter::GetUsableItemInView()
{
	FVector camLoc;
	FRotator camRot;

	if (Controller == NULL)
		return NULL;

	Controller->GetPlayerViewPoint(camLoc, camRot);
	const FVector start_trace = camLoc;
	const FVector direction = camRot.Vector();
	const FVector end_trace = start_trace + (direction * MaxUseDist);

	FCollisionQueryParams TraceParams(FName(TEXT("")), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = true;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, start_trace, end_trace, ECollisionChannel::ECC_EngineTraceChannel1, TraceParams);

	//DrawDebugLine(GetWorld(), start_trace, end_trace, FColor(255, 0, 0), false, -1, 0, 12.333);

	return Cast<AInventoryItem>(Hit.GetActor());
}
开发者ID:jackdurnford,项目名称:MidnightSnag,代码行数:25,代码来源:PlayerCharacter.cpp

示例6: TraceFromSelf

/**
*	Get location and rotation of camera. Sets players view point to camera location and rotation.
*	Sets where the trace will start, which direction, and where it ends. Traceparms setup to return details of whats collided.
*	Traces a ray against the world, returning the first blocking hit.
*
*	@params location to store hit info, distance of trace ray, the collision channel 
*	@return return the hit actor.
**/
bool APlayerCharacter::TraceFromSelf(FHitResult& OutResult, const float TraceDistance, ECollisionChannel const CollisionChannel)
{
	if (Controller)
	{
		FVector CameraLoc; 
		FRotator CameraRot;
		Controller->GetPlayerViewPoint(CameraLoc, CameraRot); //Location to cast ray (from player)

		FVector const BeginTrace = CameraLoc;
		FVector const ShootDir = CameraRot.Vector();
		FVector const TraceEnd = BeginTrace + ShootDir * TraceDistance;

		FCollisionQueryParams TraceParms(FName(TEXT("TraceFromSelf")), true, this); //returns what collided

		bool bHitReturned = false; //to determine if anything hit
		UWorld* const World = GetWorld(); 
		if (World)
		{
			bHitReturned = World->LineTraceSingleByChannel(OutResult, BeginTrace, TraceEnd, CollisionChannel, TraceParms); 
		}

		TraceParms.bTraceAsyncScene = true; //Whether we should perform the trace in the asynchronous scene.Default is false.
		TraceParms.bReturnPhysicalMaterial = false;  //Only fill in the PhysMaterial field 
		TraceParms.bTraceComplex = true; //Whether we should trace against complex collision

		return bHitReturned;
	}
	return false; //if there is no controller, nothing traced.
} 
开发者ID:jackdurnford,项目名称:MidnightSnag,代码行数:37,代码来源:PlayerCharacter.cpp

示例7: GetUsableInView

AUsableActor* AXtremeJanitorCharacter::GetUsableInView()
{
	FVector CamLoc;
	FRotator CamRot;

	if (Controller == NULL)
		return NULL;

	Controller->GetPlayerViewPoint(CamLoc, CamRot);
	const FVector TraceStart = CamLoc;
	const FVector Direction = CamRot.Vector();
	const FVector TraceEnd = TraceStart + (Direction * MaxUseDistance);

	FCollisionQueryParams TraceParams(FName(TEXT("TraceUsableActor")), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;
	TraceParams.bTraceComplex = true;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);

	// Cette ligne sera en commentaire plus tard
	DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);

	return Cast<AUsableActor>(Hit.GetActor());
}
开发者ID:MelBeee,项目名称:UE4_FinalProject_A15,代码行数:26,代码来源:XtremeJanitorCharacter.cpp

示例8: GetFirstPhysicsBodyInReach

const FHitResult UGrabber::GetFirstPhysicsBodyInReach()
{
	/// Get Player position and view data
	FVector PlayerViewPointLocation;
	FRotator PlayerViewPointRotation;
	GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT PlayerViewPointLocation, OUT PlayerViewPointRotation);

	/*UE_LOG(LogTemp, Warning, TEXT("Location: %s, Rotation: %s"), *PlayerViewPointLocation.ToString(), *PlayerViewPointRotation.ToString());*/

	/// Draw Debug Line based on how far can reach
	FVector LineTraceEnd = PlayerViewPointLocation + (PlayerViewPointRotation.Vector() * Reach);
	//DrawDebugLine(GetWorld(), PlayerViewPointLocation, LineTraceEnd, FColor(255, 0, 0), false, 0.f, 0.f, 10.f);

	/// Decide what can detect as collision
	FCollisionQueryParams TraceParameters(FName(TEXT("")), false, GetOwner());

	FHitResult LineTraceHit;
	GetWorld()->LineTraceSingleByObjectType(OUT LineTraceHit, PlayerViewPointLocation, LineTraceEnd, FCollisionObjectQueryParams(ECollisionChannel::ECC_PhysicsBody), TraceParameters);

	AActor* ActorHit = LineTraceHit.GetActor();
	if (ActorHit) {
		UE_LOG(LogTemp, Warning, TEXT("Line Trace Hit: %s"), *(ActorHit->GetName()));
	}
	return LineTraceHit;
}
开发者ID:ParhamTaher,项目名称:UnrealSection3,代码行数:25,代码来源:Grabber.cpp

示例9: GetWorld

void AITP380_RocketThingPawn::FireCluster(){
	UWorld* const World = GetWorld();
	for (int k = 0; k < NumFiredAtOnce; k++){
		FRotator FireRotation = curFireDirection.Rotation();
		FRotator randRotation = FRotator(FireRotation.Pitch, FireRotation.Yaw + FMath::RandRange(-90, 90), FireRotation.Roll);
		// Spawn projectile at an offset from this pawn
		const FVector SpawnLocation = GetActorLocation() + randRotation.RotateVector(GunOffset);

		if (World != NULL)
		{
			// spawn the projectile
			ARocketProjectile* projectile = World->SpawnActor<ARocketProjectile>(SpawnLocation, randRotation);
			projectile->targetDirection = FireRotation.Vector();
		}

		//bCanFire = false;

		// try and play the sound if specified
		
	}
	World->GetTimerManager().SetTimer(TimerHandle_ShotTimerExpired, this, &AITP380_RocketThingPawn::ShotTimerExpired, FireRate);
	projectilesFired += NumFiredAtOnce;
	
	if (projectilesFired < NumFiredTotal)
		World->GetTimerManager().SetTimer(TimerHandle_ShotIntervalExpired, this, &AITP380_RocketThingPawn::FireCluster, pauseBetweenFires);
	else
		projectilesFired = 0;
}
开发者ID:AlexZhangji,项目名称:ShootingStar,代码行数:28,代码来源:ITP380_RocketThingPawn.cpp

示例10: TraceHitForward

/*Description: Raycasts forward and detects where the player is aiming to adjust the reticles*/
bool APoseidonCharacter::TraceHitForward(APlayerController* InController, FHitResult& OutTraceResult)
{
	// Calculate the direction we are 'looking'  
	FVector CamLoc;
	FRotator CamRot;
	InController->GetPlayerViewPoint(CamLoc, CamRot);
	const FVector TraceDirection = CamRot.Vector();

	// Calculate the start location for trace  
	FVector StartTrace = FVector::ZeroVector;
	if (InController)
	{
		FRotator UnusedRotation;
		InController->GetPlayerViewPoint(StartTrace, UnusedRotation);

		// Adjust trace so there is nothing blocking the ray between the camera and the pawn, and calculate distance from adjusted start  
		StartTrace = StartTrace + TraceDirection * ((GetActorLocation() - StartTrace) | TraceDirection);
	}

	// Calculate endpoint of trace  
	const FVector EndTrace = StartTrace + TraceDirection * mGrappleRange;

	// Setup the trace query  
	static FName FireTraceIdent = FName(TEXT("GrappleTrace"));
	FCollisionQueryParams TraceParams(FireTraceIdent, true, this);
	TraceParams.bTraceAsyncScene = true;

	// Perform the trace  
	GetWorld()->LineTraceSingleByChannel(OutTraceResult, StartTrace, EndTrace, COLLISION_GRAPPLE, TraceParams);

	if (OutTraceResult.GetActor() != NULL)
	{
		FString filterEnemy = TEXT("Character");

		if (OutTraceResult.GetActor()->GetHumanReadableName().Contains(filterEnemy))
		{
			if (mIsGrappleReady)
			{
				PlayerHUD->ChangeCrosshair(EReticleEnum::RE_HIT_AIM);
			}
		}
		else
		{
			if (mIsGrappleReady)
			{
				PlayerHUD->ChangeCrosshair(EReticleEnum::RE_AIM);
			}
			else
			{
				PlayerHUD->ChangeCrosshair(EReticleEnum::RE_HIP);
			}
		}

		return true;
	}

	PlayerHUD->ChangeCrosshair(EReticleEnum::RE_HIP);

	return false;
}
开发者ID:AndreaOsorio,项目名称:PSI,代码行数:61,代码来源:PoseidonCharacter.cpp

示例11: ProjectileFire

void AShotgun::ProjectileFire()
{
	Super::ProjectileFire();

	if (BulletClass != NULL)
	{
		FActorSpawnParameters SpawnParams;
		SpawnParams.Owner = this;
		SpawnParams.Instigator = Instigator;
		FVector BulletLoc = WeaponMesh->GetSocketLocation("BulletOrigin");
		FRotator BulletRot = WeaponMesh->GetSocketRotation("BulletOrigin");

		const int32 RandomSeed = FMath::Rand();
		FRandomStream WeaponRandomStream(RandomSeed);
		const float SpreadCone = FMath::DegreesToRadians(WeaponConfig.WeaponSpread * 0.5);
		FVector ShootDir = WeaponRandomStream.VRandCone(BulletRot.Vector(), SpreadCone, SpreadCone);
		ShootDir.Z = 0;

		ABullet* const Bullet = GetWorld()->SpawnActor<ABullet>(BulletClass, BulletLoc, BulletRot, SpawnParams);
		if (Bullet)
		{
			Bullet->InitVelocity(ShootDir);
			Bullet->SetDamage(5.0f);
		}
	}

	bCanShoot = false;
	UWorld* const World = GetWorld();
	if (World != NULL)
	{
		World->GetTimerManager().SetTimer(TimeHandle_ShootCooldownExpired, this, &AMyPawnWeapon::ShootCooldownExpired, WeaponConfig.TimeBetweenShots);
	}
}
开发者ID:Vanatis,项目名称:SillyGeoCode,代码行数:33,代码来源:Shotgun.cpp

示例12: DamageTarget

void UCheatManager::DamageTarget(float DamageAmount)
{
	APlayerController* const MyPC = GetOuterAPlayerController();
	if ((MyPC == NULL) || (MyPC->PlayerCameraManager == NULL))
	{
		return;
	}

	check(GetWorld() != NULL);
	FVector const CamLoc = MyPC->PlayerCameraManager->GetCameraLocation();
	FRotator const CamRot = MyPC->PlayerCameraManager->GetCameraRotation();

	FCollisionQueryParams TraceParams(NAME_None, true, MyPC->GetPawn());
	FHitResult Hit;
	bool bHit = GetWorld()->LineTraceSingle(Hit, CamLoc, CamRot.Vector() * 100000.f + CamLoc, ECC_Pawn, TraceParams);
	if (bHit)
	{
		check(Hit.GetActor() != NULL);
		FVector ActorForward, ActorSide, ActorUp;
		FRotationMatrix(Hit.GetActor()->GetActorRotation()).GetScaledAxes(ActorForward, ActorSide, ActorUp);

		FPointDamageEvent DamageEvent(DamageAmount, Hit, -ActorForward, UDamageType::StaticClass());
		Hit.GetActor()->TakeDamage(DamageAmount, DamageEvent, MyPC, MyPC->GetPawn());
	}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:25,代码来源:CheatManager.cpp

示例13: DoTrace

void APawnWithCamera::DoTrace()
{
	FVector Loc = CameraOne->GetActorLocation();
	UE_LOG(LogClass, Error, TEXT("Loc is %s"), *Loc.ToString());
	FRotator Rot = CameraOne->GetActorRotation();
	UE_LOG(LogClass, Error, TEXT("Rot is %s"), *Rot.ToString());
	FVector Start = Loc;
	UE_LOG(LogClass, Error, TEXT("Start is %s"), *Start.ToString());
	FVector End = Loc + (Rot.Vector() * Distance);
	UE_LOG(LogClass, Error, TEXT("End is %s"), *End.ToString());
	TempActor->SetActorLocation(End);

	FCollisionQueryParams TraceParam = FCollisionQueryParams(FName(TEXT("Trace")), true, this);
	TraceParam.bTraceComplex = true;
	TraceParam.bTraceAsyncScene = true;
	TraceParam.bReturnPhysicalMaterial = false;
	TraceParam.AddIgnoredActor(this);

	FHitResult Hit(ForceInit);

	GetWorld()->LineTraceSingle(Hit, Start, End, ECC_Pawn, TraceParam);
	DrawDebugLine(GetWorld(), Start, End, FColor(255, 0, 0), false, -1, 0, 12.33f);

	if (Hit.bBlockingHit)
	{
		UE_LOG(LogClass, Error, TEXT("Hit Something"));
	}
	else
	{
		UE_LOG(LogClass, Error, TEXT("No Hit"));
	}
}
开发者ID:anteaterho,项目名称:UE4GitTest,代码行数:32,代码来源:PawnWithCamera.cpp

示例14: GetUsableInView

/*
Performs ray-trace to find closest looked-at UsableActor.
*/
ASUsableActor* ASCharacter::GetUsableInView()
{
	FVector CamLoc;
	FRotator CamRot;

	if (Controller == nullptr)
		return nullptr;

	Controller->GetPlayerViewPoint(CamLoc, CamRot);
	const FVector TraceStart = CamLoc;
	const FVector Direction = CamRot.Vector();
	const FVector TraceEnd = TraceStart + (Direction * MaxUseDistance);

	FCollisionQueryParams TraceParams(TEXT("TraceUsableActor"), true, this);
	TraceParams.bTraceAsyncScene = true;
	TraceParams.bReturnPhysicalMaterial = false;

	/* Not tracing complex uses the rough collision instead making tiny objects easier to select. */
	TraceParams.bTraceComplex = false;

	FHitResult Hit(ForceInit);
	GetWorld()->LineTraceSingleByChannel(Hit, TraceStart, TraceEnd, ECC_Visibility, TraceParams);

	//DrawDebugLine(GetWorld(), TraceStart, TraceEnd, FColor::Red, false, 1.0f);

	return Cast<ASUsableActor>(Hit.GetActor());
}
开发者ID:Raynaron,项目名称:EpicSurvivalGameSeries,代码行数:30,代码来源:SCharacter.cpp

示例15: DestroyTarget

void UCheatManager::DestroyTarget()
{
	APlayerController* const MyPC = GetOuterAPlayerController();
	if ((MyPC == NULL) || (MyPC->PlayerCameraManager == NULL))
	{
		return;
	}

	check(GetWorld() != NULL);
	FVector const CamLoc = MyPC->PlayerCameraManager->GetCameraLocation();
	FRotator const CamRot = MyPC->PlayerCameraManager->GetCameraRotation();

	FCollisionQueryParams TraceParams(NAME_None, true, MyPC->GetPawn());
	FHitResult Hit;
	bool bHit = GetWorld()->LineTraceSingle(Hit, CamLoc, CamRot.Vector() * 100000.f + CamLoc, ECC_Pawn, TraceParams);
	if (bHit)
	{
		check(Hit.GetActor() != NULL);
		APawn* Pawn = Cast<APawn>(Hit.GetActor());
		if (Pawn != NULL)
		{
			if ((Pawn->Controller != NULL) && (Cast<APlayerController>(Pawn->Controller) == NULL))
			{
				// Destroy any associated controller as long as it's not a player controller.
				Pawn->Controller->Destroy();
			}
		}

		Hit.GetActor()->Destroy();
	}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:31,代码来源:CheatManager.cpp


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