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!
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.
barjed
3
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!