💬 It's been a while since I made a regular tutorial, I hope it helps you! ✅ Get the Project files and Utilities at unitycodemonkey.com/video.php?v=j2XyzSAD4VU 🎮 Play my Steam game! cmonkey.co/dinkyguardians 🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses 👍 Learn to make awesome games step-by-step from start to finish. 🔴 RELATED VIDEOS 🔴 How to use NEW Input System Package! (Unity Tutorial - Keyboard, Mouse, Touch, Gamepad) ruclips.net/video/Yjee_e4fICc/видео.html Polish your game with my Mouse Cursor System PRO! (Make your game STAND OUT!) ruclips.net/video/wI7ug-6hdcM/видео.html My game is RELEASED! I hope you like it! (Dinky Guardians) ruclips.net/video/7m2EJYFDgWI/видео.html Simple Text Input Field Window in Unity (Submit Score, Name) ruclips.net/video/4n6RT805rCc/видео.html Samyam's Tutorial ruclips.net/video/Y3WNwl1ObC8/видео.html
While I absolutely despise the way AAA games are implementing this control scheme in all sorts of menus, I can appreciate a well done tutorial for it.. Good job!
Very nice and thorough video! I always love seeing your journey as you use more packages. I'd like to point out that there is a 'hardware cursor' cursor mode option on the virtual cursor component, that prevents double inputs for you from the get go! Also, the cursor graphic checks for canvas in the hierarchy parents to limit the movement to that canvas's pixel rect. Scale indeed doesn't fully comply here. Also, the event system component has a boolean to prevent sending navigation events as a whole. This can help too!
Thank you for showing some of your Dinky Guardians code at the end. It helped me debug an issue with how I was detecting input device changes. Would have never thought to ignore the VirtualMouse inputs in that function.
I had the exact same issues, as I guess the whole Unity community willing to use the Virtual Mouse component... at the version 1.7.X already. Thanks a lot, this is a blast to have workaround-ers.
I have a few questions to ask. First, did you use your own custom editor for your game? Second, I'm not quite sure what nameSpace and assembly definition are, but I'd like to know if I should use them. Third, what is a unit test and should I use it? Lastly, how can I determine my skill level when it comes to getting a job, such as which topics are considered beginner, intermediate, and advanced?
What do you mean by "custom editor"? Sounds like you need to learn the absolute basics, learn those before you worry about concepts like those ruclips.net/video/IFayQioG71A/видео.html unitycodemonkey.com/kitchenchaoscourse.php Best of luck!
Wow, that's very useful, and it's nice that you not only explain how to implement the virtual mouse, but also the problems you came across! And indeed, I would expect a "production ready" package to have all of the bugs that you mentioned fixed. I mean, it's kidna ridiculous that apparently they didn't test canvas scaling and position going out of the screen... But once again, thanks for the very insightful tutorial! (and for the time you spent going insane over those bugs)
This is a very useful idea. I was going to Google this out, for adapting my demo (from a PC port) to Mobile Platforms. By using the GamePad as the Mouse Pointer, everything is solved. 💯👌🏻 Thank You.
Thanks for the video, it helps me about the Clamp problem! Actual you can fix the virtualMouse offset problem by setting the CanvasScaler-UIScaleMode to 'ConstantPixelSize', which will make the Canvas match exactly as the Game Window's size
i had to solve this problem several months ago, i mixed similar logic to this with your raycast from screen space to worldspace logic to recreate the 'hand' cursor from black & white in my clone called Ungodly.
Hey CM. Awesome video. I will definitely use this for my own game. Just thought I'd send a little tip from what I saw whilst watching this tutorial. Around 22:50, I noticed that on line 96, you check if arg1 is an InputAction and then underneath on line 97 you define it. You can actually do this in the if statement and you already have most of it. An example would be: if (arg1 is InputAction inputAction) { // Use inputAction here. } Just a neat little one-line saver :p I use this as well when I check for certain objects. For instance, in my game I have a global world I can get. I do the following if (World.Get() is World world) { }
the cursor clamp script seems to work in your video but exactly copy and pasted it gives me this error: Severity Code Description Project File Line Suppression State Error CS1061 'Vector2Control' does not contain a definition for 'value' and no accessible extension method 'value' accepting a first argument of type 'Vector2Control' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\19703\My project (11)\Assets\0Scripts\VirtualMouseUI.cs 19 Active online it suggest to change it Read.Value but then the clamp doesnt work at all. anyone able to help?
I am using the canvas in Screen Space mode, and I can't change it because it would break the entire game. What would be the correct way to maintain the proportion when changing the screen resolution? For example, it's at 1920x1080, and I switch to 1280x720, then the cursor was in the corner of the screen and can’t click on anything anymore.
Also, i ran into a very special edge case, you should be careful: If you have steam open, and xinput for gamepad enabled, unity will also try to read your gamepad input as keyboard input! Be sure to disable xinput from steam when testing your game!
I followed your tutorial, but my cursor keeps moving by itself to the upper right side as soon as the mouse is detected as input device and i am not able to stop the cursor from moving. I also cant move it in any other direction. When disconnecting the mouse, everything works as expected. Do you have any idea what causes this?
i solved problems with scaling by modifying virtual mouse script. the problem was it cant get canvas component from parent so i added it manualy and just divided position and visual scaling to canvas.scaleFactor. but i wonder how to add input actions from the script?
If your project have Player Input componant in the scene, it may let you unable to interact with the UI. I've turned off the Player Input componant when the game is paused and solved the problem. If there's a better way, please tell me, thanks.
The shader is called Quibli, it's a really nice toon shader The button animations were made with Feel unitycodemonkey.com/video.php?v=Kx2Pi8yAitw It's basically just the included squash and stretch coupled with some basic animations
(Just watched the first 30 seconds, but) Is there a way to do the polar oposite? Is there a solution to make the mouse "become" an analog stick? I want to use my mouse as an analog stick. But not just a regular controller stick (in that case I could just use a controller), but an overclocked joystick. Like when you move the mouse really quick, it pushes the stick to its limits, giving you really quick movements in game. Aka make the joystick behave like a mouse, so that you can use the actual mouse as a joystick. I need this for games which don't support the simultanious use of mouse and controller. So how ever the solution is going to look like, it HAS to keep the analog behaviour of the movement stick. It may NOT switch to WASD behaviour.
Nice tutorial! I didn't know of the OnActionChange event for the input system until now. It's more convenient than the approach I implemented by keeping track of the last input time for each device type using for example Gamepad.current.lastUpdateTime Keyboard.current.lastUpdateTime and then comparing which one is the most recent one every 0.1 seconds or so. Thank you for sharing!
Excellent tutorial! How bad is it to create a canvas just for the virtual mouse and setting the Canvas Scaler UI Scale Mode to Constant Pixel Size? It solved my problem without code, the mouse always have the same pixel size and the canvas always have scale = 1.
Probably not bad, it will have some overhead but if that Canvas only has the virtual cursor I think the impact will be minimal, so if that works yup use it
Hey Code Monkey, I followed the tutorial but I have an anoying bug that I lost a lot of time trying to find a solution. Everytime I enable the virtual mouse I get a input action from the real mouse from the point action, because of that the real mouse dont get invisible and all of the UI dont change to show the buttons for the device that you are using, why is this happening?
@CodeMonkeyUnity Thanks for the tutorial! I would love to see more on gamepads. For example how do you show a keyboard for a gamepad? I could not find a good solution to this..
For my game I just used the Steamworks keyboard which you can make it show using their API partner.steamgames.com/doc/api/ISteamUtils#ShowFloatingGamepadTextInput
Is the virtual mouse only used for UI? Also, when my mouse cursor gets close to where my hidden gamepad cursor is (or vice versa) the gamepad cursor suddenly shows, snaps to where the mouse cursor is and the mouse cursor hides. Any possible ideas what may be causing this?
The virtual mouse works on whatever the regular mouse works, usually that's just the UI yes but you could also make a regular world raycast if you wanted someting like an RTS game with a virtual cursor unitycodemonkey.com/video.php?v=0jTPKz3ga4w You mean the hidden gamepad visual? If that is disabled then nothing should be interacting iwth it, and it's really just a visual so even when enabled it shouldn't affect anything Sounds like you have some strange logic interfering with those game objects, add some Debug.Log on your virtual cursor script to see what it's doing
It works great, but even if i added the division to canvas scaling, my virtual mouse is "trapped" inside tiny square on nintendo switch screen :/ Maybe becacuse my canvas is Screen Space - Camera? Any fix to that?
You really shouldn't be using a Camera with this, if you need a camera for your UI so you can apply some effects then you can keep doing that and just put the Virtual Cursor on a second Canvas using Screen Space Overlay.
I tried that, but then if I have buttons (with shaders applied) on my screen space camera canvas, and put the virtual mouse on the screen space overlay canvas, it just doesn't detect buttons if they are on second canvas. Anyway, I've sucessfully made a workaround (just switching canvas mode to overlay/camera when needed)@@CodeMonkeyUnity
@@CodeMonkeyUnity in 17:27 you add .value por I think you cant usa that command anymore. I even download your files and the .value part still is underline in red.
Bruh just use this instead. We are probably using the wrong unity version. Vector2 virtualMousePosition = virtualMouseInput.virtualMouse.position.ReadValue(); - That will do it. Happy coding :)
Add some Debug.Log to see what your code is doing and where the logic is stopping Is it an issue with just the viusal? Or the input? You can download the project files and compare with your own
@@CodeMonkeyUnity I installed the sample into my project. There is the cursor moving. If I copy the cursor into my scene it's moving as well and the setting looks identical. But if I create it on my own, nothing moves. That's really strange.
Hi CodeMonkey (I really should remember your name !) I want to use the controller instead of my mouse for an Xbox Conversion from PC, where I want to move the cursor around with the left stick and press A button instead of left mouse button (NOT IN A CANVAS) normal gameplay area. How would I do that ?
The canvas is just for display, the virtual cursor is acting like a normal cursor, so this method works perfectly fine for that, you can make something like an RTS using this, it's not just limited to UI
Ok, so I followed everything from your tutorial but when I change the res to anything other than FullHD the mouse for some reason gets trapped in a little square outside of canvas no matter what, probably due to the clamping on screenwidth we are doing on lateupdate, but still after doing the scaling part(I did the whole video) it still doesn't work. But when I return to FullHD it works fine and the mouse stays inside the regular canvas. I have no idea why, any suggestions?
Did you apply the division based on the Canvas localScale? Did you position and anchor the virtual cursor game object correctly? You can download the project files linked in the description and compare with your own
Is anyone else getting "Could not find active control after binding resolution" errors when enabling/disabling the virtual mouse game object? Edit: Just... dont upgrade to higher versions. I was using input system version 1.7. I downgraded to 1.3 and it fixed itself. yeahy!
if the work only with the new input system this system method it not for my the main reason i dont use the new input system is because the new input system Das not support therd patty controller's the support only ps4, Xinput, and maby switch controller the old input system on the other hand support every controller this one off the reason that in my game i will make sure use the old input system and i will make bindings the order make sure the player able to use whatever controller the wand and set up buttons in the order to work in the option i have both but i don't i will use new input system Mach in my game at least not for the controller's
@@CodeMonkeyUnity yes have use the debugger and I'm able to add the thos spefic therd party controllers im using if wand to the problem is that as far im award if someone use different there'd party controllers that is very likely i will still not work, the other issue is as fa I'm awerd even wand to add apis controller apis for popular therd party controllers im not able to do that, the only way to support only therd party controllers with the new input system is, to those connected controller in my computer at this time or to use the ones already support with the new input system (xinput, ps4,ps5 ect) in my game controller is very important, in my game i wand the up 4 player for each computer, in the order to achieve that in need to perfect controller support and i personally dont except people to have multiple official controllers and because have option to 4 for player with split screen it very important to support every therd party controller for the get go, event if the need to changes the default button layout wean shaman use the therd party controllers and the old system support every there'd party controllers because the find thos button layout for the windows directly unlike the new input system
I guess that is fair, usually game companies slap it on to obnoxiously complex and tight UI because they couldn't be bothered to order the buttons@@CodeMonkeyUnity I mean, there are very few "Don'ts" when it comes to game dev, Never unlock the players physic rotation you say? Yet adding a little tilt when you strafe feels fun and responsive. Never ever use default materials for everything? Yet if you decide to render things based on distance and their colliders then all the sudden you have best-seller. I guess these "DO NEVER"'s are the same as chromatics in music or dissonant chords, you are told Never ever ever harmonize a B, a C, and a C#, yet you see Beethoven chew that rule up and spit out masterpieces. Like a spice, it can be misused and ruin a dish, but with the right execution it can make it legendary.
💬 It's been a while since I made a regular tutorial, I hope it helps you!
✅ Get the Project files and Utilities at unitycodemonkey.com/video.php?v=j2XyzSAD4VU
🎮 Play my Steam game! cmonkey.co/dinkyguardians
🌍 Get my Complete Courses! ✅ unitycodemonkey.com/courses
👍 Learn to make awesome games step-by-step from start to finish.
🔴 RELATED VIDEOS 🔴
How to use NEW Input System Package! (Unity Tutorial - Keyboard, Mouse, Touch, Gamepad) ruclips.net/video/Yjee_e4fICc/видео.html
Polish your game with my Mouse Cursor System PRO! (Make your game STAND OUT!) ruclips.net/video/wI7ug-6hdcM/видео.html
My game is RELEASED! I hope you like it! (Dinky Guardians) ruclips.net/video/7m2EJYFDgWI/видео.html
Simple Text Input Field Window in Unity (Submit Score, Name) ruclips.net/video/4n6RT805rCc/видео.html
Samyam's Tutorial ruclips.net/video/Y3WNwl1ObC8/видео.html
you made this video at the EXACT right time for me! I'm literally just starting to add controller support!
Nice! Best of luck with your game!
@@CodeMonkeyUnity thanks!
CM never dissapoints! Great tutorial as always!
While I absolutely despise the way AAA games are implementing this control scheme in all sorts of menus, I can appreciate a well done tutorial for it.. Good job!
Very nice and thorough video! I always love seeing your journey as you use more packages.
I'd like to point out that there is a 'hardware cursor' cursor mode option on the virtual cursor component, that prevents double inputs for you from the get go!
Also, the cursor graphic checks for canvas in the hierarchy parents to limit the movement to that canvas's pixel rect. Scale indeed doesn't fully comply here.
Also, the event system component has a boolean to prevent sending navigation events as a whole. This can help too!
Thank you for showing some of your Dinky Guardians code at the end. It helped me debug an issue with how I was detecting input device changes. Would have never thought to ignore the VirtualMouse inputs in that function.
I had the exact same issues, as I guess the whole Unity community willing to use the Virtual Mouse component... at the version 1.7.X already.
Thanks a lot, this is a blast to have workaround-ers.
I have a few questions to ask. First, did you use your own custom editor for your game? Second, I'm not quite sure what nameSpace and assembly definition are, but I'd like to know if I should use them. Third, what is a unit test and should I use it? Lastly, how can I determine my skill level when it comes to getting a job, such as which topics are considered beginner, intermediate, and advanced?
What do you mean by "custom editor"?
Sounds like you need to learn the absolute basics, learn those before you worry about concepts like those
ruclips.net/video/IFayQioG71A/видео.html
unitycodemonkey.com/kitchenchaoscourse.php
Best of luck!
No, i means editor scripting@@CodeMonkeyUnity
Watching this makes me wonder if anyone at Unity actually ever tested this feature... Thanks, Code Monkey, you saved me a LOT of headache!
I'm glad the video helped you! Thanks!
Wow, that's very useful, and it's nice that you not only explain how to implement the virtual mouse, but also the problems you came across! And indeed, I would expect a "production ready" package to have all of the bugs that you mentioned fixed. I mean, it's kidna ridiculous that apparently they didn't test canvas scaling and position going out of the screen...
But once again, thanks for the very insightful tutorial! (and for the time you spent going insane over those bugs)
This is a very useful idea.
I was going to Google this out, for adapting my demo (from a PC port) to Mobile Platforms. By using the GamePad as the Mouse Pointer, everything is solved. 💯👌🏻
Thank You.
Thanks for the video, it helps me about the Clamp problem! Actual you can fix the virtualMouse offset problem by setting the CanvasScaler-UIScaleMode to 'ConstantPixelSize', which will make the Canvas match exactly as the Game Window's size
Super usefull ... I was trying to do this kind of thing, and I didn't know that already exist a solution. Thank you.
Are you stalking me? I was just looking to make this for my game. Perfect timing!
I hope it helps! I certainly wish I had a video like this when I started researching this topic, it would have saved me a ton of headaches heh
@@CodeMonkeyUnity Well thanks for saving me a headache. haha
YES. this is exactly what I needed when I needed it!
Ok this tutorial saved my day. It was exactly what i needed. Thanks!
I'm glad to hear that!
This tutorial helped a Ton! Thanks! I was having issue with navigating my ability tree UI with the automatic UI navigation.
I needed this as well.Thank you!
i had to solve this problem several months ago, i mixed similar logic to this with your raycast from screen space to worldspace logic to recreate the 'hand' cursor from black & white in my clone called Ungodly.
Hey CM. Awesome video. I will definitely use this for my own game. Just thought I'd send a little tip from what I saw whilst watching this tutorial. Around 22:50, I noticed that on line 96, you check if arg1 is an InputAction and then underneath on line 97 you define it. You can actually do this in the if statement and you already have most of it.
An example would be:
if (arg1 is InputAction inputAction)
{
// Use inputAction here.
}
Just a neat little one-line saver :p I use this as well when I check for certain objects. For instance, in my game I have a global world I can get. I do the following
if (World.Get() is World world)
{
}
OH is that right? I've never seen that syntax, that is indeed an awesome little time saver. I just learned something new so thanks a lot!
Good info. Thanks CM! 👍
I used Constant Pixel Size instead of Scale with screen size. I don't see any problem and now it works on Ultra wide and 1080.
FYI, if you're having problems getting this to work, you may need to manually pair the virtual mouse to the correct user.
the cursor clamp script seems to work in your video but exactly copy and pasted it gives me this error:
Severity Code Description Project File Line Suppression State
Error CS1061 'Vector2Control' does not contain a definition for 'value' and no accessible extension method 'value' accepting a first argument of type 'Vector2Control' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\19703\My project (11)\Assets\0Scripts\VirtualMouseUI.cs 19 Active
online it suggest to change it Read.Value but then the clamp doesnt work at all. anyone able to help?
Thank you code monkey ❤❤❤ you save me
I am using the canvas in Screen Space mode, and I can't change it because it would break the entire game. What would be the correct way to maintain the proportion when changing the screen resolution? For example, it's at 1920x1080, and I switch to 1280x720, then the cursor was in the corner of the screen and can’t click on anything anymore.
Also, i ran into a very special edge case, you should be careful: If you have steam open, and xinput for gamepad enabled, unity will also try to read your gamepad input as keyboard input! Be sure to disable xinput from steam when testing your game!
I followed your tutorial, but my cursor keeps moving by itself to the upper right side as soon as the mouse is detected as input device and i am not able to stop the cursor from moving. I also cant move it in any other direction. When disconnecting the mouse, everything works as expected. Do you have any idea what causes this?
Dose it work for multiple control? similar to the character selection screen in super smash bros
i solved problems with scaling by modifying virtual mouse script. the problem was it cant get canvas component from parent so i added it manualy and just divided position and visual scaling to canvas.scaleFactor. but i wonder how to add input actions from the script?
If your project have Player Input componant in the scene, it may let you unable to interact with the UI.
I've turned off the Player Input componant when the game is paused and solved the problem.
If there's a better way, please tell me, thanks.
What shader did you use to make your game look cool like that? Also the menu / buttons to have that gloss animation when mouse hover?
The shader is called Quibli, it's a really nice toon shader
The button animations were made with Feel unitycodemonkey.com/video.php?v=Kx2Pi8yAitw
It's basically just the included squash and stretch coupled with some basic animations
(Just watched the first 30 seconds, but) Is there a way to do the polar oposite? Is there a solution to make the mouse "become" an analog stick?
I want to use my mouse as an analog stick. But not just a regular controller stick (in that case I could just use a controller), but an overclocked joystick. Like when you move the mouse really quick, it pushes the stick to its limits, giving you really quick movements in game. Aka make the joystick behave like a mouse, so that you can use the actual mouse as a joystick.
I need this for games which don't support the simultanious use of mouse and controller.
So how ever the solution is going to look like, it HAS to keep the analog behaviour of the movement stick. It may NOT switch to WASD behaviour.
Anyone else wondering why buttons are unresponsive and not working: check lock state, makes sure lock is set to confined.
can you elaborate? im having this issue
You saint! I've been going crazy and this is what was wrong.
Nice tutorial! I didn't know of the OnActionChange event for the input system until now. It's more convenient than the approach I implemented by keeping track of the last input time for each device type using for example Gamepad.current.lastUpdateTime Keyboard.current.lastUpdateTime and then comparing which one is the most recent one every 0.1 seconds or so. Thank you for sharing!
My mouse cursor still doesnt higlight over the correct location where the buttons are even after using the fix you said
You can download the project files to compare directly with your own, everything should work if you start from there
Excellent tutorial!
How bad is it to create a canvas just for the virtual mouse and setting the Canvas Scaler UI Scale Mode to Constant Pixel Size? It solved my problem without code, the mouse always have the same pixel size and the canvas always have scale = 1.
Probably not bad, it will have some overhead but if that Canvas only has the virtual cursor I think the impact will be minimal, so if that works yup use it
Hey Code Monkey, I followed the tutorial but I have an anoying bug that I lost a lot of time trying to find a solution. Everytime I enable the virtual mouse I get a input action from the real mouse from the point action, because of that the real mouse dont get invisible and all of the UI dont change to show the buttons for the device that you are using, why is this happening?
@CodeMonkeyUnity Thanks for the tutorial! I would love to see more on gamepads. For example how do you show a keyboard for a gamepad? I could not find a good solution to this..
For my game I just used the Steamworks keyboard which you can make it show using their API partner.steamgames.com/doc/api/ISteamUtils#ShowFloatingGamepadTextInput
Is the virtual mouse only used for UI? Also, when my mouse cursor gets close to where my hidden gamepad cursor is (or vice versa) the gamepad cursor suddenly shows, snaps to where the mouse cursor is and the mouse cursor hides. Any possible ideas what may be causing this?
The virtual mouse works on whatever the regular mouse works, usually that's just the UI yes but you could also make a regular world raycast if you wanted someting like an RTS game with a virtual cursor unitycodemonkey.com/video.php?v=0jTPKz3ga4w
You mean the hidden gamepad visual? If that is disabled then nothing should be interacting iwth it, and it's really just a visual so even when enabled it shouldn't affect anything
Sounds like you have some strange logic interfering with those game objects, add some Debug.Log on your virtual cursor script to see what it's doing
Is there a way to interact with my objets in scene too ?
As long as they interact with the event system yes. So you can add a PhysicsRaycaster and "click" on objects in the world that have colliders.
@@CodeMonkeyUnity thanks
It works great, but even if i added the division to canvas scaling, my virtual mouse is "trapped" inside tiny square on nintendo switch screen :/ Maybe becacuse my canvas is Screen Space - Camera? Any fix to that?
because the scale doesn't change on the canvas with screen space- camera, pls help code monkey :(
You really shouldn't be using a Camera with this, if you need a camera for your UI so you can apply some effects then you can keep doing that and just put the Virtual Cursor on a second Canvas using Screen Space Overlay.
I tried that, but then if I have buttons (with shaders applied) on my screen space camera canvas, and put the virtual mouse on the screen space overlay canvas, it just doesn't detect buttons if they are on second canvas. Anyway, I've sucessfully made a workaround (just switching canvas mode to overlay/camera when needed)@@CodeMonkeyUnity
Hello, in the part: virtualMouse.position.value the ".value" doesnt work anymore and mark an error. What can I use instead?
What error?
@@CodeMonkeyUnity in 17:27 you add .value por I think you cant usa that command anymore. I even download your files and the .value part still is underline in red.
But what is the actual error? Maybe you're using an old version of the Input System?
Bruh just use this instead. We are probably using the wrong unity version. Vector2 virtualMousePosition = virtualMouseInput.virtualMouse.position.ReadValue(); - That will do it. Happy coding :)
Hi, I followed your tutorial but for some reason the cursor is not moving. I'm using Unity 2023.
Add some Debug.Log to see what your code is doing and where the logic is stopping
Is it an issue with just the viusal? Or the input?
You can download the project files and compare with your own
@@CodeMonkeyUnity I installed the sample into my project. There is the cursor moving. If I copy the cursor into my scene it's moving as well and the setting looks identical. But if I create it on my own, nothing moves. That's really strange.
Hi CodeMonkey (I really should remember your name !) I want to use the controller instead of my mouse for an Xbox Conversion from PC, where I want to move the cursor around with the left stick and press A button instead of left mouse button (NOT IN A CANVAS) normal gameplay area. How would I do that ?
The canvas is just for display, the virtual cursor is acting like a normal cursor, so this method works perfectly fine for that, you can make something like an RTS using this, it's not just limited to UI
Ok, so I followed everything from your tutorial but when I change the res to anything other than FullHD the mouse for some reason gets trapped in a little square outside of canvas no matter what, probably due to the clamping on screenwidth we are doing on lateupdate, but still after doing the scaling part(I did the whole video) it still doesn't work. But when I return to FullHD it works fine and the mouse stays inside the regular canvas. I have no idea why, any suggestions?
Did you apply the division based on the Canvas localScale? Did you position and anchor the virtual cursor game object correctly?
You can download the project files linked in the description and compare with your own
I have the same issue, it doesn't work on Screen Space - Camera, beause the canvas isn't scaling in this mode@@CodeMonkeyUnity
Polishing the game will never end...)))
Big fan
1 week ago i was struggling with this, the documentation for the virtual mouse is REALLY BAD, i struggled to find something
Yeah it took me a while to figure out all the issues I encountered, hopefully this video helps!
Is anyone else getting "Could not find active control after binding resolution" errors when enabling/disabling the virtual mouse game object? Edit: Just... dont upgrade to higher versions. I was using input system version 1.7. I downgraded to 1.3 and it fixed itself. yeahy!
How to implement this with the ui toolkit
Not sure, I've researched it but haven't used it much myself
I am using UI Toolkit and I was able to just add a canvas to my scene and follow the tutorial. I'm not sure if that's the "best" way but it works.
Sounds like Unity has a lot of Bugs to fix…
if the work only with the new input system this system method it not for my
the main reason i dont use the new input system is because the new input system Das not support therd patty controller's the support only ps4, Xinput, and maby switch controller
the old input system on the other hand support every controller
this one off the reason that in my game i will make sure use the old input system and i will make bindings the order make sure the player able to use whatever controller the wand and set up buttons in the order to work
in the option i have both but i don't i will use new input system Mach in my game at least not for the controller's
Are you sure about that? Have you used the Input debugger? Unless you have some really exotic strange controllers they should definitely be supported.
@@CodeMonkeyUnity yes have use the debugger and I'm able to add the thos spefic therd party controllers im using if wand to
the problem is that as far im award if someone use different there'd party controllers that is very likely i will still not work,
the other issue is as fa I'm awerd even wand to add apis controller apis for popular therd party controllers im not able to do that,
the only way to support only therd party controllers with the new input system is,
to those connected controller in my computer at this time or to use the ones already support with the new input system (xinput, ps4,ps5 ect)
in my game controller is very important,
in my game i wand the up 4 player for each computer,
in the order to achieve that in need to perfect controller support and i personally dont except people to have multiple official controllers
and because have option to 4 for player with split screen it very important to support every therd party controller for the get go,
event if the need to changes the default button layout wean shaman use the therd party controllers and the old system support every there'd party controllers because the find thos button layout for the windows directly unlike the new input system
How to: Virtual Mouse with Gamepad
Answer: Don't, just use the event handler (I don't like virtual mice, they can be hard to control)
Personally I quite like them, they're pretty easy to control as long as you set up the speed correctly and make the buttons with a good size
I guess that is fair, usually game companies slap it on to obnoxiously complex and tight UI because they couldn't be bothered to order the buttons@@CodeMonkeyUnity
I mean, there are very few "Don'ts" when it comes to game dev, Never unlock the players physic rotation you say? Yet adding a little tilt when you strafe feels fun and responsive. Never ever use default materials for everything? Yet if you decide to render things based on distance and their colliders then all the sudden you have best-seller.
I guess these "DO NEVER"'s are the same as chromatics in music or dissonant chords, you are told Never ever ever harmonize a B, a C, and a C#, yet you see Beethoven chew that rule up and spit out masterpieces. Like a spice, it can be misused and ruin a dish, but with the right execution it can make it legendary.
first
14 min ago
fist