- Home /
How to get player strafing movement with look at Enemy and relative to camera direction???
How to get player strafing movement with look at Enemy and relative to camera direction??? but not in circular movement. simply like prince of POP WW game player movement. Im able to create freestyle movement and freestyle strafing but unable to do non circular movement with look at rotation Please somebody help me!!
Answer by Vinz3d · Apr 10, 2020 at 08:35 PM
I'm having the same issue and going crazy over maths.. if since then you've found the solution? That'd be a great help! :)
Cheers!
Answer by ShamusO · Apr 10, 2020 at 08:37 PM
Can you please upload a short clip of what's happening? Also can you post some examples of your code?
Sure, find here a link to a gif: https://drive.google.com/file/d/1Cv$$anonymous$$LP6XtxvtaRHOzo9kbdPGzxrBsF2zH/view
As you'll see, I've got normal movement and aim/strafe movement. The issue I'm having is translating horizontal/vertical floats to the strafe animations. If the camera was locked behind as a 3rd person view, it'd be fine (as you can see when the player is going forward) but the game is a VR platformer which means I need to find a way to bring the angle offset from camera-player to the h and v strafe values with h and v inputs. I'm not super confortable with C# yet and haven't found any luck so far.
private void Ai$$anonymous$$g$$anonymous$$ove(Vector3 movement) { // TODO Find a way to clamp the vectors for keyboard diagonals without normalizing Vector3 desiredDirection = (cameraRoot.transform.forward) * movement.y + (cameraRoot.transform.right) * movement.x; transform.Translate(desiredDirection * 4f * speed * Time.deltaTime, Space.World); // oldRot = transform.rotation; } private void Ai$$anonymous$$g$$anonymous$$oveAnim(Vector3 movement) { if (Is$$anonymous$$oving(movement)) { anim.SetBool("useStrafe", true); anim.SetFloat("strafe_h", movement.x); // should have something including movement.y as well anim.SetFloat("strafe_v", movement.y); // should have something including movement.x as well } else anim.SetBool("useStrafe", false); }
Also movement are my axis inputs
movement = playerInput.movementInput;