I’m trying to create a control where by pressing the Left Key, I would move slower than I would be pressing the Right key. I’m using Input.GetAxes and working with “Horizontal” but the speed value I put in to it works for both the Left and Right Arrow Buttons.
How do I give different values to each key while using the Input.GetAxes(“Horizontal”),0,0 ?
Here’s a piece of my code, I’m using C#
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float leftspeed = 6.0F;
public float rightspeed = 9.0F;
public float riseSpeed = 5.0F;
public float dropSpeed = 14.0F;
private Vector3 moveDirection = Vector3.zero;
void Update() {
CharacterController controller = GetComponent<CharacterController>();
moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection.x *= leftspeed;
moveDirection.y *= dropSpeed;
controller.Move(moveDirection * Time.deltaTime);
}
}
Any help would be appreciated thanks.