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


C++ ACharacter::GetMovementComponent方法代码示例

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


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

示例1: HandleNewState

void ABatteryCollectorGameMode::HandleNewState(EBatteryPlayState NewState)
{
    switch (NewState)
    {
        // If the game is playing
    case EBatteryPlayState::EPlaying:
    {
        // spawn volumes active
        for (ASpawnVolume* Volume : SpawnVolumeActors)
        {
            Volume->SetSpawningActive(true);
        }
    }
    break;
    // If we've won the game
    case EBatteryPlayState::EWon:
    {
        // spawn volumes inactive
        for (ASpawnVolume* Volume : SpawnVolumeActors)
        {
            Volume->SetSpawningActive(false);
        }
    }
    break;
    // If we've lost the game
    case EBatteryPlayState::EGameOver:
    {
        // spawn volumes inactive
        for (ASpawnVolume* Volume : SpawnVolumeActors)
        {
            Volume->SetSpawningActive(false);
        }
        // block player input
        APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
        if (PlayerController)
        {
            PlayerController->SetCinematicMode(true, false, false, true, true);
        }
        // ragdoll the character
        ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
        if (MyCharacter)
        {
            MyCharacter->GetMesh()->SetSimulatePhysics(true);
            MyCharacter->GetMovementComponent()->MovementState.bCanJump = false;
        }
    }
    break;
    // Unknown/default state
    default:
    case EBatteryPlayState::EUnknown:
    {
        // do nothing
    }
    break;
    }

}
开发者ID:usunyu,项目名称:MyProjects,代码行数:57,代码来源:BatteryCollectorGameMode.cpp

示例2: switch

void AAssignment_1GameMode::HandleCurrentState(EBatteryPlayState NewState)
{
    switch (NewState)
    {
        // If the game is playing
        case EBatteryPlayState::EPlaying:
        {
            // Spawn Volumes Active
            for (ASpawnVolume * Volume : SpawnVolumeActors)
            {
                Volume->SetSpawningActive(true);
            }
        }
        break;
        // If we've won the game
        case EBatteryPlayState::EWon:
        {
            // Spawn Volumes Inactive
            for (ASpawnVolume * Volume : SpawnVolumeActors)
            {
                Volume->SetSpawningActive(false);
            }
        }
        break;
        // If we've lost the game
        case EBatteryPlayState::EGameOver:
        {
            // Spawn Volumes Inactives
            for (ASpawnVolume * Volume : SpawnVolumeActors)
            {
                Volume->SetSpawningActive(false);
            }
            // Block Player Input
            APlayerController * PlayerController = UGameplayStatics::GetPlayerController(this, 0);
            if (PlayerController)
            {
                PlayerController->SetCinematicMode(true, true, true);
            }
            // Ragdoll the character
            ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
            if (MyCharacter)
            {
                MyCharacter->GetMesh()->SetSimulatePhysics(true);
                MyCharacter->GetMovementComponent()->MovementState.bCanJump = false;
            }
        }
        break;
        // Debug
        default:
        case EBatteryPlayState::EUnknown:
        {
            // Do nothing
        }
        break;
    }
}
开发者ID:gsvendso,项目名称:SER432_HomeWork,代码行数:56,代码来源:Assignment_1GameMode.cpp

示例3: TickTask

