Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by just_a_joke · Mar 31, 2015 at 10:21 AM · androidunity 5iosmobilejoystick

Unity 5 mobile single stick control

Hi there, I recently update to Unity 5 and now working on a project on mobile platform. I tried to play around with the new CrossPlatformInput in Unity 5 and implement the "MobileSingleStickControl" prefab that built in under 2D asset. But I unable to get the control to work, the controller UI did shown in the screen but user cannot interact with the controller.

I can't find any related example on using the control, mostly what I found are joystick control in Unity 4. Please provide me some example or suggestion on the controller.

Thanks

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image BlackMateria · Jan 28, 2017 at 04:17 AM 0
Share

All works now BUT i cant move and the same time jump! Help please!

5 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Thiago Baptista · Apr 07, 2015 at 12:10 PM

You've got to have an EventSystem game object in your scene in order to make the virtual joystick work. Just create one in the hierarchy and you`re set.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KitCoo · Apr 14, 2015 at 07:52 AM 0
Share

sorry if this is the wrong spot to post this question. I have got the Joystick to work by adding the Event System. Now my Problem is that every time I touch the sprite it moves all the way to screen location (0,0)? it works but is stuck in the corner.

avatar image
7

Answer by ShawnFeatherly · Apr 15, 2015 at 08:08 PM

The most common issue is the joystick popping into a corner, this is fixed by changing Joystick.cs's OnEnable() to Start(). A demonstration of this fix is covered at 5:30 in this video. https://youtu.be/l7YiASYgDC0?t=5m30s

For other issues, watch this video from the start.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KitCoo · Apr 17, 2015 at 04:58 PM 0
Share

Thanks for all the help, awesome I really appreciate the response.

avatar image
0

Answer by Textfield272 · Apr 01, 2015 at 08:49 AM

I haven't played around with any of the input prefabs and scripts in the standard assets, but I implemented a single-stick control pretty easily with a basic script.

The property Input.touches is a Touch[] that holds all touch input that frame. The state of each Touch can tell you whether it just began or was there the previous frame, and each touch also has a finger id associated with it that allows you to track the movement of individual fingers. And of course you can get the position on the screen.

A bit of basic logic will allow you to determine if there is a new touch inside the bounds of the control stick, and by subtracting the center of the control stick from the position of the touch, you can get an Vector2 representing the offset. Of course that offset will be in pixels, so you'll probably want to divide that by the radius of the stick in pixels; otherwise the magnitude the control stick gives will vary depending on the DPI of the device.

Hope that helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by ulissescad · Jan 07, 2016 at 07:00 PM

Looking at the examples of vehicles made ​​this script and fucionou well for what was proposed . First import the library of standard assets and then simply recall the position as was done in script below. MOVX is a variable for managing the movement by the inspector .

using UnityEngine ; using UnityStandardAssets.CrossPlatformInput ; using System.Collections;

public class Mov : { MonoBehaviour

 public float MOVX ;

// Use this for initialization void Start ( ) {

    // Joystick.



}

// Update is called once per frame void Update () {

     Debug.log ( Input.GetAxisRaw ( " Horizontal "));

     this.transform.Translate ( CrossPlatformInputManager.GetAxis ( " Horizontal " ) * * MOVX Time.deltaTime , 0 , 0);

} }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by danifou · Nov 10, 2016 at 11:48 AM

i have a simlar problem but its a bit diferent i can t cheak the box at the left corner at the top i got that asset from standar assets

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How access asset files in android/ios 0 Answers

Mobile joystick not moving player 0 Answers

Mobile Virtual Joysticks / Keyboard Script Conversion 0 Answers

Mobile Game Different Screen Size Issue 2 Answers

Unity Android java.lang.ClassNotFoundException 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges