Question by
Dominator3019 · Aug 12, 2016 at 04:26 PM ·
c#2drotation
He wants to write a script on a page change gait from right to left or vice versa
that is, when I click "A" to go to the left and I turn to the left and when I press the "D" I go to the right and turn around to the right but I can not. My script is going on:
using UnityEngine; using System.Collections;
public class gracza_kontrola : MonoBehaviour {
public float moveSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetAxisRaw("Horizontal") > 0.5f || Input.GetAxisRaw("Horizontal") < -0.5F )
{
transform.Translate (new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0f, 0f));
}
if(Input.GetAxisRaw("Vertical") > 0.5f || Input.GetAxisRaw("Vertical") < -0.5F )
{
transform.Translate (new Vector3(0f, Input.GetAxisRaw("Vertical") * moveSpeed * Time.deltaTime, 0f));
}
}
}
Comment