playMaker

Author Topic: How to Create Custom Cursor Joystick/Thumbpad/Gamepad [SOLVED]  (Read 4653 times)

Palanysamy

  • Playmaker Newbie
  • *
  • Posts: 14
    • View Profile
How to Create Custom Cursor Joystick/Thumbpad/Gamepad [SOLVED]
« on: November 04, 2013, 08:18:08 PM »
Hello people,
I am doing a game where you basically need to click on objects moving the cursor. It´s all done already for mouse, but I would like to do it for gamepad/joystick as well and I am unable to do it.
For Mouse, I use the following actions:
Get Mouse Y
Get Mouse X
Screen To World Point
Look at

For my attempts regarding gamepad/joystick, the same but instead of get mouse I use Get Axis (Horizontal and Vertical) but no good results?

How can I emulate mouse cursor with Joystick?
Thanks!
« Last Edit: November 10, 2013, 04:20:35 PM by Palanysamy »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15495
  • Official Playmaker Support
    • View Profile
Re: How to Create Custom Cursor Joystick/Thumbpad/Gamepad
« Reply #1 on: November 05, 2013, 02:21:31 AM »
Hi,

 For this you will need the following:

-- maintain a "joystick position" on screen, and have a cursor locating this position visually,

--using the get axis vector action, move that "joystick position" by adding the input values to it.

Does that make sense?

bye,

 Jean

Palanysamy

  • Playmaker Newbie
  • *
  • Posts: 14
    • View Profile
Re: How to Create Custom Cursor Joystick/Thumbpad/Gamepad
« Reply #2 on: November 05, 2013, 04:35:10 AM »
makes all the sense of the world Jean, thanks, I will try it as soon as I get home. Once that is done, I am thinking, how to keep the cursor on screen? with ScreenHeight ScreenWidth?
P.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15495
  • Official Playmaker Support
    • View Profile
Re: How to Create Custom Cursor Joystick/Thumbpad/Gamepad
« Reply #3 on: November 05, 2013, 06:13:21 AM »
Hi,

 Yes, and use "float clamp" to constraint each values easily, so in that regards I would actually maintain two individual floats, cursor width and cursor height, and then combine them into a vector for late convenience, else dealing with clamping on your own is a bit much for nothing.

bye,

 Jean

Palanysamy

  • Playmaker Newbie
  • *
  • Posts: 14
    • View Profile
Re: How to Create Custom Cursor Joystick/Thumbpad/Gamepad
« Reply #4 on: November 08, 2013, 09:39:36 PM »
Hi,
I can now move the cursor around with the joystick :
[Get Axis Vector]
store vector : inputVector
------------------------------
get position: position
-----------------------------
input vector + position
-----------------------------
This works perfectly. But I went to the second part, which is to keep the cursor in screen, I did:
Float clamp taking screen height and screen width into cursorheight and cursor width, and comibe these 2 floats in a new vector 3. But I dont know how to proceed from here (I tried vector3 clamp magnitude, but I just keep the cursor in a circle)
Any hint, suggestion?
MAny Thanks,
P.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15495
  • Official Playmaker Support
    • View Profile
Re: How to Create Custom Cursor Joystick/Thumbpad/Gamepad [SOLVED]
« Reply #5 on: November 11, 2013, 01:23:14 AM »
Hi,

 you need to clamp individually both axis, else, indeed if you clamp the vector, you will clamp the "radius" from the center. So extract both axis and clamp that.

bye,

 Jean