- Home /
3rd person controller , movement issues
Hi ALL,
I am trying to resolve a really vague issue which is taking lot of my time to resolve. I have a third person up and running in the game with both its Controller and camera atached to the component.
Issues are - 1) Can the rotation on pressing "a" and "d" be reduced to 10- 15 degrees rather than 90. 2) On pressing "s" key can the behavior be changed from rotating 180 to move backwards.
The script i am using is the basic script provided by unity , namely " Third person controller Script".
I assume following is the code taking care of rotation in the script -
if (targetDirection != Vector3.zero)
{
// If we are really slow, just snap to the target direction
if (moveSpeed < walkSpeed * 0.9 && grounded)
{
moveDirection = targetDirection.normalized;
}
// Otherwise smoothly turn towards it
else
{
moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, rotateSpeed * Mathf.Deg2Rad * Time.deltaTime, 1000);
moveDirection = moveDirection.normalized;
}
}
What should be modified for above mentioned changes. Thank you !!!
Answer by Canicus · Dec 08, 2014 at 10:32 AM
You have the input keys set for the game. If you in your code detect the keypress, you can choose to do what you want with it. Not sure if you have to actually disable it from the default Input.
if (Input.GetKey(KeyCode.A))
{
// turn, based on boolean
}
if (Input.GetKey(KeyCode.D))
{
// turn, based on boolean
}
if (Input.GetKey(KeyCode.S))
{
// Set som boolean value to check for 90/15 degress
}
Sorry, I started Unity yesterday but I assume this should do the trick.