x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Crash when loading a Level

We got a Main Menu that we're using as a level select. We also got one main level that we want to load through this Main Menu. In before, when we created the main level, after completing it it would reload (Load the current level) and sometimes a crash was occuring. Now, when we load the main level from the level select it crashes everytime.

We've been stuck on this issue for a while since there's isn't a clear answer anywhere. We tried every solution that seems to apply to our project without success.

Here is the log crash tracker:

 [2017.11.22-20.09.12:942][893]LogWindows:Error: === Critical error: ===
 [2017.11.22-20.09.12:942][893]LogWindows:Error: 
 [2017.11.22-20.09.12:942][893]LogWindows:Error: Assertion failed: !HasAnyFlags(RF_NeedLoad|RF_NeedPostLoad) [File:D:\Build\++UE4+Release-4.16+Compile\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectLinker.cpp] [Line: 105] 
 [2017.11.22-20.09.12:942][893]LogWindows:Error: Detaching from existing linker for ../../../../../Perforce/alex_SlickBoy/17-3-NAND164-SlickBoy/ProjetUnreal/SlickBoy/Content/VirtualRealityCPP/Blueprints/MotionControllerPawn.uasset while object MotionControllerHand_C /Game/VirtualRealityCPP/Blueprints/MotionControllerPawn.Default__MotionControllerPawn_C:LeftHand.LeftHand_MotionControllerHand_C_CAT needs loaded
 [2017.11.22-20.09.12:942][893]LogWindows:Error: 
 [2017.11.22-20.09.12:942][893]LogWindows:Error: 
 [2017.11.22-20.09.12:942][893]LogWindows:Error: KERNELBASE.dll!0x00000000A5843C58
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Core.dll!0x000000005781AFFE
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Core.dll!0x000000005763249B
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Core.dll!0x00000000575C0849
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-CoreUObject.dll!0x000000005823F158
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-CoreUObject.dll!0x00000000580E85BA
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-CoreUObject.dll!0x000000005812968B
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-CoreUObject.dll!0x000000005818D5EC
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Engine.dll!0x000000005374A94C
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Engine.dll!0x0000000053655ED4
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Engine.dll!0x000000005360EEA8
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-Engine.dll!0x000000005367460D
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-UnrealEd.dll!0x0000000051112F55
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor-UnrealEd.dll!0x0000000051938D86
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor.exe!0x000000007021E2B2
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor.exe!0x000000007020F0B0
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor.exe!0x000000007020F12A
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor.exe!0x0000000070220CF9
 [2017.11.22-20.09.12:942][893]LogWindows:Error: UE4Editor.exe!0x00000000702225F7
 [2017.11.22-20.09.12:942][893]LogWindows:Error: KERNEL32.DLL!0x00000000A8718364
 [2017.11.22-20.09.12:942][893]LogWindows:Error: ntdll.dll!0x00000000A8977091
 [2017.11.22-20.09.12:942][893]LogWindows:Error: ntdll.dll!0x00000000A8977091
 [2017.11.22-20.09.12:942][893]LogWindows:Error: 
 [2017.11.22-20.09.12:954][893]LogExit: Executing StaticShutdownAfterError
 [2017.11.22-20.09.12:959][893]LogWindows: FPlatformMisc::RequestExit(1)
 [2017.11.22-20.09.12:959][893]Log file closed, 11/22/17 15:09:12
 

It seems like the problem is somewhat related the scripts we use for the MotionControllers script. Here they are

ASlickBoyMotionController.h

 #pragma once
 
 #include "GameFramework/Actor.h"
 
 #include "SlickBoyMotionController.generated.h"
 
 UENUM(BlueprintType)
 enum class EGripState : uint8
 {
     Open,
     CanGrab,
     Grab
 };
 
 UCLASS()
 class SLICKBOY_API ASlickBoyMotionController : public AActor
 {
     GENERATED_BODY()
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class USceneComponent *Scene;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class UMotionControllerComponent *MotionController;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class USkeletalMeshComponent *HandMesh;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class USphereComponent *GrabSphere;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class USplineComponent *ArcSpline;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class UArrowComponent *ArcDirection;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class UStaticMeshComponent *ArcEndPoint;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class UStaticMeshComponent *TeleportCylinder;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class UStaticMeshComponent *TeleportRing;
 
     UPROPERTY( VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = ( AllowPrivateAccess = "true" ) )
     class UStaticMeshComponent *TeleportArrow;
     
 
     FRotator InitialControllerRotation;
     FVector InitialControllerLocation;
     TArray<class USplineMeshComponent*> SplineMeshes;
 public:    
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     class UStaticMesh *BeamMesh;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     class UMaterial *BeamMaterial;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     class UHapticFeedbackEffect_Base *HapticEffect;
 
     /** Is this the left or right hand */
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     EControllerHand Hand;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     float TeleportLaunchVelocity = 900;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     FVector Extents;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Variables" )
     bool WantsToGrip;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Variables" )
     bool IsTeleporterActive;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Variables" )
     EGripState Grip;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Variables" )
     class AActor *AttachedActor;
 
     FRotator TeleportRotator;
     bool LastIsValidTeleportDestination;
     bool HasValidTeleportLocation;
 
     // Sets default values for this actor's properties
     ASlickBoyMotionController();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     virtual void OnConstruction( const FTransform & Transform ) override;
     
     UFUNCTION()
     void OnComponentBeginOverlap( UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult );
 
     UFUNCTION( BlueprintNativeEvent, BlueprintCallable, Category = "Default" )
     void RumbleController( float intensity );
 
     UFUNCTION( BlueprintNativeEvent, BlueprintCallable, Category = "Default" )
     void GrabActor();
 
     UFUNCTION( BlueprintNativeEvent, BlueprintCallable, Category = "Default" )
     void ReleaseActor();
 
     UFUNCTION()
     USkeletalMeshComponent* GetHandMesh();
 
     AActor* GetActorNearHand();
     void UpdateAnimationGripState();
 
     void ActivateTeleporter();
     void DisableTeleporter();
 
     void GetTeleportDestination( FVector &OutPosition, FRotator &OutRotator );
     bool TraceTeleportDestination( TArray<FVector> &TracePoints, FVector &NavMeshLocation, FVector &TraceLocation );
 
     FRotator GetControllerRelativeRotation();
     FVector GetControllerRelativeLocation();
 
 };

