I’m working on a VR weapon system, and attempting to get the distance between my motion controller and the socket it grips on my shotgun in order to move the pump on the shotgun.
So I’m getting the world location of the controller, and then subtracting the world location of the socket. I’m then taking the Y value and using a clamped version of it to LERP the location of the static mesh. This is giving the intended affect, but only if I’m facing a specific direction.
If the player’s weapon is rotated in one direction, the movement is inverted. I’m sure it’s a simple fix, but I’m not sure what I’m doing wrong.
Any help would be appreciated.
I’ve attached my blueprint below.
have you tried the vector length node? if your looking to get the distance that may help
how about locking all but the plane of movement then clamping the distance that the component can move. then you would just need to logic to say when the controller is within a specified range then you want the shotgunslide to move with the controller.
I tried the vector length node, and it works in the sense that, when you pull the controller towards you, it properly translates the pump, but if you move the controller forward of the socket location, it also moves the pump backwards as the vector length has increased.
Turns out I needed to use Inverse Transform to localize the locations of the player controller and the grip socket to the weapon mesh.
Here’s the blueprint if anyone comes here looking for the answer.