I am making a character rotate around its axis using euler angles. Not quite as transform.Rotate that makes the character fall through the terrain. But I want it to put a custom speed. I mean a float or something that can be edited in the script for the character to rotate at a speed I want to set in the script.
if (((Input.GetAxis("Horizontal") > deadZone) && !Input.GetKey(KeyCode.LeftShift)) ||
(Input.GetAxis("Horizontal") < -deadZone) && !Input.GetKey(KeyCode.LeftShift))
transform.eulerAngles += new Vector3 (0, Input.GetAxis("Horizontal"), 0);
It means that if i press the left or right inputs, the character rotates around its y axis. Now i have to set its speed. How could I set a relative speed to it???
Like this:
if (((Input.GetAxis("Vertical") > deadZone) && !Input.GetKey(KeyCode.LeftShift)) ||
(Input.GetAxis("Vertical") < -deadZone && !Input.GetKey(KeyCode.LeftShift)))
TP_Motor.Instance.MoveVector += new Vector3(0, 0, Input.GetAxis("Vertical"));
This is the other code from the other script:
public Vector3 MoveVector { get; set; }
public float VerticalVelocity { get; set; }
void Awake ()
{
Instance = this;
}
public void UpdateMotor () // Le cambie era UpdateMotor
{
ProcessMotion();
}
void ProcessMotion()
{
// First Movevector
// Transform MoveVector to worldspace
MoveVector = transform.TransformDirection(MoveVector);
// Normalize MoveVector if Magnitude > 1
if (MoveVector.magnitude > 1)
MoveVector = Vector3.Normalize(MoveVector);
// Multiply MoveVector by MoveSpeed
MoveVector *= MoveSpeed();
// Reapply VerticalVelocity MoveVector.y
MoveVector = new Vector3(MoveVector.x, VerticalVelocity, MoveVector.z);
// Apply Gravity
ApplyGravity();
// Move the character into world space
TP_Controller.CharacterController.Move(MoveVector * Time.deltaTime);
}