Question by
dekilled · Sep 05, 2017 at 01:37 PM ·
controllerjoysticktps
Problem with player control with physical joystick
Hi Everyone, I'm trying to make game in unity with joystick support, so far it's doing good with all buttons, but, I'm having a bit of a problem with the axis stick, I'm trying to make a Third Person Controller and I want to ask for a little help to figure out how can I do this. So far i can make the player follow the input axis direction, I push forward and it goes forward, I push backward the player rotates and goes backward, for the sides left and right works nice too, but, for example, I turn right I want my player to keep this direction when I push the joystick forward axis, but, resets the rotation.
Here is what I've tried:
Vector3 inputAxis= new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical"));
if (inputAxis!= Vector3.zero)
{
targetRotation = Quaternion.LookRotation(inputAxis);
}
transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, 100f * Time.deltaTime);
I little help, please?
Comment