Custom Cursor with Input System - Unity Tutorial

  Рет қаралды 25,526

samyam

samyam

Күн бұрын

Пікірлер: 86
@eamartig
@eamartig 4 жыл бұрын
This channel is so underrated. This is easily the best Unity tutorial channel for beginners on KZbin.
@samyam
@samyam 4 жыл бұрын
Glad you like it :)!
@brainwavestobinary
@brainwavestobinary 4 жыл бұрын
I agree. Cool thing is that the channel has more than doubled subscribers in the last 30 days (according to SocialBlade), so people are noticing. Hopefully it keeps up.
@samyam
@samyam 4 жыл бұрын
Thank you! 😁
@BarcelonaMove
@BarcelonaMove 2 жыл бұрын
I love how she moves the mouse around the thing while explaining it. It shows a lot of enthusiasm about the topic.
@samyam
@samyam 2 жыл бұрын
Some people were complaining about it so I’ve stopped doing it as much in my more recent videos 🤣 Glad someone liked it!
@MasonWolf90
@MasonWolf90 6 ай бұрын
Thanks! I have watched so many different videos and none of them worked, but this video was straight to the point.
@kamranbigdely
@kamranbigdely 2 жыл бұрын
Thanks!
@samyam
@samyam 2 жыл бұрын
Thanks so much for the donation!! :D
@CrunchyClub2020
@CrunchyClub2020 4 жыл бұрын
If you get a "Can't add script error" it's because line 5 of the code after "public class" needs to be the same name as whatever the script is. This is my second day of unity and I renamed the script after I made it so the names didn't match. Awesome video, thanks for NOT including 10 minutes of fluffy BS.
@uhhhhh2672
@uhhhhh2672 Жыл бұрын
If you get an error message like me that says "`Cursor' does not contain a definition for `SetCursor'" its because you named your script "Cursor". Was banging my head against the wall trying to figure it out. Dont be like me, name your script appropriately lmao
@ceciliacecchet5869
@ceciliacecchet5869 Жыл бұрын
same here, but I named the input control "cursor"
@pineneedle116
@pineneedle116 8 ай бұрын
I did neither of these and am having the same issue?
@anaribeiro9471
@anaribeiro9471 3 жыл бұрын
This is the best tutorials I have seen for UNITY. Well done! And thank you so much for this great content.
@samyam
@samyam 3 жыл бұрын
Thank you!! 😄
@moandtell
@moandtell 3 жыл бұрын
Thank you so much for this video! I've learned so much in just the first half alone! This is my first step to building a game, and it feels really good to see something actually working when I press play!
@kaloshabuthapa3284
@kaloshabuthapa3284 2 жыл бұрын
When writing script, for start function, 7:47, controls.Mouse.Click.started, my script has error: “CursorControl does not contain a definition for “Mouse” . There was an option for MouseActionMap, are they the same ? How to fix this error?
@Klash120
@Klash120 2 жыл бұрын
I'm stuck at that part too :x
@Klash120
@Klash120 2 жыл бұрын
Figured it out right as I left a comment! I was using my own naming for variables & such, User error! If you've done the same, check your input action naming. Name of variable you've set (control), Action Map name (mouse), and Action (Click). Control.mouse.click; If you use the default mapping that Unity makes, it'll be [your variable name].Player.click. Hope that helps~
@camillatomasetti2453
@camillatomasetti2453 5 ай бұрын
​@@Klash120 i have the same problem, but I don't quite understand what do you mean 😅 can you try to explaine better? Thank you!
@starwarsfan6868
@starwarsfan6868 2 жыл бұрын
Thank u so much for this video!!! It helps soooo much! You're really a good teacher!!!
@samyam
@samyam 2 жыл бұрын
Thank you so much!! Appreciate it 😁
@starwarsfan6868
@starwarsfan6868 2 жыл бұрын
The click doesnt work by me. There are no errors, but it just doesnt work! Any ideas why???
@georgigeorgiev5524
@georgigeorgiev5524 2 жыл бұрын
Thank you so much I needed this type of tutorial =D
@angiemon897
@angiemon897 2 ай бұрын
How do I make the cursor scale correctly with different resolutions? :(
@mantavisions2362
@mantavisions2362 3 жыл бұрын
THANK YOU! this saved me, i was struggling! haha
@grimonmilk7287
@grimonmilk7287 2 жыл бұрын
I get this error code when I try this "Assets\Pixel Cursors\CursorController.cs(24,6): error CS1513: } expected"
@alphaanar2651
@alphaanar2651 4 жыл бұрын
YAY! new video that explains stuff which l have no idea what is this :D
@vinipossatto9586
@vinipossatto9586 4 жыл бұрын
Nice video!
@chloefinlay9133
@chloefinlay9133 3 жыл бұрын
This is such a great and clear tutorial! I'm just wondering (as I am new to unity) if there's a way I can use this method to click my objects but also use the mouse to look around the environment also? Thank you for any help you can give :)
@samyam
@samyam 3 жыл бұрын
Awesome! Yes I have a follow up video for clicking kzbin.info/www/bejne/gHqnaIyXfaangaM and I have a video on panning and zooming around the scene with cinemachine kzbin.info/www/bejne/hqSkk3uld51onq8 And then if you want to bound your camera movement to a certain space here is another video kzbin.info/www/bejne/n6vYnouhYt2ie68 Lots of videos 😂
@chloefinlay9133
@chloefinlay9133 3 жыл бұрын
@@samyam Thank you so so much!
@klause2s
@klause2s Жыл бұрын
i have been informed by unity that "'Texture2D' does not contain a definition for 'SetCursor' and no accessible extension method 'SetCursor' accepting a first argument of type 'Texture2D' could be found (are you missing a using directive or an assembly reference?)" can you provide assistance? would be appreciated
@IronIsFun
@IronIsFun Жыл бұрын
Same issue, don't know how to fix it. Did you find a solution
@klause2s
@klause2s Жыл бұрын
i have not, i've since moved away from unity and toward gamemaker
@t33h33studio
@t33h33studio 5 ай бұрын
Unfortunately, SetCursor is unusable for me. At first I thought I made a bug, but SetCursor simply does not change my cursor at times. I am not alone in this issue as people have stated this function to be unreliable for years. The OS wants to fight Unity for control.
@HdmiFly
@HdmiFly 2 жыл бұрын
My imported cursor only appears once I hit escape. Any ideas?
@rbanister100
@rbanister100 4 жыл бұрын
the buDIN, as opposed to button
@jianingzhuang104
@jianingzhuang104 3 жыл бұрын
Nice video! May I ask if we can resize the cursor using script? Thanks.
@samyam
@samyam 3 жыл бұрын
32x32 texture for cursor is required, however according to this forum you can possibly resize the actual pixels of the texture: forum.unity.com/threads/cursor-size.288333/#:~:text=If%20you%20want%20to%20resize,is%20just%20taking%20up%20memory. Or you can ignore this method and have an empty gameobject with a sprite cursor and have that follow your mouse movement
@jianingzhuang104
@jianingzhuang104 3 жыл бұрын
@@samyam Thank you very much!
@fluorescente
@fluorescente 2 жыл бұрын
silly question here but... how to make a 3D object automatically rotating like an idle state?
@samyam
@samyam 2 жыл бұрын
so rotate around the y axis? In the update method you can call RotateAround similar to the example here docs.unity3d.com/ScriptReference/Transform.RotateAround.html
@fluorescente
@fluorescente 2 жыл бұрын
@@samyam thank you! I knew it had to be easy! I'm just new to Unity ^_^
@fernandomilans8444
@fernandomilans8444 4 жыл бұрын
hi, i was thinking of changing my project's implementation of inputs to 'input system', but is it worth it? I say, 'input system' is in version 1.0, so I imagine there will be annoying bugs, I saw the documentation but I do not realize the great advantages over doing it the 'traditional' way. What is your opinion at the time of practice, what 'great advantages' you see in 'input system'. Thanks, and very good videos, greetings!
@samyam
@samyam 4 жыл бұрын
I recommend it, super simple to set up and you can easily change controls for different systems as well as allow multiple controls for one action.
@kaydnshepard8131
@kaydnshepard8131 4 жыл бұрын
I changed this Input System and my whole Game crashed. Now reinstalling Unity and hope that I can fix this =/ but anyway I learned how to change my curser.
@samyam
@samyam 4 жыл бұрын
😅 remember to back up your project!
@kaydnshepard8131
@kaydnshepard8131 4 жыл бұрын
@@samyam yeah sure 😋, lesson learned. But I will see it as a second chance to start my game new with better codes and graphics. I was not that far with the game 🖖🏼
@iamnotcreativeenoughforana5875
@iamnotcreativeenoughforana5875 3 жыл бұрын
Can anyone help me? I'm trying to lock the cursor in the middle of the screen with having it stay visible, is there a way to do this?
@samyam
@samyam 3 жыл бұрын
Hm why would you want to do this? It’ll make the player feel as if they can’t move the mouse. To lock it in the middle you can use Cursor.lockState = CursorLockMode.Locked; And if you want something to show in the middle you can add a sprite to the center of the screen
@functionSam
@functionSam 3 жыл бұрын
For using a mouse cursor in a menu system, would "release only" be suitable? I'm trying to create a mouse interaction that feels "natural" (at least in a menu to start)
@samyam
@samyam 3 жыл бұрын
Yes I think release would be suitable, you can always test or ask someone to test to see how it feels.
@roland_art
@roland_art 4 жыл бұрын
Useful, thanks! If I can, how change (overlay) the color of cursor with c# script?
@samyam
@samyam 4 жыл бұрын
You could either take in another texture with the color you want or you'd have to change the color by going through each pixel of the texture 2d and changing the tint. gamedev.stackexchange.com/questions/124463/changing-some-color-of-a-texture-using-c-in-unity If you only have a mouse in your GUI you can apply a global GUI tint to change the color at that moment forum.unity.com/threads/dynamical-color-change-of-mouse-pointer.166366/
@roland_art
@roland_art 4 жыл бұрын
@@samyam Thank you!
@vladimirgalkin412
@vladimirgalkin412 3 жыл бұрын
Please. how to add trail effect on mouse cursor?
@samyam
@samyam 3 жыл бұрын
I show how to do a similar effect here: kzbin.info/www/bejne/jobbkISif9WXZq8 Basically add the trail renderer to a gameobject, then move the gameobject according to where the mouse is
@OutCold9te6
@OutCold9te6 3 жыл бұрын
I tried again with the Kenny assets and still nothing.
@OutCold9te6
@OutCold9te6 3 жыл бұрын
I just got it to work by restarting Unity. Does that mean Unity bugged out?
@samyam
@samyam 3 жыл бұрын
Maybe! Sometimes restarting fixes bugs and some issues
@OutCold9te6
@OutCold9te6 3 жыл бұрын
I tried this with a new 2d sprite, gave it type cursor , compression none, and set it as my cursor object's Cursor variable, and it didn't change my cursor.
@samyam
@samyam 3 жыл бұрын
Did you make sure to attach the script to a gameobject? Also try calling the SetCursor in the Start method instead to see if that helps.
@UnGaming-eh7ht
@UnGaming-eh7ht 4 жыл бұрын
Honestly curious what color theme you're using for vs code here
@samyam
@samyam 4 жыл бұрын
I'm using the Godot color theme 😂
@animationspace8550
@animationspace8550 4 жыл бұрын
Unity says I have no definition for "SetCursor" or "lockState" can you help out or let me have a finished scripted (my code barely comes out right)
@samyam
@samyam 4 жыл бұрын
Make sure you are putting Cursor.SetCursor and Cursor.lockState. The code is available for patrons in the description.
@HadiExtreme
@HadiExtreme 4 жыл бұрын
Oh I had this problem last month! If you haven't solved it already, check your script name. If you named it Cursor, then it would be overriding Unity's Cursor class, causing the problem.
@CodeWithMilk
@CodeWithMilk 2 жыл бұрын
@@HadiExtreme It was the excatly problem I had... thx!
@crusader1910
@crusader1910 4 жыл бұрын
My cursor is only pixels or a disstroted image. Any idea why?
@samyam
@samyam 4 жыл бұрын
It has to do with your import settings on the image. Make sure it is set to Texture2D for type and you can adjust the compression and filtering as well
@SankalpParab
@SankalpParab 3 жыл бұрын
how to interact with world space ui in cursor lock mode
@samyam
@samyam 3 жыл бұрын
That’s a little tricky it seems, you’ll have to simulate the mouse cursor if you lock it to see what UI it is over. You can also shoot raycasts and have the UI with colliders to detect if the ray hits the button. Here’s some threads that may help forum.unity.com/threads/world-space-canvas-cursorlockmode-locked-incompatible.566485/ forum.unity.com/threads/fake-mouse-position-in-4-6-ui-answered.283748/?_ga=2.160872958.255425762.1618484813-653284547.1617361468 stackoverflow.com/questions/38054706/alternative-of-raycast-for-ui-items-in-unity3d stackoverflow.com/questions/42384658/unity-ui-interacting-with-worldspace-ui-when-cursor-is-locked
@SankalpParab
@SankalpParab 3 жыл бұрын
@@samyam thank you so much for your suggestions ✌🏻😇
@eggwardosteve
@eggwardosteve 3 жыл бұрын
It really feels like the video went way too fast. It was really hard to keep up, even with having to pause the video
@samyam
@samyam 3 жыл бұрын
Sorry about that! I’ve been improving my pacing and speed in my more recent videos. Thanks for pointing it out!
@Swatgoezhigh
@Swatgoezhigh 3 жыл бұрын
controls.Enable(); and Disable() throws a NullReferenceException
@samyam
@samyam 3 жыл бұрын
Did you instantiate the controls? controls = new CursorControls();
@Swatgoezhigh
@Swatgoezhigh 3 жыл бұрын
@@samyam ok that helped :D
@srecky7822
@srecky7822 3 жыл бұрын
why does unity change the way their code works every 2 seconds? this tutorial doesn't work anymore
@samyam
@samyam 3 жыл бұрын
What do you mean? It should work. What issue are you having?
@fernandomilans8444
@fernandomilans8444 4 жыл бұрын
Hi! In the console it throws me-> InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. and is because i have in many sides -> Input.GetMouseButtonDown(0), so only solution is Setting Active Input Handling to "Both"?
@samyam
@samyam 4 жыл бұрын
Yes you should only be using the new input system if you enabled it, but you can switch to both to disable the errors
@Baby_Kangaroo43
@Baby_Kangaroo43 4 жыл бұрын
finally smthn useful
@14DimensionEnterprise
@14DimensionEnterprise 4 жыл бұрын
why you circling mouse cursor? too annoying
@samyam
@samyam 4 жыл бұрын
Yeah I know I need to work on that 😅 I don’t notice when I record
Local Multiplayer with NEW Input System - Unity Tutorial
15:12
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 134 М.
every step to actually make your dream game (then sell it)
24:27
Custom Cursors In Unity
3:52
bendux
Рет қаралды 50 М.
How to Rebind Your Controls in Unity (With Icons!) | Input System
20:29
Sasquatch B Studios
Рет қаралды 31 М.
Unity's NEW input system in 13 minutes
13:02
BiteMe Games
Рет қаралды 38 М.
HOW TO CUSTOMIZE YOUR MOUSE CURSOR - UNITY TUTORIAL
9:14
Blackthornprod
Рет қаралды 117 М.
Why you should switch to Unity's New Input System (and how easy it is)
9:51
Jason Weimann (GameDev)
Рет қаралды 34 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН