Unity Hand Tour < six > Game joystick easy Touch 3 tutorial

Source: Internet
Author: User

It's easy to use a joystick joystick that has been introduced in unity since. But it also has a lot of limitations, not all to meet the needs of ordinary MMO hand-tours, such as: to be able to easily better material, can be specified in an area display, or only when the area is touched, and so on. With these features, the easy touch plugin has been implemented for you. All are configurable. You can buy from the asset store or use the free version.

(can be freely shared, please specify the original source http://blog.csdn.net/janeky/article/details/17364903)

    • Instance

Use the last example to achieve it. Control the movement of a role

    • Steps

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:

[CSharp]View PlainCopy 
  1. Using Unityengine;
  2. Using System.Collections;
  3. Public class Movecontroller:monobehaviour {
  4. void onenable ()
  5. {
  6. Easyjoystick.on_joystickmove + = Onjoystickmove;
  7. Easyjoystick.on_joystickmoveend + = Onjoystickmoveend;
  8. }
  9. //shift lever End
  10. void Onjoystickmoveend (Movingjoystick move)
  11. {
  12. //Stop, role recovery idle
  13. if (move.joystickname = = "Movejoystick")
  14. {
  15. Animation.  Crossfade ("idle");
  16. }
  17. }
  18. //Move the lever
  19. void Onjoystickmove (Movingjoystick move)
  20. {
  21. if (move.joystickname! = "Movejoystick")
  22. {
  23. return;
  24. }
  25. //Get the coordinates of the center offset of the joystick
  26. float Joypositionx = move.joystickaxis.x;
  27. float joypositiony = move.joystickaxis.y;
  28. if (joypositiony! = 0 | | Joypositionx! = 0)
  29. {
  30. //Set the orientation of the character (toward the current coordinate + joystick offset)
  31. Transform. LookAt (new Vector3 (transform.position.x + Joypositionx, TRANSFORM.POSITION.Y, Transform.position.z + joypositiony  ));
  32. //Move the player's position (move by position)
  33. Transform. Translate (Vector3.forward * time.deltatime * 5);
  34. //Play run animation
  35. Animation.  Crossfade ("Run");
  36. }
  37. }
  38. }

Finish the work, the specific


Finally, let's take a look at the parameters of Easy touch

    • Summarize

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

Unity Hand Tour < six > Game joystick easy Touch 3 tutorial

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.