ASlickBoyMotionController.cpp

 #include "SlickBoy.h"
 #include "SlickBoyMotionController.h"
 #include "SlickBoyPickupable.h"
 #include "Runtime/HeadMountedDisplay/Public/MotionControllerComponent.h"
 #include "Runtime/Engine/Classes/Components/SplineComponent.h"
 #include "Runtime/HeadMountedDisplay/Public/IHeadMountedDisplay.h"
 #include "Runtime/Engine/Classes/Kismet/KismetMathLibrary.h"
 #include "Runtime/Engine/Classes/Kismet/HeadMountedDisplayFunctionLibrary.h"
 #include "Runtime/Engine/Classes/Components/SplineMeshComponent.h"
 
 // Sets default values
 ASlickBoyMotionController::ASlickBoyMotionController() :
     Extents( 500, 500, 500 )
 {
 
 
      // 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;
 
     Hand = EControllerHand::Right;
     Grip = EGripState::Open;
 
     Scene = CreateDefaultSubobject<USceneComponent>( TEXT( "Scene" ) );
 
     MotionController = CreateDefaultSubobject<UMotionControllerComponent>( TEXT( "MotionController" ) );
     MotionController->SetupAttachment( Scene );
     MotionController->Hand = Hand;
 
     HandMesh = CreateDefaultSubobject<USkeletalMeshComponent>( TEXT( "HandMesh" ) );
     HandMesh->SetupAttachment( MotionController );
 
     GrabSphere = CreateDefaultSubobject<USphereComponent>( TEXT( "GrabSphere" ) );
     GrabSphere->SetupAttachment( HandMesh ); 
     GrabSphere->InitSphereRadius( 10.0f );
     GrabSphere->OnComponentBeginOverlap.AddDynamic( this, &ASlickBoyMotionController::OnComponentBeginOverlap );
 
     ArcDirection = CreateDefaultSubobject<UArrowComponent>( TEXT( "ArcDirection" ) );
     ArcDirection->SetupAttachment( HandMesh );
 
     ArcSpline = CreateDefaultSubobject<USplineComponent>( TEXT( "ArcSpline" ) );
     ArcSpline->SetupAttachment( HandMesh );
 
     ArcEndPoint = CreateDefaultSubobject<UStaticMeshComponent>( TEXT( "ArcEndPoint" ) );
     ArcEndPoint->SetupAttachment( Scene );
     ArcEndPoint->SetVisibility( false );
 
     TeleportCylinder = CreateDefaultSubobject<UStaticMeshComponent>( TEXT( "TeleportCylinder" ) );
     TeleportCylinder->SetupAttachment( Scene );
 
     TeleportRing = CreateDefaultSubobject<UStaticMeshComponent>( TEXT( "TeleportRing" ) );
     TeleportRing->SetupAttachment( TeleportCylinder );
 
     TeleportArrow = CreateDefaultSubobject<UStaticMeshComponent>( TEXT( "TeleportArrow" ) );
     TeleportArrow->SetupAttachment( TeleportCylinder );    
 }
 
 void ASlickBoyMotionController::OnConstruction(const FTransform & Transform)
 {
     Super::OnConstruction(Transform);
 
     if (Hand == EControllerHand::Left)
     {
         // Reflect hand mesh
         //HandMesh->SetWorldScale3D( FVector( 1, 1, -1 ) );
     }
 
 }
 
 void ASlickBoyMotionController::RumbleController_Implementation( float intensity )
 {
     FLatentActionInfo actionInfo;
     actionInfo.CallbackTarget = this;
     APlayerController *playerController = GetWorld()->GetFirstPlayerController();
     playerController->PlayHapticEffect( HapticEffect, Hand, intensity, false );
 }
 
 void ASlickBoyMotionController::OnComponentBeginOverlap( UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult )
 {
     Grip = EGripState::CanGrab;
     if ( ( OtherComp != nullptr ) && ( OtherComp != GrabSphere ) )
     {
         UStaticMeshComponent *mesh = Cast<UStaticMeshComponent>( OtherComp );
         if ( mesh && mesh->IsSimulatingPhysics() )
         {
             this->RumbleController( 0.8 );
         }
     }
 }
 
 // Called when the game starts or when spawned
 void ASlickBoyMotionController::BeginPlay()
 {
     Super::BeginPlay();
 
     MotionController->Hand = Hand;
     if ( Hand == EControllerHand::Left )
     {
         // Reflect hand mesh
         MotionController->Hand = Hand;
         //HandMesh->SetWorldScale3D( FVector( 1, 1, -1 ) );
     }
 
     // Hide until activation (but wait for BeginPlay so it is shown in editor)
     TeleportCylinder->SetVisibility( false, true );
 }
 
 USkeletalMeshComponent* ASlickBoyMotionController::GetHandMesh()
 {
     return HandMesh;
 }
 
 AActor* ASlickBoyMotionController::GetActorNearHand()
 {
     TArray<AActor*> overlappingActors;
 
     GrabSphere->GetOverlappingActors( overlappingActors );
     FVector handLocation = GrabSphere->GetComponentLocation();
 
     AActor* nearest = nullptr;
     float mindist = 99999999999;
 
     // Find closest overlaping actor
     for ( AActor *actor : overlappingActors )
     {
         bool isPickupable = actor->GetClass()->ImplementsInterface( USlickBoyPickupable::StaticClass() );
         if ( isPickupable )
         {
 
             float dist = ( actor->GetActorLocation() - handLocation ).SizeSquared();
             if ( dist < mindist )
             {
                 mindist = dist;
                 nearest = actor;
             }
         }
     }
 
     //     if ( GEngine && Hand == EControllerHand::Right )
 //         GEngine->AddOnScreenDebugMessage( -1, 0.16f, FColor::Red,
 //             FString::Printf( TEXT( "Actors near right hand %d, found pickupable: %d, %s" ), 
 //             overlappingActors.Num(), 
 //             count,
 //             nearest ? TEXT( "TRUE" ) : TEXT( "FALSE" ) ) );
 
     return nearest;
 }
 
 void ASlickBoyMotionController::UpdateAnimationGripState()
 {
     // Default to Open
     Grip = EGripState::Open;
 
     if ( AttachedActor )
     {
         // If holding an object, always keep fist closed
         Grip = EGripState::Grab;
     }
     else
     {
         // React to player input
         if ( WantsToGrip )
             Grip = EGripState::Grab;
 
         // If not holding something, the hand should open or close 
         // slightly when passing over an interactable object
         AActor *actor = GetActorNearHand();
         if ( actor )
             Grip = EGripState::CanGrab;
     }
 
     // Only let hand collide with environment while gripping
     if ( Grip == EGripState::Grab )
         HandMesh->SetCollisionEnabled( ECollisionEnabled::QueryAndPhysics );
     else
         HandMesh->SetCollisionEnabled( ECollisionEnabled::NoCollision );
 }
 
 void ASlickBoyMotionController::GrabActor_Implementation()
 {
     WantsToGrip = true;
 
     AActor *actor = GetActorNearHand();
     if ( actor && actor->IsValidLowLevel() )
     {
         AttachedActor = actor;
         ISlickBoyPickupable::Execute_Pickup( actor, MotionController );
         RumbleController( 0.7 );
     }
 
 }
 
 void ASlickBoyMotionController::ReleaseActor_Implementation()
 {
     WantsToGrip = false;
 
     AActor *actor = AttachedActor;
     if ( actor && actor->IsValidLowLevel() )
     {
         // Make sure this hand is still holding the Actor (May have been taken by another hand / event)
         if ( MotionController == actor->GetRootComponent()->GetAttachParent() )
         {
             ISlickBoyPickupable::Execute_Drop( actor );
             RumbleController( 0.2 );
         }
     }
 
     AttachedActor = nullptr;
 }
 
 // Called every frame
 void ASlickBoyMotionController::Tick( float DeltaTime )
 {
     Super::Tick( DeltaTime );
 
     UpdateAnimationGripState();
 
     if ( IsTeleporterActive )
     {
         TArray<FVector> TracePoints;
         FVector NavLocation;
         FVector HitLocation;
         bool IsValidTeleportDestination = TraceTeleportDestination( TracePoints, NavLocation, HitLocation );
 
         TeleportCylinder->SetVisibility( IsValidTeleportDestination, true );
 
         if ( IsValidTeleportDestination )
         {
             // Find Floor at Teleport Location and Move Cylinder
             FHitResult OutHit;
             {
                 FVector EndPos = NavLocation + FVector( 0, 0, -200 );
                 FCollisionQueryParams CollisionQueryParams( FName( TEXT( "TeleporterDrop" ) ), false, this );
                 GetWorld()->LineTraceSingleByChannel( OutHit, NavLocation, EndPos, ECC_WorldStatic, CollisionQueryParams );
             }
 
             FVector TeleportCylinderLocation;
             if ( OutHit.bBlockingHit )
                 TeleportCylinderLocation = OutHit.ImpactPoint;
             else
                 TeleportCylinderLocation = NavLocation;
 
             TeleportCylinder->SetWorldLocation( TeleportCylinderLocation, false, nullptr, ETeleportType::TeleportPhysics );
 
             ArcEndPoint->SetVisibility( true );
             ArcEndPoint->SetWorldLocation( HitLocation, false, nullptr, ETeleportType::TeleportPhysics );
 
             // Rotate Arrow
             FRotator ArrowRotator = TeleportRotator;
 
              IHeadMountedDisplay *hmd = GEngine->HMDDevice.Get();
             if ( hmd )
             {
                 FRotator DeviceRotation;
                 FVector DevicePosition;
                 UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition( DeviceRotation, DevicePosition );
 
                 DeviceRotation.Pitch = 0;
                 DeviceRotation.Roll = 0;
 
                 ArrowRotator = UKismetMathLibrary::ComposeRotators( TeleportRotator, DeviceRotation );
             }
 
             TeleportArrow->SetWorldRotation( ArrowRotator );
             
             // Make Spline....
             if ( TracePoints.Num() > 0 )
             {
                 ArcSpline->ClearSplinePoints();
                 for ( FVector TracePoint : TracePoints )
                 {
                     ArcSpline->AddSplinePoint( TracePoint, ESplineCoordinateSpace::Local, true );
                 }
                 ArcSpline->SetSplinePointType( TracePoints.Num() - 1, ESplinePointType::CurveClamped, true );
 
                 for ( int i = 0; i < TracePoints.Num() - 2; i++ )
                 {
                     FVector StartPos = TracePoints[i];
                     FVector StartTangent = ArcSpline->GetTangentAtSplinePoint( i, ESplineCoordinateSpace::Local );
 
                     FVector EndPos = TracePoints[i + 1];
                     FVector EndTangent = ArcSpline->GetTangentAtSplinePoint( i + 1, ESplineCoordinateSpace::Local );
 
                     USplineMeshComponent *SplineMeshComponent;
                         
                     if ( i >= SplineMeshes.Num() )
                     {
                         SplineMeshComponent = NewObject<USplineMeshComponent>( this, USplineMeshComponent::StaticClass() );
                         SplineMeshComponent->SetStaticMesh( BeamMesh );
                         SplineMeshComponent->SetMaterial( 0, BeamMaterial );
                         SplineMeshComponent->SetStartScale( FVector2D( 4, 4 ) );
                         SplineMeshComponent->SetEndScale( FVector2D( 4, 4 ) );
                         SplineMeshComponent->SetBoundaryMax( 1 );
                         SplineMeshes.Push( SplineMeshComponent );
                     }
                     SplineMeshComponent = SplineMeshes[i];
 
                     SplineMeshComponent->SetVisibility( true );
                     SplineMeshComponent->SetStartAndEnd( StartPos, StartTangent, EndPos, EndTangent );
 
 
                 }
 
                 // Hide any extra
                 for ( int i = TracePoints.Num() - 2; i < SplineMeshes.Num(); i++ )
                     SplineMeshes[i]->SetVisibility( false );
 
                 RegisterAllComponents();
             }
 
             
         }
 
         // If it changed, rumble.
         if ( LastIsValidTeleportDestination != IsValidTeleportDestination )
             RumbleController( 0.3 );
         LastIsValidTeleportDestination = IsValidTeleportDestination;
     }
     
 }
 
 void ASlickBoyMotionController::ActivateTeleporter()
 {
 //    if ( GEngine ) GEngine->AddOnScreenDebugMessage( -1, 0.16f, FColor::White, FString::Printf( TEXT( "Activating Teleporter " ) ) );
     IsTeleporterActive = true;
 
     if (MotionController) {
         InitialControllerRotation = MotionController->GetComponentRotation();
         InitialControllerLocation = MotionController->GetComponentLocation();
     }
         
 }
 
 
 void ASlickBoyMotionController::DisableTeleporter()
 {
     IsTeleporterActive = false;
     
     TeleportCylinder->SetVisibility( false, true );
     ArcEndPoint->SetVisibility( false );
 
     // Hide old Spline
     for ( USplineMeshComponent *SplineMesh : SplineMeshes )
         SplineMesh->SetVisibility( false );
 
     // TODO: Roomscale Mesh
 }
 
 bool ASlickBoyMotionController::TraceTeleportDestination( TArray<FVector> &TracePoints, FVector &NavMeshLocation, FVector &TraceLocation )
 {
 
     FVector StartPos = ArcDirection->GetComponentLocation();
     FVector LaunchVelocity = ArcDirection->GetForwardVector();
 
     LaunchVelocity *= TeleportLaunchVelocity;
 
     // Predict Projectile Path
     
     FPredictProjectilePathParams PredictParams( 0.0f, StartPos, LaunchVelocity, 4.0f, UEngineTypes::ConvertToObjectType( ECC_WorldStatic ) );
     FPredictProjectilePathResult PredictResult;
     const bool DidPredictPath = UGameplayStatics::PredictProjectilePath( GetWorld(), PredictParams, PredictResult );
     if ( !DidPredictPath )
         return false;
 
     // Getting Projected Endpoint
     
     FVector PointToProject = PredictResult.HitResult.Location;
     FNavLocation ProjectedHitLocation; 
     UNavigationSystem *NavSystem = GetWorld()->GetNavigationSystem();
     const bool DidProjectToNav = NavSystem->ProjectPointToNavigation( PointToProject, ProjectedHitLocation, Extents );
     if ( !DidProjectToNav )
         return false;
 
     // Outputs...
 
     TracePoints.Empty();
     for ( FPredictProjectilePathPointData Point : PredictResult.PathData )
         TracePoints.Push( Point.Location );
 
     TraceLocation = PredictResult.HitResult.Location;
     NavMeshLocation = ProjectedHitLocation.Location;    
 
     return true;
 }
 
 
 void ASlickBoyMotionController::GetTeleportDestination( FVector &OutPosition, FRotator &OutRotator )
 {
     IHeadMountedDisplay *hmd = GEngine->HMDDevice.Get();
     FVector DevicePosition(ForceInitToZero);
     if ( hmd )
     {
         FRotator DeviceRotation;
         UHeadMountedDisplayFunctionLibrary::GetOrientationAndPosition( DeviceRotation, DevicePosition );
         DevicePosition.Z = 0; // Ignore relative height difference
     }
 
     DevicePosition = TeleportRotator.RotateVector( DevicePosition );
 
     // Substract HMD origin (Camera) to get correct Pawn destination for teleportation.
     OutPosition = TeleportCylinder->GetComponentLocation() - DevicePosition;
     OutRotator = TeleportRotator;
 }
 
 FRotator ASlickBoyMotionController::GetControllerRelativeRotation()
 {
     const FTransform InitialTransform( InitialControllerRotation );
     const FTransform CurrentTransform = MotionController->GetComponentTransform();
     const FTransform RelativeTransform = CurrentTransform.GetRelativeTransform( InitialTransform );
 
     return RelativeTransform.GetRotation().Rotator();
 }
 
 FVector ASlickBoyMotionController::GetControllerRelativeLocation()
 {
     const FTransform InitialTransform(InitialControllerLocation);
     const FTransform CurrentTransform = MotionController->GetComponentTransform();
     const FTransform RelativeTransform = CurrentTransform.GetRelativeTransform(InitialTransform);
 
     return RelativeTransform.GetLocation();
 }

