Totally lost about the way we must positionate the UIJoystick

Hey everyone!

Recently, I’ve downloaded UIToolkit to give it a shot. Now, I’m trying to create a UIJoystick, but I don’t get how UIToolkit positionate the item on the screen based on the parameters I’m passing. It doesn’t seem to make any sense. Someone can give me a help explaining a little bit about each parameter’s function and what it affects on the position?

Thanks from now!

Hi guto.thomas,

maybe it’s a little late but I recently passed for the same problem you have and finally find out how to position the UIJoystick.

The rect is the touch area of the Joystick, so you have to position it where you want the joystick to work, like:

Rect area = new Rect(0, Screen.height - bg.height, bg.width, bg.height)

it’s the left bottom of the screen and size of joystick’s background image. The following two paramenters is used to position the pad, relative to the touch area, you’ll probably want it on the center of the rect:

UIJoystick.create("joystick_image.png", area, bg.width / 2 , -bg.height / 2);

Remember that the Y axis is inverted.

Hope that help.