Weird with Actor Hand controller

Ok, This may be something but I remember having issues with ECC_Visibility and changed to use ECC_MAX to resolve the issue. This could be the problem

Sorry, just spotted another issue.
The Nav System code isn’t quite right. Try this:

  FNavLocation outNavLocation;
  UNavigationSystemV1* pNavSystem = UNavigationSystemV1::GetNavigationSystem( GetWorld() );
  result = pNavSystem->ProjectPointToNavigation( pathResult.HitResult.Location, outNavLocation, TeleportExtents );

no sir, it’s not working

I’ll share my code. The code for me is working perfectly. The method name doesn’t match but it’s basically the same code. Screenshot below as well.

If this isn’t working, close your editor and delete the binaries and Intermediate folder then launch the uproject again.

At this point it should be working. I should note my project is 4.26 but there should be little difference between the 2 projects.

bool AVRCharacter::GetTeleportLocation( FVector& OutLocation )
{
  OutLocation = FVector::ZeroVector;

  //  calculate the direction in which the controller is pointing, applying a slight rotation to point the controller
  //  in the right direction. Use this instead of forward
  FVector Look = RightMotionController->GetForwardVector();

  //  the start and end vectors for the line trace
  FVector startVector = RightMotionController->GetComponentLocation();

  //  we have a hit, so we can teleport.
  FPredictProjectilePathParams inParams( TeleportRadius, startVector, Look * TeleportSpeed, TeleportSimTime, ECollisionChannel::ECC_MAX, this  );
  inParams.DrawDebugType = EDrawDebugTrace::ForOneFrame;
  FPredictProjectilePathResult PathResult;

  bool bDidHit = UGameplayStatics::PredictProjectilePath( this, inParams, PathResult );

  if ( !bDidHit )
  {
    return false;
  }
  //UE_LOG( LogTemp, Warning, TEXT("HIT: %s"), *( hitResult.Location.ToString() ) );

  FNavLocation OutNavLocation;
  UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetNavigationSystem( GetWorld() );
  bool IsNavPossible = NavSystem->ProjectPointToNavigation( PathResult.HitResult.Location, OutNavLocation, TeleportExtents );
  if ( IsNavPossible )
  {
    OutLocation = OutNavLocation.Location;
  }
  return IsNavPossible;
}

why you didn’t change into actor instead component
GetComponentLocation() into GetActorLocation()

In the tests I have, I’ve not extracted the controller yet, which I realise is different from what you have. However, checking the code in the specific lecture I see the only change is in fact the position of the controller. So, talking my code, all you’d have to do is change the startVector and it should work.

Ashok,
Just so you know, I’ve checked my code after the HandController refactor. The 2 lines were updated to be the following (I also renamed the startVector to StartLocation)

  FVector Look = RightMotionController->GetActorForwardVector();
  FVector StartLocation = RightMotionController->GetActorLocation();

This worked exactly as it did before the refactor. One thing I did have to do is in the HandController class, I couldn’t use MotionController as the created Motion controller. I had to change the name to TheMotionController. Once I did this, the issues (crashes) went away.

Let me know if you’re having issues.

thank you so much worked

1 Like

help…

did you add UFUNCTION() above the declaration in the header?

yes i did

UFUNCTION()
void OnBeginOverlap(UPrimitiveComponent* OnComponentBeginOverlap, UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult);

Error

Your signature looks wrong. The begin and endoverlap only take 2 parameters.

	UFUNCTION()
	void ActorBeginOverlap( AActor* OverlappedActor, AActor* OtherActor );
	UFUNCTION()
	void ActorEndOverlap( AActor* OverlappedActor, AActor* OtherActor );

TheRightController->OnComponentBeginOverlap.AddDynamic(this, &AVRCharacter::OnBeginOverlap);

Actually i did for component not for actor.

TheRightController = CreateDefaultSubobject(TEXT(“TheRightController”));
TheRightController->SetupAttachment(VRRoot);
TheRightController->SetTrackingSource(EControllerHand::Right);

I see. You’re defining in the VRCharacter. This should be done in the HandController and OnBeginOverlap is used.

Something to note, if you use the bDisplayDeviceModel to show the controller model, you need to add a box or sphere collision into your blueprint otherwise overlaps won’t trigger.

1 Like

help me please!!

Again, inside the HandController, MotionControlerComponent->GetTrackingSource() gives you the hand you set previously.

Privacy & Terms