• 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
-1
Question by johnq1216 · Feb 09, 2014 at 05:54 PM · androidiphonecontrols

Why is there so little support for Virtual D-pads?

I can't find anything on Dpads. More specifically, I am looking for a way to control a character with 2 Arrow Buttons that are commonly seen in Mobile's platformers. Cordy 2 is a great example as it positions Left and Right buttons diagonally to each other (which IMO increases tactile feedback).

I'm working on a 2.5D platformer. I tried unsuccessfully to implement D-Pad controls. I thought 2 simple GUIs would work.

Does anyone know how I can get this control scheme to work or is there a prefab out there?

Thank you!

Comment
Add comment
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

3 Replies

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

Answer by barjed · Feb 09, 2014 at 08:09 PM

Then your real question is about passing parameters between objects, this isn't an issue related to the DPad specifically.

There are many ways in which you could accomplish that and I suggest reading on the subject because this is one of the fundamentals in Unity and in programming in general.

First identify the place where the Debug messages are actually sent. From there you have to make a decision. We do not know yoru code structure but let's assume you have a game object that's called TouchController and you have a script component called TouchControllerScript.cs that's connected to it that reads values from the on screen buttons.

Add a public property to your TouchControllerScript code, like so:

 public GameObject PlayerPrefab;

Now save the script and go back to the inspector, you'll notice that there's a familiar field in your script that let's you drag and drop GameObject entities there. Grab the object that represents your player and drop it there.

Now, from your TouchControllerScript, you have easy access to all different variables of the player GameObject, for example:

 PlayerPrefab.transform.position;

Now you can do what I said earlier - construct a movement vector from the axes values you read from the on screen buttons:

 Vector3 myMovementVector = new Vector3(xValue,0,zValue);

Pass it into the SimpleMove method (it accepts Vector3 as a parameter):

 PlayerPrefab.SimpleMove(myMovementVector);

Note that this requires that a CharacterController component is added to the prefab you'll be moving.

Voila!

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 johnq1216 · Feb 09, 2014 at 09:03 PM 0
Share

Thank you Barjed. You are a lifesaver! I'm sorry everyone that I was not clear on my question.

I first learned Java, so I am aware of parameters and public variables. For some reason, it was difficult to understand that in Unity.

Thank you again!

avatar image
0

Answer by Kiloblargh · Feb 09, 2014 at 06:30 PM

By "so little support," do you just mean it requires more effort than GameObject> Create Other > Virtual D-Pad?

It's not difficult to make one from scratch if you know how to use raycasts and colliders. If you can make a touchable anything, you can make a virtual d-pad. If you can't, you need to read the manual.

There are also several pre-built ones on the Asset Store, for around $30, which you would already know if you had made an effort to search for one.

Comment
Add comment · Show 5 · 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 johnq1216 · Feb 09, 2014 at 07:15 PM 0
Share

Well, if you need the details.

By little support, I mean there doesn't seem to be any documentation on it or a guide by other users. Youtube is usually reliable, but not in this case.

I am able to make a touchable anything. The problem I have is trying to get that touchable anything to move the character and not just send debug confirmations. I think the key is the FPS Controller. I've changed the Joystick Script to only send out -1 on the Horizontal Axis. That works, but my character can only go in one direction. I tried making a duplicate Joystick script and rena$$anonymous$$g it Joystick2, but of course the Camera Script and Controller Scripts only recognize the regular Joystick Script.

I can keep going, but I am tired and it's been several days.

So don't tell me or any newbie for that matter to "read the manual" and label my search efforts as lazy. And don't tell me to just shell out 30 bucks like I have them lying around. Don't waste my time or anyone else's time.

avatar image barjed · Feb 09, 2014 at 07:21 PM 0
Share

I am not sure I understand.

If you are already able to get a Axis value from your Joystick then things should be rather simple. There are Controller $$anonymous$$ove and Controller Simple $$anonymous$$ove components that accept Vector as their input and will move your character around the world.

So, construct a Vector3 from your Axes (X and Z), pass it to Controller Simple $$anonymous$$ove and you're set.

avatar image johnq1216 · Feb 09, 2014 at 07:50 PM 0
Share

The problem is I can't make the connection in scripting. I have a GuiTexture that detects touch by sending Debug messages. How do I make the connection between this GuiTexture and the Controller?

All I really want is one GuiTexture to send -1 and another GuiTexture to send 1 as an input.

avatar image meat5000 ♦ johnq1216 · Oct 10, 2015 at 05:55 PM 0
Share

The connection is made by measuring the difference between the point of touch on the texture and where it is dragged to (mapped on x,z for a 3D conversion). Taking this value for horiztonal and vertical axes gives you two separate non discrete values of control to work from.

avatar image xt-xylophone · Feb 09, 2014 at 07:53 PM 1
Share

So is this your real question?

avatar image
0

Answer by robin-broughton · Oct 10, 2015 at 04:02 PM

https://www.youtube.com/watch?v=z8XUM-19kdM

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

22 People are following this question.

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

Related Questions

RPG style controls for iOS/Android 0 Answers

Deploying to Android or iPhone device - track public variables in inspector? 1 Answer

Specular Materials on iPhone or Android? 1 Answer

Simultaneous Android and iOS development 1 Answer

Is this the correct walkthrough to get a game from pc to android/iphone? 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