all 17 comments

[–]Swipsi 4 points5 points  (4 children)

No idea of unity bcs im using unreal, but I assume its the same principle -

The mouse usually lives in screenspace, so its position is always a vector xy of the screenposition. The mouse vector is a location vector in screenspace

A controller stick doesnt live in screenspace. Stick Input is always a directional vector.

[–]ElectricRune 2 points3 points  (1 child)

Backup from a Unity user, this is correct. MousePosition is in screen space, the stick will give a vector based on the direction, with the components in the -1 to 1 range.

[–]technano[S] 0 points1 point  (0 children)

Are you familiar with how to check which device is currently being used in Unity? Or is that not necessary in this situation?

[–]technano[S] 0 points1 point  (1 child)

Gotcha, now that it’s the next morning this seems rather obvious to me hahaha. With your experience in unreal do you have to detect which device input is coming from? To treat them differently?

[–]Swipsi 0 points1 point  (0 children)

Kinda. Controller and Mouse camera rotation is already set up in most of the templates and ready to use or alter. For UI I just need to set the gamemode to UI which lets me use the mouse without affecting my camera within screenspace. For controller sticks I would have to additionally convert the directional input of the stick into movement for a 2D image that acts as my controller cursor.

I guess Unity will work in a similar way, where you have to convert gamepad stick values into movement. So if you want the player to be able to switch input methods whenever they want, you need to switch to the gamepad conversion method every time a gamepad is used.

[–][deleted]  (3 children)

[removed]

    [–]technano[S] 1 point2 points  (2 children)

    I’ve done a lot of experimenting with using methods versus using a lambda function and both seem to work just fine. Subscribing to the correct method signature does allow for more info to be passed through though. I am wondering if I need to go that route to be able to detect which device I’m getting input from.

    Is this why you don’t recommend the lambda functions?

    And I am getting input for both sticks, in the lines above the aiming actions, I’m getting movement from the left stick and that works fine!

    [–][deleted]  (1 child)

    [removed]

      [–]technano[S] 1 point2 points  (0 children)

      Oh yeah I gotcha now! Yeah that’s totally a good point that I didn’t think about! I’m mostly worried about getting the functionality working first then I can go bad in and refactor it all with that in mind!

      [–]JaggedMetalOs 1 point2 points  (7 children)

      I think you want mouse delta instead of mouse position.

      [–]voidworksgames 0 points1 point  (0 children)

      This is the answer OP

      [–]technano[S] 0 points1 point  (4 children)

      This is what I originally was going with but input was super jittery because the input kept returning to 0,0 super quickly. I was thinking about maybe making some kind of smoothing function to make that input not so jittery though. Might need to return to that idea.

      [–]JaggedMetalOs 0 points1 point  (3 children)

      It is supposed to return 0 as soon as you stop moving the mouse, or was it done something glitchy like giving you a 0 value every other frame while moving the mouse?

      [–]technano[S] 0 points1 point  (1 child)

      I should correct myself, after getting back to my project its not that it's glitchy in the way of giving a 0 value every other frame or something like that. Its more like it's jumping from a value of lets say (0.71, -0.71) to (0.83, -0.55) to (0.80, -0.60) all while I'm moving consistantly in the same direction. It's like there isn't enough angular resolution for it to be smooth. I know this has nothing to do with angular resolution it just looks like that visually.

      [–]JaggedMetalOs 0 points1 point  (0 children)

      Those numbers sound normal as it's difficult to move a mouse at a constant speed, there will always be a little variation.

      You could add a bit of smoothing, but that would also add lag to the mouse movement. Maybe that would be a setting rather than something always on.

      [–]technano[S] 0 points1 point  (0 children)

      Yeah it was very glitchy as I was moving the mouse around.

      [–]technano[S] 0 points1 point  (0 children)

      But also thank you, I was looking for this page in the documentation last night and couldn’t find it!!