I was wondering if there is a “virtual joystick” component out there that I could use for iphone/ipad joystick play?
Something that I could just plug in that would provide the graphics/scripting of the virtual joysticks, if that makes sense. Don’t really want to spend the time to make virtual joysticks/button controls myself if possible.
Yes, they are pretty easy to use, you can found them in Standard Assets (Mobile) folder,
The script is called Joystick. Here is how to use it:
Create an empty object, add an GUITexture on it (add your stick texture to), add the Joystick component to the same GameObject.
Then create an other component (on your character for example, to move it with the input you’ll retrieve from the Joystick component) then:
Use Joystick.position to retrieve position in screen space, relative to the center of the tap zone (defined in your Joystick public properties).
For example:
if (Joystick.position.x > 0)//the joystick was moved to the right
if (Joystick.position.x < 0)//the joystick was moved to the left
if (Joystick.position.y > 0)//the joystick was moved up
if (Joystick.position.y < 0)//the joystick was moved down
//those position always goes from 0 to 1 and 0 to -1, where 1(or -1) means that your stick wont move any further and of course 0 means that the stick is at the center of that axis.
Sorry for my quick answer, if you don’t understand well, I’ll try to respond later on with a clearer answer, I’m a bit busy now.
Cheers,
Bit of a necro here, but I am unable to locate the sample projects that are being referenced in this thread and am unable to figure out how to use the Joystick script that is a standard asset.
Which “it” are you referring to?
If you are referring to “the sample project” then you didn’t finish reading my post, as I don’t have one and am unable to read any values.
If you are referring to “the Joystick script” then you are a moron, as you can’t “slap that on a scene” and “read its values” because: 1) scripts can’t be attached to scenes and 2) those important values are their default 0 values and worthless.
That said, after posting my last message I located the PDF that was required to explain how to use the script. Since then, however, I’ve lost track of it.
I don’t HAVE a prefab. I have a JAVASCRIPT. I’m pretty sure I said that.
Oh wait, I did:
The reason I replied with sarcasm is because the unhelpful reply was unhelpful. I have managed to locate the PDF that the sample code came with (and thus have a working project now) but I am unable to further help others because I’ve lost track of where I found that PDF.
Yep. This the way it SHOULD work, however it does NOT. This is what happens:
Assets/Standard Assets/Character Controllers/Sources/Scripts/MouseLook1.cs(41,33): error CS0103: The name `Joystick’ does not exist in the current context
And I have no clue why. BUT if take a duplicate of the FirstPersonControl script located in the same package and copy/paste my code just after the Joystick variable declaration in that file, I can see the public vars in the inspector. I don’t really think that’s the way it should be done.
Then using the Joystick script in C# file, like modified version of the MouseLook script, seems to be impossible what ever I try. I also tried the C# version of the Joystick script but I still get the same error.
This doesn’t work either I get the same error like the Joystick script didn’t exist in my project. Does anyone have any clue why this happens?