Hey, for my project I need to get the position and the rotation of the left hand/controller. It is used for a line trace.
How do I get this?
I already tried to get the world location and rotation of the Left Controller of the MotionControllerPawn bp, which does not seem to work.
Then I thought about mirroring the hand mesh like it is done in the BP_MotionController, but there, I can’t store the mirrored location and rotation as variable.
Hi, it works fine for me. Do you mind sharing more information about what does not work? (so does it return no location, does the returned location not change when the controller moves, is the returned location/rotation wrong, …)
With camera as ‘origin’, it returns a location and it moves along with the player. If I use (the root component of) Left Controller of the MotionControllerPawn, the location does not change when the controller moves. Instead, I can see a static debug from the location where the controllers are spawned when starting the game.
Besides, I also get a bp runtime error: Accessed None trying to read property CallFunc_BreakHitResult_HitActor1 from function: ‘ExecuteUbergraph_BP_MotionController’ from node: DestroyActor in graph: EventGraph in object: BP_MotionController with description: Accesed None trying to read property CallFunc_BreakHitResult_HitActor1.
However, it works. What is going on there?
I added the blueprint. Input and condition don’t seem to be the problem.
Edit: Well, seems like I solved the problem with the error.
Apparently DestroyActor only works if I have a proper target (an actor). If it’s not a proper target, then the target is empty, so DestroyActor can’t be executed. I just used Return Value of the LineTrace for a branch before the DestroyActor function, so this function is only called when there is a valid hit.
You are getting an error because your hit result didn’t hit anything but you are anyway passing this hit actor to the output. You should first add a branch on line trace return value and only if you hit something then use the hit actor as an output.
Also I am not sure if your line trace works at all. I don’t remember how is the default VR pawn set up but in my projects the motion controllers are components on the pawn not actors. So get a reference to the motion controller component or even directly to the camera you want to trace from. Best is to save the reference as a variable and use that instead of Get All Actors Of Class which is a not good practice in general.
Thanks!
I already figured that error out, everything works now, happy about that.
Regarding the default VR Pawn set up: Left Controller and Right Controller are actors of the MotionControllerPawn. Or at least they are not listed in the components list, but are actor reference variables of the BP Motion Controller type.
I tried to substitute the Get Actors Of Class by a cast. However, it still seems like Left Controller is stuck on the first spawned location and doesn’t update. Is there something like a tick I forgot?
You two are gods! It works!
This is such a simple solution, yet I would have never thought about using them as components. Thank you for helping a beginner!