Super Easy DRAG and DROP Unity Tutorial

  Рет қаралды 30,653

BMo

BMo

2 жыл бұрын

In practically 3 lines of code, learn how to add Drag and Drop mechanics into your game by allowing you to use your mouse to click on a GameObject, drag them to a new position, let go of the mouse button and their position will update.
✨Want to support the channel?
Buy me a coffee ☕: ko-fi.com/bmoli
➤SUBSCRIBE to inflate my ego with a bigger number 💖
➤LIKE the video to help the algorithm or I'll drag & drop you
➤Join our DISCORD SERVER and be best friends: / discord
Thanks for watching!
#unity #tutorial #bmo

Пікірлер: 48
@i_am_set
@i_am_set 2 жыл бұрын
Bro! You’re scaring me with how accurate these tutorials are with my needs. Literally have “drag & drop” next on my todo list that I’m gonna do tomorrow! I’m happy to see I’ll have a trusted tutorial to follow for it. The timing is impeccable
@mosquito4504
@mosquito4504 2 жыл бұрын
TRUE XDDDDD
@infinitebeats6444
@infinitebeats6444 2 жыл бұрын
He's defo stalking your thoughts lol
@joey7061
@joey7061 Жыл бұрын
@@mosquito4504
@benjaminchristl5283
@benjaminchristl5283 2 жыл бұрын
Your short tutorials reignited my interest in making games. They are very helpful and short so it is always easy to find exactly the tutorials i need. But I will watch all new videos regardless if i need them or not :D Keep em coming 👍
@stefansigurdsson2146
@stefansigurdsson2146 2 жыл бұрын
I love how concise these videos are, makes learning really easy and fun!
@stashatstake
@stashatstake Жыл бұрын
Nice video, man. Kept it really concise, very important in game dev in my opinion. And the overall tone of the video was also light and refreshing
@ivandamyanov
@ivandamyanov Жыл бұрын
I was wondering why a super basic tutorial wouldn't work for me, I found out about Perspective and Ortographic cameras and how you need to use a Raycast instead if using the Perspective camera for this to work. Thanks for the video, it's down to the point!
@ripdoxyyy
@ripdoxyyy 2 жыл бұрын
Sir, your content is way too good. From your explanations to keeping the videos short yet informative, you may be the most helpful channel I've ever found.
@hirejeffwu
@hirejeffwu 7 ай бұрын
Great tutorial, thank you! For anyone that wasn't able to get this to work, make sure your camera projection type is set to "Orthographic".
@noopsink_piano
@noopsink_piano Жыл бұрын
Thank you so much for the quick and concise tutorial :D
@joshstephenson9711
@joshstephenson9711 Жыл бұрын
Excellent editing, pacing, etc. All tutorial-makers can learn from this.
@SelaMalka
@SelaMalka Жыл бұрын
Super helpful video as usual, thank you!
@dailycompute
@dailycompute Жыл бұрын
Absolutely perfect! Thank you!
@vapoman4034
@vapoman4034 2 жыл бұрын
Thanks for this tutorial : Simple, clear and well explain. , that's why I already subscribe !
@lukamuller7305
@lukamuller7305 Жыл бұрын
Amazing Tutorial Thanks !
@pt3012
@pt3012 2 жыл бұрын
Ok, that last part with the subscribe was really funny! :D But I already did, so you should add an ELSE method for such cases too.
@manumap782
@manumap782 2 жыл бұрын
Big thank you!!
@CodeLaniakea-tf5no
@CodeLaniakea-tf5no 9 ай бұрын
Thank You! You save my time!
@mandamoon9149
@mandamoon9149 2 жыл бұрын
Dropping on comment here for this scrumptious tutorial 🤤
@beamlaku
@beamlaku Жыл бұрын
Easy and helpful tutorial. plus creative and funny way to ask for subscribing. 👍👍
@evilmurlock
@evilmurlock Жыл бұрын
when you draged the subscribe from out of screen that was so funy I died. Also thanks for the turorial, i tried some other interface for drag and droping, but I think that only worked with UI elements, so this was exactly what I needed.
@LuizMoratelli
@LuizMoratelli 2 жыл бұрын
Wow, I used something like this today, but I have a lot of issues using a Perspective Camera with 90 degrees of rotation in X axis and dragging an object inside a Parent with the same rotation of the camera. By the end I need to change the Camera to Ortographic and compensate the Y axis.
@KaranDas69
@KaranDas69 Жыл бұрын
Thanks ♥️
@squarepris1m203
@squarepris1m203 6 ай бұрын
great tutorial, anyone know if theres a way you can make it so it cant go out of a specified area?
@electricshade1861
@electricshade1861 2 жыл бұрын
Nice
@Stompin40
@Stompin40 2 жыл бұрын
Wow!
@cardario5323
@cardario5323 2 жыл бұрын
omg finally someone made something without using UI
@gabrieldj8191
@gabrieldj8191 7 ай бұрын
Add rigid body and box collider 2d for a pretty cool physics engine.
@mosquito4504
@mosquito4504 2 жыл бұрын
Is there way to drag something using different button instead of mouse button? For example i want to drag my object by using "=" key
@bossmanduty916
@bossmanduty916 Жыл бұрын
how do you make it so that the drag and drop item doesn't go through the walls if you try drag it through the walls
@TheZamphire
@TheZamphire 2 жыл бұрын
I wonder im messing with a 3d platformer is there a way to stop physics from building up so an object does not slam down or bounce super high or carry momentum when you let go?
@pt3012
@pt3012 2 жыл бұрын
I guess that's due to the rigidbody. Maybe you could set it to kinematic when the mouse is dragging and add an OnMouseUp additionally, where you set the kinematic to false again. docs.unity3d.com/ScriptReference/Rigidbody-isKinematic.html
@TheZamphire
@TheZamphire 2 жыл бұрын
@@pt3012Thank you, ill try that in the morning
@Sagardeep_Das
@Sagardeep_Das 10 ай бұрын
Help. After executing the code in script I can move my objects only vertically not all the way around background. Edit - Problem Solved. I need to click on the blue box to drag anywhere. Thanks so much for this tutorial.
@TransGuyShane
@TransGuyShane 2 жыл бұрын
Does this work on buttons for mobile games? If not , is there a way to modify it so it does work for mobile? I'm working on a game for my niece, this is perfect for my game but the game is going to be for her tablet, not a pc. I suck at coding so sorry if this is super easy and I'm just being stupid but I'd love to know :)
@max.playsgames
@max.playsgames 2 жыл бұрын
not 100% sure, but maybe something like touchphase could work for that, although from memory even if you do mouse it still works for touch anyway but id say you can definitely find a way to use this for a tablet game with one of those options
@TransGuyShane
@TransGuyShane 2 жыл бұрын
@@max.playsgames thank you :) I will look into that :)
@user-cq6lx3vx9d
@user-cq6lx3vx9d 5 ай бұрын
will it work if Rigidbody is added?!
@cardario5323
@cardario5323 2 жыл бұрын
hey does this work in 3d too?
@Hassanali-jr4yb
@Hassanali-jr4yb 10 ай бұрын
does this will work on mobile too ?
@NotASpyReally
@NotASpyReally 2 жыл бұрын
This is great but it doesn't work well in 3D :(
@SmellGrow
@SmellGrow 11 ай бұрын
It won’t work why is it going -20 in z
@user-rj4ef8dv9o
@user-rj4ef8dv9o 6 ай бұрын
I spent several hours but couldn't do this whti Visual Scripting...omg!
@m4ank
@m4ank Жыл бұрын
this -dosent- fucking work -please help-
@owen22s19
@owen22s19 Жыл бұрын
how did you get it to word
@XusermrX
@XusermrX Жыл бұрын
Here is the code to copy and paste: using System.Collections; using System.Collections.Generic; using UnityEngine; public class draggable : MonoBehaviour { Vector3 mousePositionOffset; private Vector3 GetMouseWorldPosition() { //capture mouse position & return WorldPoint return Camera.main.ScreenToWorldPoint(Input.mousePosition); } private void OnMouseDown() { //Capture the mouse offset mousePositionOffset = gameObject.transform.position - GetMouseWorldPosition(); } private void OnMouseDrag() { transform.position = GetMouseWorldPosition() + mousePositionOffset; } }
@InanimateJR
@InanimateJR Жыл бұрын
^^ This needs a pin
How to Make An Enemy Chase The Player in Unity
6:45
BMo
Рет қаралды 41 М.
Как реализовать Drag and Drop в Unity UI?
16:32
Лавка Разработчика
Рет қаралды 15 М.
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
Coding Adventure: Chess
29:22
Sebastian Lague
Рет қаралды 3,7 МЛН
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 94 М.
Drag and drop in Unity UI - create your own inventory UI!
12:47
Coco Code
Рет қаралды 100 М.
Drag and Drop with New Input system! ( Touch and Mouse )
11:41
Game Dev Geeks
Рет қаралды 10 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 520 М.
I Made A Platformer Game But You're The Enemy
6:12
BMo
Рет қаралды 474 М.
Flexible LOOT SYSTEM in Unity with Random Drop Rates
13:24
How to make a drag and drop game in Unity
19:29
Tarodev
Рет қаралды 49 М.
Simple Drag And Drop System | Unity 3D Tutorial For Beginners
6:47
User1 Productions
Рет қаралды 2,7 М.