I am trying to interact with objects in my VR game, and most tutorials I see are for free moving objects, but I am not looking for that. I specifically want to interact with objects that have constraints. For example: levers, hinges, sliders, etc. And also some objects that can be moved only in Z and Y (pitch and yaw), with a constrained pivot, sort of like a mounted gun.
Here is my WIP, so far I want to focus on the gun functionality, and then move onto the levers and stuff.
VRExpansion plugin handles pretty much all of that, if you don’t want to use it in your project you could probably download the demo and see how it is handled there.
Here is where I am at now. WIP_RS_GUN on Vimeo
I tried something called Mitch’s VR Templates. It has a lot of the functionality of what I need, however they all pertain to a single axis. When I try to combine an actor with both a pitch and yaw function it only does the yaw. The yaw was basically code for a door, I just extended the max and min angle to be -45 , 45.
The pitch is in parented below the yaw so they move independently. I included the blueprints:
You’ll notice that there are multiple functions that work with my VR pawn character. There is a ‘drag start’ ‘drag’ ‘drag stop’. The top portions are for the yaw, where I didn’t mess with the original blueprint, just replaced it with my meshes. Below that is a duplicate of the yaw nodes, but I just switched the meshes and the axis to be pitch. But still only the Yaw works.
Ok I’ll take a look. Sorry about the weird naming, the comments say ‘door’ because that was in the template. The original purpose of the simulate was to let go and have the gun still move slightly and slow down to a full stop. It was a cool effect but not totally necessary. Thanks!
It did not work unfortunately. I suspect it’s an issue with child component inheritance overriding my rotations. I can send you my project. I made a clean simple version to get started with. I’m uploading it to my google drive right now. I’ll give you a link when it’s ready.
alright i’ll be home in about an hour or two and i’ll check it out for you. Should be able to get it straightened out tonight, or at least narrow down the problem for you.
Well i downloaded it to take a look, but the project you sent was very broken, based on errors it looks like multiple missing classes.
Example: Can’t find file for asset. /Game/ExampleContent/VR_World_Interaction/Blueprints/InteractiveObjects/BP_MG_O
plus many more, most are just meshes so not a big deal, but the BP classes that are missing make it to where any code through blueprints you had in the project are completely broken so i don’t even have a basis to start looking for you.
It contains a lot of the VR templates from the original file, like doors, levers etc… you can look at those too and see how those are setup too.
BP_MG_Test should be the main gun blueprint with all the parts. There is also a backup folder with all of my iterations.
got it pretty much working for you, you had a lot of redundant code that was overwriting itself, and somethings just pointing to the wrong area. It’s a bit cleaner now, want me to zip up and upload the project or just show you the blueprints?
Here’s the updated file. Combined the yaw and pitch into single handlers, got rid of the gun handle event entirely, changed the initial offset to also include an initial pitch offset, updated the atan2’s to correctly use x and z for the pitch, and cleaned up the start and stop drag functions as well. If you have any questions about it let me know. Gun Test Download
Yeah that works! Thank you for fixing that. Is there a way to get the pitch to be more sensitive? It’s easy to move the yaw, but if I move my hands up and down too fast it lets go of the gun and gets stuck and I have to grab it again.