- Home /
Combining 2 Vectors for Diagonal Movement
I am trying to make a simple player movement script with rigid bodies, but I have hit quite a snag. I want the player to move in its own local z direction when I use the forward input, but also I want it to be able to strafe while moving. I am not sure how to produce this effect because every time I have tried, it only does one or the other.
Any help would be great. Thanks!
You can always add vectors together. Sometimes you want to limit the result (Vector3.Clamp$$anonymous$$agnitude()), so that diagonals don't move faster than just horizontal or vertical. I'd have to see your code before I could give anything more specific.
Answer by winner1324 · Apr 04, 2014 at 03:52 PM
I figured it out. I was using if statements to trigger motion. You cannot use if statements for motion to be able to add the vectors together.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141912im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Player walks in the direction the vr camera is looking? 2 Answers
How can i smooth out the rotation? 1 Answer
Move Multiple Directions At Once (ex. forward and right) unity 3d 1 Answer
Having trouble with a basic movement script. 2 Answers
help animator not acces other gameobject,Animator acces other gameobject? 0 Answers