//TODO: This is still an awful way to do this and we should scrap this task or do it right.
void UAbilityTask_MoveToLocation::TickTask(float DeltaTime)
{
	if (bIsFinished)
	{
		return;
	}

	Super::TickTask(DeltaTime);
	AActor* MyActor = GetAvatarActor();
	if (MyActor)
	{
		ACharacter* MyCharacter = Cast<ACharacter>(MyActor);
		if (MyCharacter)
		{
			UCharacterMovementComponent* CharMoveComp = Cast<UCharacterMovementComponent>(MyCharacter->GetMovementComponent());
			if (CharMoveComp)
			{
				CharMoveComp->SetMovementMode(MOVE_Custom, 0);
			}
		}


		float CurrentTime = GetWorld()->GetTimeSeconds();

		if (CurrentTime >= TimeMoveWillEnd)
		{
			bIsFinished = true;

			// Teleport in attempt to find a valid collision spot
			MyActor->TeleportTo(TargetLocation, MyActor->GetActorRotation());
			if (!bIsSimulating)
			{
				MyActor->ForceNetUpdate();
				OnTargetLocationReached.Broadcast();
				EndTask();
			}
		}
		else
		{
			float MoveFraction = (CurrentTime - TimeMoveStarted) / DurationOfMovement;
			if (LerpCurve)
			{
				MoveFraction = LerpCurve->GetFloatValue(MoveFraction);
			}

			MyActor->SetActorLocation(FMath::Lerp<FVector, float>(StartLocation, TargetLocation, MoveFraction));
		}
	}
	else
	{
		bIsFinished = true;
		EndTask();
	}
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:55,代码来源:AbilityTask_MoveToLocation.cpp

示例4: HandleNewState

void ABatteryCollectorGameMode::HandleNewState(EBatteryPlayState NewState)
{
	switch (NewState)
	{
	case EBatteryPlayState::EPlaying:
	{
		for (ASpawnVolume* Volume : SpawnVolumeActors)
		{
			Volume->SetSpawningActive(true);
		}
	}
	break;
	case EBatteryPlayState::EGameOver:
	{
		for (ASpawnVolume* Volume : SpawnVolumeActors)
		{
			Volume->SetSpawningActive(false);
		}
		APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
		if (PlayerController)
		{
			PlayerController->SetCinematicMode(true, false, false, true, true);
		}

		ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
		if (MyCharacter)
		{
			MyCharacter->GetMesh()->SetSimulatePhysics(true);
			MyCharacter->GetMovementComponent()->MovementState.bCanJump = false;
		}
	}
	break;
	case EBatteryPlayState::EWon:
	{
		for (ASpawnVolume* Volume : SpawnVolumeActors)
		{
			Volume->SetSpawningActive(false);
		}
	}
	break;
	case EBatteryPlayState::EUnknown:
		break;
	default:
		break;
	}
}
开发者ID:Federico-leites,项目名称:UE4BatteryCollectorPractice,代码行数:46,代码来源:BatteryCollectorGameMode.cpp

示例5: OnDestroy

void UAbilityTask_MoveToLocation::OnDestroy(bool AbilityIsEnding)
{
	AActor* MyActor = GetAvatarActor();
	if (MyActor)
	{
		ACharacter* MyCharacter = Cast<ACharacter>(MyActor);
		if (MyCharacter)
		{
			UCharacterMovementComponent* CharMoveComp = Cast<UCharacterMovementComponent>(MyCharacter->GetMovementComponent());
			if (CharMoveComp && CharMoveComp->MovementMode == MOVE_Custom)
			{
				CharMoveComp->SetMovementMode(MOVE_Falling);
			}
		}
	}

	Super::OnDestroy(AbilityIsEnding);
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:18,代码来源:AbilityTask_MoveToLocation.cpp

示例6: HandleNewState

void ABatteryCollectorGameMode::HandleNewState(EBatteryPlayState NewState)
{

    
    switch (NewState) {
        case EBatteryPlayState::EPlaying :
            
            // If the game is playing
            //
            // spawn volume active
            for (ASpawnVolume* Volume : SpawnVolumeActors) {
                Volume->SetSpawningActive(true);
            }
            
            break;
        case EBatteryPlayState::EWon :
            
            // if we won the game
            //
            // spawn volume inactive
            for (ASpawnVolume* Volume : SpawnVolumeActors) {
                Volume->SetSpawningActive(false);
            }
            
            
            break;
        case EBatteryPlayState::EGameOver :
        {
            // If we lost
            //
            // spawn volume inactive
            // block player input
            // ragdoll the character
            for (ASpawnVolume* Volume : SpawnVolumeActors) {
                Volume->SetSpawningActive(false);
            }
            
            APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
            if(PlayerController)
            {
                PlayerController->SetCinematicMode(true, false, false, true, true);
                
                UE_LOG(LogClass, Log, TEXT("You have set Cinematic Mode"));

            }
            else
            {
                UE_LOG(LogClass, Log, TEXT("Player Controller was invalid!!"));
            }

            // now ragdoll the character
            ACharacter* MyCharacter = UGameplayStatics::GetPlayerCharacter(this, 0);
            if(MyCharacter)
            {
                MyCharacter->GetMesh()->SetSimulatePhysics(true);
                MyCharacter->GetMovementComponent()->MovementState.bCanJump=false;
                
                UE_LOG(LogClass, Log, TEXT("ACharacter jump turned off and Set Simulate Physics on"));
            }else
            {
                UE_LOG(LogClass, Log, TEXT("ACharacter was invalid!! (EGameOver State in HandleNewState"));

            }
        }
            
            break;
            
        default :

            // unknown state - incase some code forgets to call
            //
            // use to help debug
            
            break;
    }
}
开发者ID:rachmann,项目名称:BatteryCollector,代码行数:76,代码来源:BatteryCollectorGameMode.cpp


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