Gottfried kann sich bewegen und drehen
This commit is contained in:
@ -15,6 +15,10 @@ public class Character : MonoBehaviour
|
||||
|
||||
public float speed = 2f;
|
||||
|
||||
[Header("Turning")]
|
||||
public float turningRate = 30f;
|
||||
public Quaternion _targetRotation = Quaternion.identity;
|
||||
|
||||
[Header("Keybindings")]
|
||||
public KeyCode jumpKey = KeyCode.Space;
|
||||
|
||||
@ -41,6 +45,8 @@ public class Character : MonoBehaviour
|
||||
MyInput();
|
||||
SpeedControl();
|
||||
|
||||
transform.rotation = Quaternion.RotateTowards(transform.rotation, _targetRotation, turningRate * Time.deltaTime);
|
||||
|
||||
if (grounded)
|
||||
{
|
||||
rb.drag = groundDrag;
|
||||
@ -62,7 +68,11 @@ public class Character : MonoBehaviour
|
||||
horizontalInput = Input.GetAxisRaw("Horizontal");
|
||||
verticalInput = Input.GetAxisRaw("Vertical");
|
||||
|
||||
|
||||
if(horizontalInput != 0f || verticalInput != 0f)
|
||||
{
|
||||
_targetRotation = Quaternion.Euler(new Vector3(0f, Mathf.Atan2(horizontalInput, verticalInput) * Mathf.Rad2Deg, 0f));
|
||||
}
|
||||
|
||||
if (Input.GetKey(jumpKey) && readyToJump && grounded)
|
||||
{
|
||||
readyToJump = false;
|
||||
|
||||
Reference in New Issue
Block a user