using UnityEngine;using System.Collections;public class ShowChangjingView: MonoBehaviour { public GameObject first; private float YSpeed; private float XSpeed; void Update () { } void OnEnable() { EasyJoystick.On_JoystickMove = OnJoystickMove; // EasyJoystick.On_JoystickMoveEnd = OnJoystickMoveEnd; } void OnJoystickMove(MovingJoystick move) { print ("OnJoystickMove"); //获取摇杆中心偏移的坐标 float joyPositionX = move.joystickAxis.x; float joyPositionY = move.joystickAxis.y; if(joyPositionY > 0) { YSpeed = 1f; } else { YSpeed = -1f; } if(joyPositionX > 0) { XSpeed = 1f; } else { XSpeed = -1f; } transform.Translate(Vector3.forward* Time.deltaTime * YSpeed); transform.Translate(Vector3.right* Time.deltaTime * XSpeed); } }
推荐整理分享Unity 3D实现用摇杆穿墙效果(unity 3d代码),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:unity 3d代码,用unity3d做游戏,unity怎么添加虚拟摇杆,unity3d 摇杆,unity摇摆效果,unity3d怎么用,unity中怎么让模型摇晃,unity摇摆效果,内容如对您有帮助,希望把文章链接给更多的朋友!
unity之协程,Yield语句,倒计时 我们今天学习了,unity的动画效果,例如小球打墙,倒计时,协程,要用协程的话,必须要用Yield语句是一种特殊的Return(返回)语句,它可以确保函数在
Clean Empty Directories on Unity3D and Git 大家好,我是孙广东。转载请注明出处:
【转】Unity 3D Best Practices 原文链接