The motion controllers are used by a MotionControllerPawn

ASlickBoyMotionControllerPawn.h

 #include "SlickBoy.h"
 #include "SlickBoyMotionControllerPawn.h"
 #include "SlickBoyMotionController.h"
 #include "Runtime/HeadMountedDisplay/Public/IHeadMountedDisplay.h"
 #include "Managers/DebugMessage.h"
 #include "SlickBoy_TestGameMode.h"
 #include "SlickBoy/Managers/BeatManager.h"
 
 // Sets default values
 ASlickBoyMotionControllerPawn::ASlickBoyMotionControllerPawn()
 {
      // Set this pawn to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     VROrigin = CreateDefaultSubobject<USceneComponent>(TEXT("VROrigin"));
     VROrigin->SetupAttachment(RootComponent);
 
     Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
     Camera->SetupAttachment(VROrigin);
 
     LeftHand = CreateDefaultSubobject<UChildActorComponent>(TEXT("LeftHand"));
     LeftHand->SetupAttachment(VROrigin);
 
     RightHand = CreateDefaultSubobject<UChildActorComponent>(TEXT("RightHand"));
     RightHand->SetupAttachment(VROrigin);
 
     capsuleComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("Collider"));
     capsuleComponent->SetupAttachment(Camera);
 
     DeviceType = EHMDDeviceType::DT_ES2GenericStereoMesh;
 
     static ConstructorHelpers::FObjectFinder<UClass> bullet(TEXT("Class'/Game/BluePrints/Bullet.Bullet_C'"));
     if (bullet.Object) {
         myBullet = (UClass*)bullet.Object;
     }
 
     static ConstructorHelpers::FObjectFinder<UAnimSequence> myShootAnim(TEXT("AnimSequence'/Game/Meshes/Weapons/Pistol_Anim_Shoot.Pistol_Anim_Shoot'"));
     if (myShootAnim.Object) {
         shootAnim = myShootAnim.Object;
     }
 
     static ConstructorHelpers::FObjectFinder<UAnimSequence> mySurchargeAnim(TEXT("AnimSequence'/Game/Meshes/Weapons/Pistol_Anim_Surcharge.Pistol_Anim_Surcharge'"));
     if (mySurchargeAnim.Object) {
         surchargeAnim = mySurchargeAnim.Object;
     }
 
     static ConstructorHelpers::FObjectFinder<UParticleSystem> PS(TEXT("ParticleSystem'/Game/Particles/PS_gunfire.PS_gunfire'"));
     HitParticleComponent = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("PS_gunfire"));
     HitParticleComponent->SetupAttachment(VROrigin);
     HitParticleComponent->bAutoActivate = false;
     HitParticleComponent->SetTemplate(PS.Object);
     HitParticleComponent->BodyInstance.bLockXRotation = true;
     HitParticleComponent->BodyInstance.bLockYRotation = true;
     HitParticleComponent->BodyInstance.bLockZRotation = true;
 }
 
 // Called when the game starts or when spawned
 void ASlickBoyMotionControllerPawn::BeginPlay()
 {
     Super::BeginPlay();
 
     Controller = UGameplayStatics::GetPlayerController(GetWorld(), 0);
 
     HitParticleComponent->DeactivateSystem();
 
     // Setup Player Height for Various Platforms
     IHeadMountedDisplay *hmd;
     if (GEngine)
         hmd = GEngine->HMDDevice.Get();
     else
         hmd = NULL;
     if ( hmd )
     {
         DeviceType = hmd->GetHMDDeviceType();
 
         // Set up Teleport Style
         if ( ControlScheme == ETeleportControlScheme::Auto )
             ControlScheme =
                 ( DeviceType == EHMDDeviceType::DT_OculusRift    ? ETeleportControlScheme::StickOnly :
                 ( DeviceType == EHMDDeviceType::DT_Morpheus        ? ETeleportControlScheme::ControllerRoll
                                                                 : ETeleportControlScheme::ButtonAndStick ) );
 
         if ( DeviceType == EHMDDeviceType::DT_SteamVR || DeviceType == EHMDDeviceType::DT_OculusRift )
         {
             hmd->SetTrackingOrigin(EHMDTrackingOrigin::Floor);
         }
         else
         {
             // PSVR
             hmd->SetTrackingOrigin(EHMDTrackingOrigin::Eye);
 
             // Set Height Offset for Tracking            
             VROrigin->AddLocalOffset( FVector( 0, 0, DefaultPlayerHeight ) );
         }
     }
 
     surcharge = false;
     surchargeMeter = 0;
     offBeatAugmentation = 15;
     constantSurchargeDeflate = 25;
 
 
     actualTimer = timeForInvincibility; //Set the Invincibility Timer at its max Time
 
 }
 
 void ASlickBoyMotionControllerPawn::FinishTeleport( ASlickBoyMotionController *Current, const FVector &TeleportPosition, const FRotator &TeleportRotator )
 {
     Current->DisableTeleporter();
 
     // Move the player
     TeleportTo( TeleportPosition, TeleportRotator, false, false );
 
     // Fade back in
     APlayerCameraManager *PlayerCamera = UGameplayStatics::GetPlayerCameraManager( GetWorld(), 0 );
     PlayerCamera->StartCameraFade( 1, 0, FadeInDuration, TeleportFadeColor, false, true );
 
     // All done.
     IsTeleporting = false;
 }
 
 void ASlickBoyMotionControllerPawn::ExecuteTeleport( ASlickBoyMotionController *Current )
 {
     if ( IsTeleporting )
         return;
 
     //     if ( !Current->HasValidTeleportLocation )
     //     {
     //         Current->DisableTeleporter();
     //         return;
     //     }
 
     FVector TeleportPosition;
     FRotator TeleportRotator;
 
     Current->GetTeleportDestination( TeleportPosition, TeleportRotator );
 
     // We're doing this!
     IsTeleporting = true;
 
     // Fade out screen
     APlayerCameraManager *PlayerCamera = UGameplayStatics::GetPlayerCameraManager( GetWorld(), 0 );
     PlayerCamera->StartCameraFade( 0, 1, FadeOutDuration, TeleportFadeColor, false, true );
     
     // Wait for Fade to complete before continuing the teleport
     FTimerHandle TimerHandle;
     FTimerDelegate TimerDelegate;
     TimerDelegate.BindUFunction( this, FName( TEXT( "FinishTeleport" ) ), Current, TeleportPosition, TeleportRotator );
     GetWorldTimerManager().SetTimer( TimerHandle, TimerDelegate, FadeOutDuration, false );
 }
 
 
 void ASlickBoyMotionControllerPawn::HandleButtonStyleTeleportActivation( UChildActorComponent *Hand, EInputEvent KeyEvent )
 {
     if ( ControlScheme == ETeleportControlScheme::StickOnly )
         return;
 
     ASlickBoyMotionController *Current = Cast<ASlickBoyMotionController>( Hand->GetChildActor() );
     ASlickBoyMotionController *Other = Cast<ASlickBoyMotionController>( ( Hand == LeftHand ? RightHand : LeftHand )->GetChildActor() );
 
     if ( KeyEvent == IE_Pressed )
     {
         if ( Current )
             Current->ActivateTeleporter();
         if ( Other )
             Other->DisableTeleporter();
     }
     else
     {
         if ( Current && Current->IsTeleporterActive )
             ExecuteTeleport( Current );
     }
 }
 
 void ASlickBoyMotionControllerPawn::HandleStickInputStyleTeleportActivation( FVector2D AxisInput, ASlickBoyMotionController *Current, ASlickBoyMotionController *Other )
 {
     if ( ControlScheme != ETeleportControlScheme::StickOnly )
         return;
 
     const float ThumbDeadzoneSq = ThumbDeadzone * ThumbDeadzone;
     if ( AxisInput.SizeSquared() > ThumbDeadzoneSq )
     {
         if ( Current )
             Current->ActivateTeleporter();
         if ( Other )
             Other->DisableTeleporter();
     }
     else 
     {
         if ( Current && Current->IsTeleporterActive )        
             ExecuteTeleport( Current );
     }
 }
 
 bool ASlickBoyMotionControllerPawn::GetRotationFromInput( ASlickBoyMotionController *Current, FVector2D AxisInput, FRotator &OrientRotator )
 {
     FRotator ActorRotator = GetActorRotation();
     ActorRotator.Roll = 0;
     ActorRotator.Pitch = 0;
 
     if ( ControlScheme == ETeleportControlScheme::ControllerRoll )
     {
         const FRotator RelativeRotation = Current->GetControllerRelativeRotation();
         float FinalYaw = RelativeRotation.Roll * 3 + ActorRotator.Yaw;
 
         OrientRotator = FRotator( 0, FinalYaw, 0 );
         return true;
     }
     else
     {
         const float ThumbDeadzoneSq = ThumbDeadzone * ThumbDeadzone;
         if ( AxisInput.SizeSquared() > ThumbDeadzoneSq )
         {
             FVector InputVector( AxisInput, 0 );
             InputVector.Normalize();
             InputVector = ActorRotator.RotateVector( InputVector );
 
             OrientRotator = InputVector.ToOrientationRotator();
             return true;
         }
     }
 
     OrientRotator = ActorRotator;
     return false;
 }
 
 // Called every frame
 void ASlickBoyMotionControllerPawn::Tick( float DeltaTime )
 {
     Super::Tick( DeltaTime );
     
     if (capsuleComponent && Camera) {
         capsuleComponent->SetWorldLocation(Camera->GetComponentLocation() + FVector(-23, 0, -89));
     }
 
     /*if (InputComponent)
     {
         ASlickBoyMotionController *Left = Cast<ASlickBoyMotionController>(LeftHand->GetChildActor());
         FVector2D ThumbLeft(
             InputComponent->GetAxisValue(TEXT("ThumbLeft_Fwd")),
             InputComponent->GetAxisValue(TEXT("ThumbLeft_Side"))
         );
 
         ASlickBoyMotionController *Right = Cast<ASlickBoyMotionController>(RightHand->GetChildActor());
         FVector2D ThumbRight(
             InputComponent->GetAxisValue(TEXT("ThumbRight_Fwd")),
             InputComponent->GetAxisValue(TEXT("ThumbRight_Side"))
         );
 
         // Robo Rally style Teleport Activation
         HandleStickInputStyleTeleportActivation(ThumbLeft, Left, Right);
         HandleStickInputStyleTeleportActivation(ThumbRight, Right, Left);
 
         // Get Teleport Target Rotation
         if (Left->IsTeleporterActive)
         {
             // If there is no Rotational Input, only use Actor rotation if not using Robo Rally style teleport
             FRotator OrientRotator;
             if (GetRotationFromInput(Left, ThumbLeft, OrientRotator) || ControlScheme != ETeleportControlScheme::StickOnly)
                 Left->TeleportRotator = OrientRotator;
         }
 
         if (Right->IsTeleporterActive)
         {
             // If there is no Rotational Input, only use Actor rotation if not using Robo Rally style teleport
             FRotator OrientRotator;
             if (GetRotationFromInput(Right, ThumbRight, OrientRotator) || ControlScheme != ETeleportControlScheme::StickOnly)
                 Right->TeleportRotator = OrientRotator;
         }
 
     }*/
 
     if (!surcharge) {
         if (surchargeMeter >= 90) {
             surcharge = true;
 
             USkeletalMeshComponent* leftHand = ((ASlickBoyMotionController*)LeftHand->GetChildActor())->GetHandMesh();
             ((ASlickBoyMotionController*)LeftHand->GetChildActor())->RumbleController_Implementation(1);
             if (leftHand)
                 leftHand->PlayAnimation(surchargeAnim, false);
 
             USkeletalMeshComponent* rightHand = ((ASlickBoyMotionController*)RightHand->GetChildActor())->GetHandMesh();
             ((ASlickBoyMotionController*)RightHand->GetChildActor())->RumbleController_Implementation(1);
             if (rightHand)
                 rightHand->PlayAnimation(surchargeAnim, false);
         }
     }
     else {
         if (surchargeMeter <= 50)
             surcharge = false;
     }
     if ((surchargeMeter - (DeltaTime * constantSurchargeDeflate)) <= 0)
         surchargeMeter = 0;
     else
         surchargeMeter -= (DeltaTime * constantSurchargeDeflate);
 
 
     if (invincible)
     {
         actualTimer -= (GetWorld()->GetDeltaSeconds());
         if (actualTimer <= 0)
         {
             invincible = false;
             actualTimer = timeForInvincibility;
         }
     }
 }
 
 void ASlickBoyMotionControllerPawn::HandleLeftGrip( UChildActorComponent *Hand, EInputEvent KeyEvent )
 {
     ASlickBoyMotionController *Current = Cast<ASlickBoyMotionController>( Hand->GetChildActor() );
     if ( Current )
     {
         if (KeyEvent == IE_Pressed) {
             Current->RumbleController_Implementation(0.1f);
             Fire(Current);
         }
     }
 }
 
 void ASlickBoyMotionControllerPawn::HandleRightGrip(UChildActorComponent *Hand, EInputEvent KeyEvent)
 {
     class ASlickBoyMotionController* Current = Cast<ASlickBoyMotionController>(Hand->GetChildActor());
     if (Current)
     {
         if (KeyEvent == IE_Pressed) {
             Current->RumbleController_Implementation(0.1f);
             Fire(Current);
         }
     }
 }
 
 void ASlickBoyMotionControllerPawn::HandleGrab(UChildActorComponent *Hand, EInputEvent KeyEvent)
 {
     ASlickBoyMotionController *Current = Cast<ASlickBoyMotionController>(Hand->GetChildActor());
     if (Current)
     {
         if (KeyEvent == IE_Pressed)
             Current->GrabActor();
         else // released
             Current->ReleaseActor();
     }
 }
 
 void ASlickBoyMotionControllerPawn::Fire(ASlickBoyMotionController *Current)
 {
     if (surcharge)
         return;
 
     if (Current)
     {
         FActorSpawnParameters SpawnInfo;
         SpawnInfo.Owner = this;
         SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
 
         FQuat HandQuat = Current->GetControllerRelativeRotation().Quaternion();
         FVector HandLocation = Current->GetControllerRelativeLocation();
 
         FQuat quatdown(FVector(0.0f, 1.0f, 0.0f), 0.60f);
 
         FQuat GunQuat = HandQuat * quatdown;
 
         USkeletalMeshComponent* currentMesh = Current->GetHandMesh();
         if (currentMesh) {
             currentMesh->PlayAnimation(shootAnim, false);
         }
 
         UGameplayStatics::PlaySoundAtLocation(GetWorld(), fireSoundCue, GetPawnViewLocation(), 5);
 
         FVector newPos = HandLocation + GunQuat * bulletDisplacement;
 
         UWorld* World = GetWorld();
 
         TirOnBeat();
 
         if (World)
         {
             APlayerProjectile* currentBullet = World->SpawnActor<APlayerProjectile>(myBullet, newPos, GunQuat.Rotator(), SpawnInfo);
 
             if (currentBullet)
             {
                 FVector LaunchDirection = GunQuat.GetForwardVector();
                 currentBullet->FireInDirection(LaunchDirection);
                 currentBullet->SetHitSoundCue(hitSoundCue);
                 UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), HitParticleComponent->Template, newPos, GunQuat.Rotator(), false);
             }
         }
     }
 }
 
 void ASlickBoyMotionControllerPawn::BindInputActionUFunction( class UInputComponent* PlayerInputComponent, FName ActionName, EInputEvent KeyEvent, FName FuncName, UChildActorComponent *Hand )
 {
     FInputActionBinding InputActionBinding( ActionName, KeyEvent );
 
     FInputActionHandlerSignature InputActionHandler;
     InputActionHandler.BindUFunction( this, FuncName, Hand, KeyEvent );
 
     InputActionBinding.ActionDelegate = InputActionHandler;
     PlayerInputComponent->AddActionBinding( InputActionBinding );
 }
 
 // Called to bind functionality to input
 void ASlickBoyMotionControllerPawn::SetupPlayerInputComponent( class UInputComponent* PlayerInputComponent )
 {
     Super::SetupPlayerInputComponent( PlayerInputComponent );
 
     //BindInputActionUFunction( PlayerInputComponent, TEXT( "TeleportLeft" ), IE_Pressed, TEXT( "HandleButtonStyleTeleportActivation" ), LeftHand );
     //BindInputActionUFunction( PlayerInputComponent, TEXT( "TeleportLeft" ), IE_Released, TEXT( "HandleButtonStyleTeleportActivation" ), LeftHand );
     //BindInputActionUFunction( PlayerInputComponent, TEXT( "TeleportRight" ), IE_Pressed, TEXT( "HandleButtonStyleTeleportActivation" ), RightHand );
     //BindInputActionUFunction( PlayerInputComponent, TEXT( "TeleportRight" ), IE_Released, TEXT( "HandleButtonStyleTeleportActivation" ), RightHand );
 
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GripLeft" ), IE_Pressed, TEXT( "HandleLeftGrip" ), LeftHand );
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GripLeft" ), IE_Released, TEXT( "HandleLeftGrip" ), LeftHand );
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GrabLeft" ), IE_Pressed, TEXT( "HandleGrab" ), LeftHand );
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GrabLeft" ), IE_Released, TEXT( "HandleGrab" ), LeftHand );
 
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GripRight" ), IE_Pressed, TEXT( "HandleRightGrip" ), RightHand );
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GripRight" ), IE_Released, TEXT( "HandleRightGrip" ), RightHand );
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GrabRight" ), IE_Pressed, TEXT( "HandleGrab" ), RightHand );
     BindInputActionUFunction( PlayerInputComponent, TEXT( "GrabRight" ), IE_Released, TEXT( "HandleGrab" ), RightHand );
 
     //PlayerInputComponent->BindAxis( TEXT( "ThumbLeft_Fwd" ) );
     //PlayerInputComponent->BindAxis( TEXT( "ThumbRight_Fwd" ) );
 
     //PlayerInputComponent->BindAxis( TEXT( "ThumbLeft_Side" ) );
     //PlayerInputComponent->BindAxis( TEXT( "ThumbRight_Side" ) );
 
     PlayerInputComponent->BindAction("PC_SWAP", IE_Released, this, &ASlickBoyMotionControllerPawn::SwapToPC);
     PlayerInputComponent->BindAction("PC_SPECTATOR", IE_Released, this, &ASlickBoyMotionControllerPawn::SwapToSpect);
 }
 
 void ASlickBoyMotionControllerPawn::SwapToPC() 
 {
     UDebugMessage::ShowMessage("Swapping To PC");
 
     /*
     ASlickBoy_TestGameMode* gameMode = ((ASlickBoy_TestGameMode*)GetWorld()->GetAuthGameMode());
     std::function<void()> function = [this]() { UDebugMessage::ShowMessage("Swapping To PC"); };
     gameMode->Manager()->delayManager->AddDelayedAction(function, 5);
     */
     //ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
 
     ASlickBoy_TestGameMode* myGameMode = (ASlickBoy_TestGameMode*)GetWorld()->GetAuthGameMode();
     if(myGameMode != NULL)
         myGameMode->SelectPCPawn();
 
     //myCharacter->SetActorLocation(myCharacter->GetActorLocation() + FVector(-100,0,0));
     //myCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
     //myCharacter->SetActorLocation(myCharacter->GetActorLocation() + FVector(100,0,0));
 }
 
 void ASlickBoyMotionControllerPawn::SwapToSpect() 
 {
     UDebugMessage::ShowMessage("Swapping To PC");
     ASlickBoyMotionControllerPawn* thePawn = this;
     //thePawn->SetActorLocation(FVector(0, -1000, 0));
     ASlickBoy_TestGameMode* myGameMode = (ASlickBoy_TestGameMode*)GetWorld()->GetAuthGameMode();
     if (myGameMode != NULL)
         myGameMode->SelectSpectatorPawn();
 
 
     if (thePawn)
     {
         thePawn->Destroy();
     }
 }
 
 void ASlickBoyMotionControllerPawn::SelectCharacter() 
 {
     Controller->SetViewTargetWithBlend(this, .5f);
     Controller->Possess(this);
 }
 
 void ASlickBoyMotionControllerPawn::Attack(float damage)
 {
     if (!invincible)
     {
         ASlickBoy_TestGameMode* myGameMode = GetWorld()->GetAuthGameMode<ASlickBoy_TestGameMode>();
         
         //Effet de damage
         DamagedEffect();
 
 
         // executer le code qui enleve de la vie au joueur
         myGameMode->AdjustPlayerHealth(damage);
 
 
         UDebugMessage::ShowMessage(FString::SanitizeFloat(myGameMode->GetPlayerInfo()->_health) + " DE VIE");
         invincible = true;
 
 
         // GESTION DE LA MORT
         if (myGameMode->GetPlayerInfo()->_health <= 0 /*&& !invincible*/)
         {
             //invincible = true;
             UDebugMessage::ShowMessage("HE DIED");
             for (int i = 0; i < deathListeners.Num(); i++)
             {
                 deathListeners[0]->onDeath(this);
             }
             myGameMode->gameLoop->OnFail();
         }
     }
 }
 
 void ASlickBoyMotionControllerPawn::DamagedEffect()
 {
     //DO EFFECT OF DAMAGE ON PLAYER HERE
     UDebugMessage::ShowMessage("Effet de DAMAGE");
 }
 
 void ASlickBoyMotionControllerPawn::TirOnBeat()
 {
     ASlickBoy_TestGameMode* myGameMode = GetWorld()->GetAuthGameMode<ASlickBoy_TestGameMode>();
     TArray<AActor*> FoundActors;
     UGameplayStatics::GetAllActorsOfClass(GetWorld(), ABeatManager::StaticClass(), FoundActors);
 
     if (FoundActors.Num() <= 0)
         return;
 
     ABeatManager* monBM = Cast<ABeatManager>(FoundActors[0]);
     if (monBM) {
         if (monBM->onBeat)
         {
             GLog->Log("Tir On Beat: Oui!!!!!!!!!!!!!!!!");
             
             //Raise the multiplier by 0.5/5
             myGameMode->AdjustMultiplier(0.5);
         }
         else
         {
             GLog->Log("Tir On Beat: Non");
             surchargeMeter += offBeatAugmentation;
 
             //Reset the multiplier to 0
             myGameMode->AdjustMultiplier(0);
         }
     }
 }
 
 UCameraComponent* ASlickBoyMotionControllerPawn::GetVrCamera()
 {
     return Camera;
 }
 
 UChildActorComponent * ASlickBoyMotionControllerPawn::GetRightHand()
 {
     return RightHand;
 }
 
 UChildActorComponent * ASlickBoyMotionControllerPawn::GetLeftHand()
 {
     return LeftHand;
 }
 
 void ASlickBoyMotionControllerPawn::Delete()
 {
     LeftHand->DestroyChildActor();
     RightHand->DestroyChildActor();
     Destroy();
 }

