Easy Touch Tutorials
Transferred from: http://www.unitymanual.com/thread-31332-1-1.html
1.import "Easy Touch 3" Resource pack
2. Create a character model
3. Create a terrain
4. Add an instance of Joystick: Hedgehog team->easy touch->extensions->add a new Joystick. Then we can see it coming out in the lower left corner.
5. Set the relevant parameters of the joystick, see
6. Create a new script MoveController.cs to receive the joystick events and control the movement of the characters. The code is as follows:
[AppleScript]
Plain Text View
Copy Code?
0102030405060708091011121314151617181920212223242526272829303132333435363738394041424344454647 |
using UnityEngine;
using System.Collections;
public
class MoveController
: MonoBehaviour
{
void OnEnable
(
)
{
EasyJoystick.On_JoystickMove
+
= OnJoystickMove;
EasyJoystick.On_JoystickMoveEnd
+
= OnJoystickMoveEnd;
}
/
/
移动摇杆结束
void OnJoystickMoveEnd
(
MovingJoystick
move
)
{
/
/
停止时,角色恢复
idle
if (
move
.joystickName
=
= "MoveJoystick"
)
{
animation.CrossFade
(
"idle"
)
;
}
}
/
/
移动摇杆中
void OnJoystickMove
(
MovingJoystick
move
)
{
if (
move
.joystickName !
= "MoveJoystick"
)
{
return
;
}
/
/
获取摇杆中心偏移的坐标
float joyPositionX
= move
.joystickAxis.x;
float joyPositionY
= move
.joystickAxis.y;
if (
joyPositionY !
= 0 || joyPositionX !
= 0
)
{
/
/
设置角色的朝向(朝向当前坐标
+
摇杆偏移量)
transform.LookAt
(
new Vector
3
(
transform.
position
.x
+ joyPositionX
, transform.
position
.y
, transform.
position
.z
+ joyPositionY
)
)
;
/
/
移动玩家的位置(按朝向位置移动)
transform.Translate
(
Vector
3.
forward
* Time.deltaTime
* 5
)
;
/
/
播放奔跑动画
animation.CrossFade
(
"run"
)
;
}
}
}
|
Finish the work, the specific
Finally, let's take a look at the parameters of Easy touch
Easy Touch offers a virtual joystick solution that can be adapted to your every need. Including the previous mentioned, custom UI, hide, specify the area and so on. You can try it out in your project
http://pan.baidu.com/s/1ovU58
Unity 3d-easy Touch 3 Tutorial Turn