ELI5 Hi All I’m totally new at this so my apologies I tried searching but to no avail. I want to create in blueprint a thumbstick walk to sprint mechanic. The middle (Deadzone) would have no movement, then if you move thumbstick up half the distance the character would walk, and thumbstick all the way would make the character sprint. Ive seen this done in games like Zero Caliber and thats what im trying to emulate.
I know this probably looks completely stupid to you guys but this is were i’m at. I have seamless locomotion down fine. I tried adding this to the logic but when i do he’s stuck in a constant run forward.
You are connecting the walk speed to the movement function, it should be axis value.
IMO You are not really wrong in your approach, just need to elaborate a bit on the math. I would use both X and Y (X = Axis value forward, Y = right) to create a 2D vector and get its magnitude / length. That is what should dictate the condition to walk or sprint.
You can then expand it using dot product to only sprint when moving forward, etc:
Pezzott1 Thanks for the reply. I know you practically spelled it out for me but could you show me what it would look like in blueprint? When I tried connecting to the X and Y value I no longer walked in the direction i was looking. I reverted back to what worked for me.
Hey! So… shaked off some work stress and took time to read your question properly, thought that I probably was over complicating things.
Perhaps this is what you area after:
pezzott1, thanks for the reply. The animation portion is not what I’m looking for. I’m not there yet. that will be my next step. As I press the thumbstick forward I want the character speed to go from a walk to a sprint. I bought a vr basics book the other day for unreal but all it focuses on is teleport movement. I think I need to see the blueprint of how someone does it (hopefully with a short explanation) because of how new I am to unreal/blueprints/coding.
thanks again for the help!
I can think of 2 quick ways you could achieve this:
- Set MaxWalkSpeed to your sprint speed and walk speed around half way, making it a bit of a range rather than a fixed amount.
- Use a vector 2D to get (roughly) half way using vector length to know when the player inputs 0.5 < on the controller:
-
The length of the 2d vector helps us see when we are half way to change MaxWalkSpeed:
Hope this helps.
Solved! So this is my mistake and being new to Unreal. The ability to do this already exists in Unreal 4.27. My mistake is I was binding Move Forward to Oculus Left Thumbstick Up in Project Settings–>Input. What you want to actually do is bind the input to Oculus Left Thumbstick Y Axis. the axis will give you a range of motion and a slow walk to a run speed. My original biding treated it like a button which gave no range of motion so it was just full run all the time. Thanks to all that tried to assist.