0
votes

I am using a fairly complicated and comprehensive Third Person Controller package from the asset store. https://www.assetstore.unity3d.com/en/#!/content/27438

I need to change this line in the controller (or possibly add new code) to make the character move in the direction that the character is facing when the move forward key is pressed.

Here is the default line, but the character moves in relation to the camera rather than independently:

m_LookRotation = m_CameraTransform.rotation;

And next is the line that was recommended to replace that line to achieve the goal:

m_LookRotation = Quaternion.Euler(PlayerInput.GetAxisRaw(Constants.YawInputName), 0, 0);

However, with that line replacing the original, the move forward key causes the character to move in one particular direction, regardless of which way he is facing. Example: If I turn to the right, and then press the walk forward key, the character turns back to the original direction before walking forward.

[Here is the full controller script: https://docs.google.com/document/d/1B4sstqtCqRMCLuHuxEuA9I7tO_3W4aHqEZwr73uFDjY/edit?pref=2&pli=1 ]

1

1 Answers

0
votes

You could just multiply the rotation of the character and forward vector, i.e.:

Vector3 targetForward = characterRotation * Vector3.forward;