本文整理汇总了C++中APawn::AddMovementInput方法的典型用法代码示例。如果您正苦于以下问题:C++ APawn::AddMovementInput方法的具体用法?C++ APawn::AddMovementInput怎么用?C++ APawn::AddMovementInput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类APawn
的用法示例。
在下文中一共展示了APawn::AddMovementInput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMovementAbs
void ACinemotusPlayerController::HandleMovementAbs(float DeltaTime, bool useHydraMotion = false)
{
APawn* pawn = GetPawn();
if (!pawn)
{
return;
}
//check velocities
FVector velocity = useHydraMotion ? HydraLatestData->controllers[CAM_HAND].velocity : FVector::ZeroVector;
FVector velRel = FVector(velocity);
FRotationMatrix mat(GetControlRotation());
float scalar = 2.5;
if (useHydraMotion)
{
FRotationMatrix cMat(HydraLatestData->controllers[CAM_HAND].rotation);
velRel.X = FVector::DotProduct(cMat.GetScaledAxis(EAxis::X), velocity);
velRel.Y = FVector::DotProduct(cMat.GetScaledAxis(EAxis::Y), velocity);
velRel.Z = FVector::DotProduct(cMat.GetScaledAxis(EAxis::Z), velocity); //take motion and make relative to the orientation of the controller
}
//velocity.X*DeltaTime * scaleCmToMetres*fSpeedMulitplier +
pawn->AddMovementInput(mat.GetScaledAxis(EAxis::X), velRel.X*DeltaTime * scalar*fSpeedMulitplier + vXYandCrane.X);
pawn->AddMovementInput(mat.GetScaledAxis(EAxis::Y), velRel.Y*DeltaTime * scalar*fSpeedMulitplier + vXYandCrane.Y);
pawn->AddMovementInput(mat.GetScaledAxis(EAxis::Z), velRel.Z*DeltaTime * scalar*fSpeedMulitplier);
pawn->AddMovementInput(FVector::UpVector, vXYandCrane.Z);
//Add Movement input for offhand
FVector xPlanar = mat.GetScaledAxis(EAxis::X);
xPlanar.Z = 0;
bool didNorm = xPlanar.Normalize();
if (!didNorm)
{
xPlanar.X = 1.0; xPlanar.Normalize(); }
pawn->AddMovementInput(xPlanar, offHandPlanarMovement.X);
FVector yPlanar = mat.GetScaledAxis(EAxis::Y);
yPlanar.Z = 0;
didNorm = yPlanar.Normalize();
if (!didNorm) { yPlanar.Y = 1.0; yPlanar.Normalize(); }
pawn->AddMovementInput(yPlanar, offHandPlanarMovement.Y);
}
示例2: TickPathNavigation
void UBTTask_FlyTo::TickPathNavigation(UBehaviorTreeComponent& OwnerComp, FBT_FlyToTarget* MyMemory, float DeltaSeconds)
{
const auto& queryResults = MyMemory->QueryResults;
APawn* pawn = OwnerComp.GetAIOwner()->GetPawn();
if (DebugParams.bVisualizePawnAsVoxels)
NavigationManager->Debug_DrawVoxelCollisionProfile(Cast<UPrimitiveComponent>(pawn->GetRootComponent()));
FVector flightDirection = queryResults.PathSolutionOptimized[MyMemory->solutionTraversalIndex] - pawn->GetActorLocation();
//auto navigator = Cast<IDonNavigator>(pawn);
// Add movement input:
if (MyMemory->bIsANavigator)
{
// Customized movement handling for advanced users:
IDonNavigator::Execute_AddMovementInputCustom(pawn, flightDirection, 1.f);
}
else
{
// Default movement (handled by Pawn or Character class)
pawn->AddMovementInput(flightDirection, 1.f);
}
FVector test = FVector(10,10,100);
//test.
// Reached next segment:
if (flightDirection.Size() <= MinimumProximityRequired)
{
// Goal reached?
if (MyMemory->solutionTraversalIndex == queryResults.PathSolutionOptimized.Num() - 1)
{
UBlackboardComponent* blackboard = pawn->GetController()->FindComponentByClass<UBlackboardComponent>();
blackboard->SetValueAsBool(FlightResultKey.SelectedKeyName, true);
blackboard->SetValueAsBool(KeyToFlipFlopWhenTaskExits.SelectedKeyName, !blackboard->GetValueAsBool(KeyToFlipFlopWhenTaskExits.SelectedKeyName));
// Unregister all dynamic collision listeners. We've completed our task and are no longer interested in listening to these:
NavigationManager->StopListeningToDynamicCollisionsForPath(MyMemory->DynamicCollisionListener, queryResults);
FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
return;
}
else
{
MyMemory->solutionTraversalIndex++;
}
}
}