[Unity3d] easytouch usage

Source: Internet
Author: User

For RPG games on mobile platforms, we often use virtual joystick to control the walk and behavior of character roles. I believe we are no stranger to it. We tried easytouch2.5 before, it is found that the latest version of 3.1 is not easy to use. The version 2.5 does not do well in self-adaptation, and the latest version has solved this problem. Of course, unity also comes with the joystick, which is easy to use, but there are many limitations that won't meet the needs of General MMO games, such as specifying display areas or changing some materials, these easytouch plug-ins have been implemented for you, and you have to admire the plug-in's original author to make such cool and useful plug-ins. Of course, this is estimated to be developed by foreigners. For the download of plug-ins, you can purchase it on assetstore, or use the free version.

I also provide a 3.1 plug-in here: http://download.csdn.net/detail/s10141303/6962919

I,

It feels cool! Next, let's take a look at the creation process!

Ii. Procedure 1. Quick Start (C #) in the official documentation #)

1-import easytouch package.
2-create an empty gameobject, and name it easytouch. (You can choose another name)
Step 1 & 2 can be replace by the option menu


3-Add the easytouch. CS script on the easytouch gameobject that you just created.
4-select the easytouch gameobject, and verifies that broadcast messages is set to false in the inspector.


5-create a new C # script myfirsttouch
6-add these methods

[CSHARP]View plaincopyprint?
  1. // Subscribe to events
  2. Void onenable (){
  3. Easytouch. on_touchstart + = on_touchstart;
  4. }
  5. // Unsubscribe
  6. Void ondisable (){
  7. Easytouch. on_touchstart-= on_touchstart;
  8. }
  9. // Unsubscribe
  10. Void ondestroy (){
  11. Easytouch. on_touchstart-= on_touchstart;
  12. }
  13. // Touch start event
  14. Public void on_touchstart (gesture ){
  15. Debug. Log ("Touch in" + gesture. position );
  16. }

7-create an empty gameobject, and name it receiver.
8-add myfirsttouch script to the gameobject er.
9-run it in editor, and click on the screen

 

2. Translate the above steps

1. Import the "easytouch" Resource Package

2. Create an empty object and name it easytouch (you can also change it to another name)

3. Add the easytouch. CS script on the just-created easytouch object.

4. Select change object, but do not select broadcastmessages

5. Create a new C # script named myfirsttouch

6. Add these methods

7. Create an empty object named "er ".

8. Add the myfirsttouch script to the empty object explorer.

9. Run and click Remote Sensing. The console displays the currently pressed coordinates.

3. according to the official prompts, You Can Do remote sensing Control for your own people. 1. import easytouch3 resource package 2. prepare for the preliminary stage, including creating the character model and terrain. 3. add a joystick instance: Hedgehog team-> easy touch-> extensions-> Add a new joystick. In this case, a virtual Remote Sensing instance is created in the lower left corner. 4. Set parameters for remote sensing. 5. Create the script movecontroller. CS to receive the movement of the remote sensing event control role. [CSHARP]View plaincopyprint?
  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. // Move the joystick to the end
  10. Void onjoystickmoveend (movingjoystick move)
  11. {
  12. // When the role is stopped, the role restores the idle
  13. If (move. joystickname = "movejoystick ")
  14. {
  15. Animation. crossfade ("idle ");
  16. }
  17. }
  18. // Move the joystick
  19. Void onjoystickmove (movingjoystick move)
  20. {
  21. If (move. joystickname! = "Movejoystick ")
  22. {
  23. Return;
  24. }
  25. // Obtain the coordinates of the rocker center offset
  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 role (orientation to 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 (moving by orientation)
  33. Transform. Translate (vector3.forward * time. deltatime * 5 );
  34. // Play the running animation
  35. Animation. crossfade ("Run ");
  36. }
  37. }
  38. }
Execution sequence of several functions: 6. 7. click the create button and choose hedgehogteam> easytouch> extensions> Create a New button. A button is created in the lower right corner of the screen. How can we make the desired effect by clicking the button with the desired button? Jump method: click the button to jump the character! If you need to reprint please indicate the source: http://blog.csdn.net/dingxiaowei2013/article/details/19967041

================================== Publisher Ding Xiaowei csdn blog column ================ =====

Myblog: http://blog.csdn.net/dingxiaowei2013 myqq: 1213250243

Unity QQ group: 858550 cocos2dx QQ group: 280818155

==================================== Mutual learning, common progress ==============================

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.