Convert Mouse Cursor to Gamepad Cursor

This might be a tricky one. I’ve looked everywhere online.

I’m attempting to use the right stick movement as a crosshair in order to shoot a grappling hook towards the crosshair position. I have messed around a bit with some tutorials but there’s nothing solid that I can find on how to do it correctly. Any advice?

Assuming you have some gun on your player
A separate object attached to your player
That rotates toward mouse cursor
If not then make one it even can be invisible (blank image)

Now make a custom point FOR EXAMPLE 100 pixels away from your gun object
I made arm object for my player instead of gun (yes my player shoot from hand imagine that) and added a point away 80 pixels from player called it TouchCrosshair

Now all i do IF game is ran on device with touch screen
I check in condition does device have touch screen and if so it activates all touch crap (same condition but inverted i have for events that make arm follow mouse cursor while attaching crosshair object to cursorX and Y)

Now i change position of that crosshair (if device have touch screen) to Player.PointX(“TouchCrosshari”) same for Y

And all i need to do now is to rotate arm (in your case gun object) toward angle of right touch analog i placed on screen

In your case you rotate gun toward your right or left gamepad analog depending on what you want

Try it on desktop then try it on phone
As simple as that

Hey thanks for the response, I am using a gamepad for the controls. My character is essentially mud that will shoot out a long appendage that will grab and pull him towards the target. I think your solution will work pretty well just making it essentially a separate object that is hidden but stuck to the player until called upon. Thank you for the info, I will let you know if that works out. I’m still really new to this software, but I’m LOVING it.

1 Like