даДобавлено (14 Мая 2018, 14:33)
---------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player_script : MonoBehaviour {
public float x;
public float y;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
x = Input.GetAxis("Vertical");
y = Input.GetAxis("Horizontal");
if (Input.GetKey (KeyCode.W))
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.Euler (0, transform.rotation.y, 0), 0.2f);
if (Input.GetKey (KeyCode.S))
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.Euler (0, transform.rotation.y + 180, 0), 0.2f);
if (Input.GetKey (KeyCode.A))
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.Euler (0, transform.rotation.y - 90, 0), 0.2f);
if (Input.GetKey (KeyCode.D))
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.Euler (0, transform.rotation.y + 90, 0), 0.2f);
}
void FixedUpdate(){
gameObject.GetComponent<Animator> ().SetFloat ("Speed", x, 0.1f,Time.deltaTime);
gameObject.GetComponent<Animator> ().SetFloat ("Direction", y, 0.1f,Time.deltaTime);
}
}