if(Input.GetKey(KeyCode.W)))
{
this .transform .Translate (Vector3.forward *Time .deltaTime*speed );
}
else if(Input.GetKey(KeyCode.S))
{
this .transform .Translate (Vector3.forward *Time .deltaTime*-speed );
}
if(Input.GetKey(KeyCode.A )) )
{
this .transform .Rotate (Vector3.up *Time .deltaTime*-rotatespeed);
}
else if(Input.GetKey(KeyCode.D))
{
this .transform .Rotate (Vector3.up *Time .deltaTime*rotatespeed);
}
这个是一个很基本的移动代码,可以尝试吧代码复制到update()里面,再定义一下speed(移动速度)和rotatespeed(旋转速度)就可以了。
功能为: W按住向前移动,S按住向后移动,A按住向左旋转,D按住向右旋转。
其实角色控制方法应该很多,我这个仅仅是键盘操作。
新手,如果见解不当,请指正,非常感谢。
Photoshop|
Dreamweaver|
SVG|
WebGL|
Visual Studio|
PowerDesigner|
Eclipse|
Git|
Apache Ant|
Atom|
Composer|
CodeSmith|
Flex|
Gradle|
Maven|
Sublime Text3|
SVN|
Tableau|
Vim|
Chrome开发者工具|
OpenGL|
Unity|
Direct3D|
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....