Amazing tutorial. Clear and to the point without sacrificing any needed explanations. You're a great teacher. I'm working on my first project in Unity and you answered so many questions for me. Thanks for taking the time to make videos and sharing them with all of us.
Good tutorial. Some of these functions are really obtuse and impossible to figure out without good documentation or tutorial. I mean, for example why do they store whether the mouse button is clicked or not as a float of all things? As if there are any analog mouse buttons...
Hi Samyam,, Great tutorial - it's clear, to the point and well-conceived. Keep up the good work! Quick question - How can I use this script on an imported OBJ object? It works fine with native Unity objects but does not seem to work ( at least for me ) with imported ones. Any help would be appreciated.
Thanks a LOT for this video, I was looking exactly for how to work out this functionality on the new Input system. This video was so well layered out and explained, that not only it gave me a lot of insight about the subject, but also really specific techniques while at it as well! Really appreciated!
hi i tried posting in your discord server but i copied the code and debugged the raycast, but the raycast isnt hitting anything, would you happen to know why that is?
Thanks again. Your vid start out with great topics, but often lean into needless complexity. Good vid, but tmi for grasping input systems usefully. This example would change the flow of most code but beggars aught not be choosers,. >KISS > 1.Keep.2.It.3.Simple.4.Stupid!
This was very well explained and although quite up-tempo, very informative. I understood your code fully and was able to replicate it. I'm not sure I'd be able to do it on my own though. How do you get this good at this?
You can replace the mouse coordinates with your finger coordinates! I have a video here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ERAN5KBy2Gs.html
@@samyam If I do that, will I be able to drag multiple objects then at the same time using multiple fingers? I want to know before I start implementing that.
Awesome stuff, but I have a question: if we want to not move object along depth axis, eg z how to do that? Get angle between last two rays and using trigonometry get new position of object?
If you aren’t using physics you can set the z position to equal the previous z position of the object. If physics you can lock the Z movement constraint in the Rigidbody component settings docs.unity3d.com/ScriptReference/Rigidbody-constraints.html
@@samyam I think I didn't explain it fully: the main problem is if you lock depth axis movement of dragged item, it is not fully following cursor, the farther you go towards edges the more it stays behind. My assumption was it is because ray should become longer if you move from center of screen towards edges That's why I thought I have to use some geometry algebra . Am I correct?
My MousePressed() function just doesn't trigger. mouseClick.performed doesn't trigger? I put Debug.Log("!") in the function and it keeps silence (( Can't figure out where is the problem :(
How do stop from being able to fling items across the map? For instance I want it so that as soon as I stop dragging, the item stops and drops to the floor.
Hi, thank you for this video, very useful. I just have a little problem, I can drag the floor which has no tag, no layer, no script. Can't find why, my "if"s look like yours. M. D.
Amazing tutorial, thank you so much. However, I keep having this error with your script....:Assets\DragandDrop.cs(7,6): error CS0246: The type or namespace name 'Serializefield' could not be found (are you missing a using directive or an assembly reference?) And when I use public variables instead, it does seem to work, but at once I fall through my terrain when I click on any layer other than draggable... Would anyone have a suggestion?
Thanks! You can access other mouse properties, here’s a list: docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.Mouse.html And change the transform of the object respectively. Or you can use an Input Action Asset to store your actions and then read those values ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-m5WsmlEOFiA.html
You'll need to add touch input to your actions, I have a video on Touch Input that might help you: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-ERAN5KBy2Gs.html