标签:idle 玩家 translate nsf highlight tor one void sla
using UnityEngine; using System.Collections; public class JoystickController : MonoBehaviour { private Joystick mJoystick; private float mSpeed=7.5F; void Start () { //获取Joystick mJoystick=GameObject.Find("UnityJoystick").GetComponent<Joystick>(); } void Update () { //获取摇杆响应值 float mX=mJoystick.position.x; float mY=mJoystick.position.y; //移动角色 if(mX!=0||mY!=0) { Vector3 mPos=new Vector3(transform.position.x+mX,transform.position.y, transform.position.z+mY); transform.LookAt(mPos); //移动玩家的位置(按朝向位置移动) transform.Translate(Vector3.forward * Time.deltaTime * 5F); //播放奔跑动画 animation.Play("Run"); }else { animation.Play("idle"); } } }
标签:idle 玩家 translate nsf highlight tor one void sla
原文地址:https://www.cnblogs.com/slqt/p/10346191.html