Easy Touch Shake control character movement
public class Joystick:monobehaviour
{
public float speed; Define Speed
Private Charactercontroller CC; Define person Controller
Code startup
private void Ondisable ()
{
Start Call Onmove,onmoveend
Easyjoystick.on_joystickmove + = OnMove;
Easyjoystick.on_joystickmoveend + = Onmoveend;
}
private void OnDestroy ()
{
End Close Onmove,onmoveend
Easyjoystick.on_joystickmove-= OnMove;
Easyjoystick.on_joystickmoveend-= Onmoveend;
}
private void Start ()
{
CC = getcomponent<charactercontroller> ();//Get Controller
}
Touch Move Method
public void OnMove (Movingjoystick move)
{
Determine if it is easy Touch shake sense
if (move.joystickname! = "New joystick")
{
Return
}
Define and move left and right
float Joypositionx = move.joystickaxis.x;
float joypositiony = move.joystickaxis.y;
Judging before and after moving
if (joypositiony! = 0 | | Joypositionx! = 0)
{
Defining coordinates
Vector3 moveposition = new Vector3 (Joypositionx, 0, Joypositiony);
Defining coordinate increments
Vector3 dir = transform.position + moveposition;
Orientation oriented
Transform. LookAt (dir);
Positioning move
Vector3 MoVector3 = transform.forward*time.deltatime*speed;
First person move
Cc. Move (MOVECTOR3);
}
}
End of touch Move method
public void Onmoveend (Movingjoystick move)
{
Debug.Log ("Touch Lift")
}
}
Note: Using this method must be done after importing the easy touch plug-in, typically for non-PC-side use.
Easy Touch Shake control character movement