ASlickBoyMotionControllerPawn.cpp

 #pragma once
 
 #include "GameFramework/Pawn.h"
 #include "Slickboy/Attackable.h"
 #include "Slickboy/IDeathListener.h"
 #include "GameLoop.h"
 #include "SlickBoyMotionControllerPawn.generated.h"
 
 UENUM( BlueprintType )
 enum class ETeleportControlScheme : uint8
 {
     Auto,                // Select By Device
     ButtonAndStick,        // Press a button
     StickOnly,            // Robo Rally Style
     ControllerRoll        // For PSVR
 };
 
 UCLASS()
 class SLICKBOY_API ASlickBoyMotionControllerPawn : public APawn, public IAttackable
 {
     GENERATED_BODY()
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class USceneComponent *VROrigin;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class UCameraComponent *Camera;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class UChildActorComponent *LeftHand;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class UChildActorComponent *RightHand;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Code Components", meta = (AllowPrivateAccess = "true"))
     class UParticleSystemComponent* HitParticleComponent;
 
     void HandleStickInputStyleTeleportActivation( FVector2D AxisInput, class ASlickBoyMotionController *Current, class ASlickBoyMotionController *Other );
     bool GetRotationFromInput( class ASlickBoyMotionController *Current, FVector2D AxisInput, FRotator &OrientRotator );
 
     APlayerController* Controller;
 
 private:
     UPROPERTY(EditAnywhere, Category = "Cheat")
         bool invincible;
     UPROPERTY(EditAnywhere, Category = "Cheat")
         float actualTimer;
     UPROPERTY(EditAnywhere, Category = "Cheat")
         float timeForInvincibility;
 
 public:
     UFUNCTION()
     UCameraComponent* GetVrCamera();
 
     UFUNCTION()
         UChildActorComponent* GetRightHand();
 
     UFUNCTION()
         UChildActorComponent* GetLeftHand();
 
     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Code Components")
     UCapsuleComponent* capsuleComponent;
 
     //Sound
     UPROPERTY(EditAnywhere, Category = "Sound")
     USoundCue* fireSoundCue;
 
     UPROPERTY(EditAnywhere, Category = "Sound")
     USoundCue* hitSoundCue;
 
     // Gun Anim
     UAnimSequence *shootAnim;
     UAnimSequence *surchargeAnim;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     float FadeInDuration = 0.1;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     float FadeOutDuration = 0.1;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     FLinearColor TeleportFadeColor = FLinearColor::Black;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     float ThumbDeadzone = 0.7;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     float DefaultPlayerHeight = 180;
 
     UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Code Constants" )
     ETeleportControlScheme ControlScheme = ETeleportControlScheme::Auto;
 
     uint8 DeviceType;
     bool IsTeleporting;
 
     // Sets default values for this pawn's properties
     ASlickBoyMotionControllerPawn();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent( class UInputComponent* InputComponent ) override;
     
     UFUNCTION()
     void HandleButtonStyleTeleportActivation( class UChildActorComponent *Hand, EInputEvent KeyEvent );
 
     UFUNCTION()
     void HandleLeftGrip( class UChildActorComponent *Hand, EInputEvent KeyEvent );
 
     UFUNCTION()
     void HandleRightGrip(class UChildActorComponent *Hand, EInputEvent KeyEvent);
 
     UFUNCTION()
     void HandleGrab(UChildActorComponent *Hand, EInputEvent KeyEvent);
 
     void BindInputActionUFunction( class UInputComponent* PlayerInputComponent, FName ActionName, EInputEvent KeyEvent, FName FuncName, class UChildActorComponent *Hand );
 
     UFUNCTION()
     void FinishTeleport( class ASlickBoyMotionController *Current, const FVector &TeleportPosition, const FRotator &TeleportRotator );
 
     void ExecuteTeleport( class ASlickBoyMotionController *Current );
 
     // SWAP CONTROLS
 
     UFUNCTION()
     void SwapToPC();
 
     UFUNCTION()
     void SwapToSpect();
     
     void SelectCharacter();
 
     // SHOOTING
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite)
     FVector bulletDisplacement;
 
     UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = ProjectileVariable)
     TSubclassOf<class APlayerProjectile> myBullet;
 
     UFUNCTION()
     void Fire(class ASlickBoyMotionController* Hand);
 
     // Surcharge
     float surchargeMeter;
     float offBeatAugmentation;
     float constantSurchargeDeflate;
     bool surcharge;
 
     void TirOnBeat();
 
     //RECEIVE SHOT FROM ENEMIES
     virtual void Attack(float damage) override;
     TArray<IIDeathListener*> deathListeners;
 
     void DamagedEffect();
 
     void Delete();
 };



If anyone from Unreal is willing to help us I can send the project (I got a link).

Product Version: UE 4.16
Tags:
more ▼

asked Nov 27 '17 at 01:57 PM in C++ Programming

avatar image

Xeal534
1 1 1

avatar image Dune Nov 27 '17 at 04:34 PM

Are you running the game through the editor, and how are you performing the load? It almost looks like your Perforce that is connected to your project is causing issues while creating a new motion controller?

avatar image Xeal534 Nov 29 '17 at 02:58 PM

Yes the problem only appears when in the editor. If we build or package the game the problem is not there anymore. To swap from a level to another we are using UGameplayStatics::OpenLevel. We are also using Perforce. How can we fix the problem with perforce so the motion controller are created without a problem.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question