Hi,
I’m attempting to map some movement controls to the tilt of a single motion controller(vive). I want to be able to detect tilting one controller fwd-back, left-right, then use those inputs for movement of an actor. Is this even possible in Blueprints?
Yes, it’s 100% possible in blueprints. This question is less of a technical capability question and more of a design and implementation question.
If you look at your motion controller component, you can get its position and orientation at that instant in time. You’ll be interested in looking at the yaw, pitch, and roll values.
It sounds like you’re looking for a change in yaw/pitch over time. That’s the key there, that it’s over time. That should suggest to you that you’re going to be keeping a history of values and watching them as they change over time, and then interpreting the change in values as a form of input. Good so far?
So, the next few questions you’ll be asking is, “How do I do that?” and “where do I store these values?” and “how do I get rid of old values?” and “how do I interpret my values correctly?”
To store the values, you’ll want to put them into some sort of data structure, such as an array. You’ll need to decide how many values you need to store in order to get good data. 10 frames? 100 frames? 1000? I can’t tell you this value, you have to find and test for it yourself. But, let’s pretend that we’re using 10 frames of data so that we can look at how we can discard old data.
Normally, you would use a data structure called a “queue” with a length of 10. When you insert items into this queue, you add them to the “front” (in this case). If your queue already has 10 items in it, then you remove the last item and then insert another. The good news is that you can implement a queue within an array by using a “circular queue” (https://en.wikipedia.org/wiki/Circular_buffer) and just overwrite the next index value instead of dequeuing it.
So, I answered three out of four additional questions you’ll run into, and the last question is a question I can’t really answer because the answer is going to be “it depends on your implementation / requirements”.
Thank you so much for this info! Voted! You are spot on - I do want to track these inputs over time. I use arrays often but not “queue”, so I will begin my researching on the topic immediately. As for the last inquiry - I plan to implement by using these stored inputs to signal “add movement input” or “add force/impulse” to or I think there is probably a better way to translate my actor left-right,fwd-back (i just need to do some more research). The tricky part is that these movements are added to an actor already in a set state of motion - actually all actors are moving forward on an infinite track that builds and destroys itself. This is going to hopefully be a highway outrun vr game! Anyway, Thanks so much for the help!- it will get me started! Any other info appreciated but thank you for all you’ve already provided!
No, there isn’t a “circular array” data structure. You have to implement it yourself, which is really straight forward and simple… you keep a second integer variable which is the current array index. Call it something like… “NextIndex”. You should be able to look at the wikipedia link and figure out a way to implement it using only blueprints. 100% possible, 75% easy.