Unity Tutorial | Clicking and Dragging 2D Sprites

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

Nade

Nade

5 жыл бұрын

Hey all! I really hope some of you find this tutorial helpful in your own projects, as figuring it out for my own project was a great feeling. Thank you guys so much for watching!!

Пікірлер: 174
@marcelafregatto3456
@marcelafregatto3456 4 жыл бұрын
Concise, simple and informative. Your explanation of the code was very useful. Thank you for the great tutorial!
@benmessenger9697
@benmessenger9697 4 жыл бұрын
Thanks for ths. I'm brand new to Unity and this was very helpful. ALmost everything else I found had probably great scripts but none of them explained how to apply them. I had 2D rigid bosies, 3D rigid bodies, etc etc. Yours is the only one that explained it from the start, which made me realise I only needed a 2D box collider.
@steamingHOTsomething
@steamingHOTsomething 3 жыл бұрын
Thank you for describing what the code does in addition to showing us how to do this. It really helps with understanding the whole concept.
@davidgentry5971
@davidgentry5971 Жыл бұрын
Thank you! I have been trying for days to get a click and drag method to work and yours is the first. Great tutorial!
@supgamen5832
@supgamen5832 4 жыл бұрын
Thank you so much it took me forever to find a video that worked I spent to hours just looking around on KZfaq thank you so much I really needed this your the best bro looking forward to more great videos
@OldJobobo
@OldJobobo 2 жыл бұрын
Super awesome this is exactly what I needed and worked with very minor changes. Thank you so much.
@_.emberrr
@_.emberrr 2 жыл бұрын
DUDE THANK YOU SO MUCH YOU DONT KNOW HOW MUCH I WANT TO THANK YOU IVE BEEN TRYING TO SEARCH FOR THIS FOR SO LONG THANK YOU THANK YOU
@cerielgerrits781
@cerielgerrits781 2 жыл бұрын
Very clear and helpful Nade, thanks.
@austinthewotter
@austinthewotter 4 жыл бұрын
Very nicely made and easy to follow. Thanks much.
@shahriarahmed728
@shahriarahmed728 3 жыл бұрын
Fantastic tutorial. Very clear one & you made it easy to understand :)
@chadhurley2046
@chadhurley2046 5 жыл бұрын
Great tutorial, man!!
@hairy_harrison
@hairy_harrison 5 жыл бұрын
Thanks for tutorial. It was great!
@amandaflood
@amandaflood 2 жыл бұрын
Thanks, very helpful and I like how you explain the code 😊
@Gernata_Dev
@Gernata_Dev 3 жыл бұрын
thanks man !!! great tutorial
@cleotheocelot2413
@cleotheocelot2413 4 жыл бұрын
Very good tutorial it really helped me keep up good content
@cormacconnell6961
@cormacconnell6961 4 жыл бұрын
Very helpful, thanks!
@arisaek7764
@arisaek7764 Жыл бұрын
A very helpful tutorial, this one is
@paolomontini919
@paolomontini919 4 жыл бұрын
Best tutorial out there! :D
@projectoedit
@projectoedit 2 ай бұрын
Very good code! Very good explanation!
@gold3ngam3s84
@gold3ngam3s84 4 жыл бұрын
great content, this saved me a lot of time. :D
@peanutman5221
@peanutman5221 Жыл бұрын
Thx soo much your a life saver my guy 🙏
@MDweller
@MDweller 3 жыл бұрын
good job man. it help me a lot. thankyou
@rankoooo
@rankoooo Жыл бұрын
Thx bro, it dose help a lot
@djpersonalspace2406
@djpersonalspace2406 4 жыл бұрын
Best tutorial I've seen on this - how would i ensure that the objects are only moved within certain boundaries??
@ainurmaisarah8381
@ainurmaisarah8381 4 жыл бұрын
thank you for the tutorial.
@marcusfromoz7066
@marcusfromoz7066 3 жыл бұрын
I've watched a lot of code tutorials in the last 12 months and your manner in this one is one of the best. Subscribed based on this video and will browse for any others I find useful. Thank you. By manner I mean you spoke clearly, you didn't stop/start to think things through, you clearly had it well planned out prior and you focused on making it as concise as possible.
@banane2186
@banane2186 3 жыл бұрын
.
@sipsopgamera7624
@sipsopgamera7624 4 жыл бұрын
Thanks, you helped for a jam. My only feedback is to put the starpos varibles after we see the snaping issue so it is more clear. But still great video
@karacter3369
@karacter3369 2 жыл бұрын
i like your tutorial a lot
@qwertykeyasmr6453
@qwertykeyasmr6453 4 жыл бұрын
Thanks a lot. New subscriber gained
@scottlittle934
@scottlittle934 5 жыл бұрын
THIS WAS A FREAKIN' LIFE SAVER!!! Thank you so much for making this tutorial and explaining everything so well. I'm a junior in college working toward my degree in game design and development and I'm in the middle of an experimental design challenge for class where I've got 2 weeks to make a game on my own, but I've got a week left since I was having a hard time coming up with an idea. Luckily, I thought of one a couple days ago and it hinged on drag and drop which I've never done before and everything I was finding either didn't explain it nearly as well as you and made it sound more complicated than this which left me more confused and until I found your video I was starting to think that it might be outta scope for the time I have left and that I'd be screwed. So, I just wanted to make sure I took the time to let you know how much I appreciate your help, and I'll try to remember to send you a message with with a link the finished game when it's done :D
@Faithexx
@Faithexx 2 жыл бұрын
2 years later.. how'd the project end up going? ;D
@user-eq6oy1um7e
@user-eq6oy1um7e 4 жыл бұрын
Great! I am a baby at coding but this is fairly simple.
@NotASpyReally
@NotASpyReally 4 жыл бұрын
Thank you SO MUCH for this !!! I liked and subscribed!
@Kutayeen
@Kutayeen 4 жыл бұрын
A day just searched this, at least find it thanks a lot.
@residentsicko
@residentsicko 4 жыл бұрын
Great Info. I have a question/request for you if you'll indulge me. How would I implement a click and drag like this but also just a quick click with the same button triggers another event? Obviously so the event doesn't trigger when I click AND drag.
@azur7362
@azur7362 3 жыл бұрын
I am making a chain with multiple links, and I've watched turotials on it and gotten it together. Now i want to move the top part of the chain, but when I do, the whole thing disconnects from the part i grab. Any help?
@DonGT
@DonGT 4 жыл бұрын
Question how can I make it so you can rotate the object by spinning it whilst holding it.. I have rigidbody2d on the object and stuff idk
@yced101
@yced101 3 жыл бұрын
excellent. THX
@DonGT
@DonGT 4 жыл бұрын
Could I add a rigidbody 2d to make it flail around , also how would (okay so I have this minigame in my game that has you drag your character around and fall but how would i make it so that only his arms and legs flail but his head and body stay still)
@izzaacalley
@izzaacalley 3 жыл бұрын
is there a way i could make it to where when i drag it over another object that can be dragged it only drags the one on top?
@Nathan-pe8kc
@Nathan-pe8kc 4 ай бұрын
what if you wanted gravity to affect the sprite, so that once you release the mouse button it falls back to the ground?
@Toopa88
@Toopa88 4 жыл бұрын
5:45 isn't OnMouseDown() only called on left mouse clicks to begin with?
@NadeOnRust
@NadeOnRust 5 жыл бұрын
Hey all! As of now, I cannot create community posts for all of you to see until I have 1,000+ subs, so to see a video schedule of each week, and to post suggestions, please click the "Discussion" tab of my channel to check that out. Thanks!!
@Empriction
@Empriction 4 жыл бұрын
Just did everything, and when i try to click and drag, nothing happens? What did I do wrong? I included box colider and attached C# file to my sprite
@MrGidorMr
@MrGidorMr 4 жыл бұрын
Me too
@klaudijuspupsys3446
@klaudijuspupsys3446 4 жыл бұрын
@@MrGidorMr @Empriction Input.GetMouseButtonDown(0) seem to be the problem for me. This explains why docs.unity3d.com/ScriptReference/Input.GetMouseButtonUp.html?_ga=2.96919455.1894432741.1592407429-119814026.1592407429
@ceeperderptoad2775
@ceeperderptoad2775 4 жыл бұрын
@@klaudijuspupsys3446 so remove it?
@klaudijuspupsys3446
@klaudijuspupsys3446 4 жыл бұрын
@@ceeperderptoad2775 Yeah. Method OnMouseDown() is triggered by left mouse button. Use method OnMouseOver() if you want to choose which mouse button to click. private void OnMouseOver() { if (Input.GetMouseButtonDown(0)) Debug.Log("Pressed left click."); if (Input.GetMouseButtonDown(1)) Debug.Log("Pressed right click."); if (Input.GetMouseButtonDown(2)) Debug.Log("Pressed middle click."); }
@ceeperderptoad2775
@ceeperderptoad2775 4 жыл бұрын
@@klaudijuspupsys3446 thanks I also wrote some code somewhere in the comments and got an error I'm super new to unity as I started I think 4 days ago. If you can help with this too that would be amazing.
@mitar8106
@mitar8106 4 жыл бұрын
Bravo!
@bottleflips3617
@bottleflips3617 4 жыл бұрын
It’s working all except for when I release the mouse button the sprite doesn’t release, any idea why? I’m very new to this so it’s probably a stupid mistake
@letsplaynay9936
@letsplaynay9936 4 жыл бұрын
Thanks!
@hippolox5435
@hippolox5435 2 жыл бұрын
so one problem. When i give the item a rigidbody the velocity just keeps speeding up if held leading to some umm.... large events
@cerealboxgaming4349
@cerealboxgaming4349 2 жыл бұрын
How can i do this with rigidbody, and a collider? the rigidbody acts weird (spinning randomly) and the colliders don't work. (going through other objects with colliders) i would like this for my game death simulator.
@EdwardFominykh
@EdwardFominykh 2 жыл бұрын
Any ideas on how to preserve velocity when you let go?
@ceeperderptoad2775
@ceeperderptoad2775 4 жыл бұрын
Edit: it was fixed but is there a way to add this to a ragdoll?
@vressentials
@vressentials 3 жыл бұрын
Hi There, thanks for the video, unfortunately the Object I assigned the Script to moves after game start and am not able to move it whatsoever...no errors showing after tagging the Main Camera.
@vressentials
@vressentials 3 жыл бұрын
Remember tag camera to MainCamera in the inspector or it'll say Null Object....
@zamanyolcusu1586
@zamanyolcusu1586 3 жыл бұрын
How can we use this kind of control on more objects using the tag function?
@Darkziss0
@Darkziss0 Жыл бұрын
Thank!
@sterling709
@sterling709 2 жыл бұрын
the final part is good, where we have this startposx and y , to avoid sudden snap middle. thanks
@DSFtfghjfgf
@DSFtfghjfgf 3 жыл бұрын
Everytime I type in the code it says somethings wrong I clicked it and It says theres an error on the 10th layer when nothing was there just the void Start thing. nevermind
@molecular_master
@molecular_master 3 жыл бұрын
Hey Nade! Can you tell me how to do this with rigidbody? I want to register collision so the dragged object won't go through another one
@ViralGymClips874
@ViralGymClips874 3 жыл бұрын
Same
@MenaRamyEnaeet2512
@MenaRamyEnaeet2512 3 жыл бұрын
Hey I sat Time.timeScale To zero and if I clicked the object and drag it to another position and tried to move it again it doesn't move solution please and Thank you for that awesome tutorial.
@deliriousmansano3556
@deliriousmansano3556 4 жыл бұрын
Why theres is no monobehaviour. OnMouseDown and Up even I have box collider 2d??
@LEMNSQZY
@LEMNSQZY 5 жыл бұрын
Hey! I got this working for a sprite, but nothing seems to happen if this same process is applied to a UI image on a canvas. The box collider and script remain unchanged, it's just the type of gameobject. Do you have any suggestions on how to fix this?
@grubinski13
@grubinski13 4 жыл бұрын
I would like to know the same thing! Did you figure it out ?
@cricketfandom9089
@cricketfandom9089 3 жыл бұрын
kzfaq.info/get/bejne/eK2iYJp4v7CyiJs.html
@DavidAdochiti
@DavidAdochiti 2 жыл бұрын
how can i maek it so that if i dont drag the object to the correct place, it goes back to its original position??
@user-iq4pc8ns9y
@user-iq4pc8ns9y 4 жыл бұрын
tell me how to make it all work with the camera in perspective mode?
@youtuberyoutuber2495
@youtuberyoutuber2495 4 жыл бұрын
I have a video request: It will build on this one. The request is, after taking your finger off the object, it is permanently placed, so you can't click on it to move it again. And in the same video, add an icon so we can delete any object on the scene after clicking on the object.
@younessaitouaddi2268
@younessaitouaddi2268 3 жыл бұрын
nice
@lex2763
@lex2763 4 жыл бұрын
Thanks for the great tutorial. I just had one question... When I am using this C# script the movement of the sprite lags behind the movement of the mouse (doesn't happen in your video)... I was wondering if you/anyone knows how to solve this?
@stuff3862
@stuff3862 4 жыл бұрын
I think you have to set it so its not updating per frame or something and is just updating independent, I'll see if I can find it.
@yalld
@yalld 4 жыл бұрын
Any updates on how to fix this issue? I am having the same difficulties.
@windowsmoke
@windowsmoke 4 жыл бұрын
@@yalld in the on mouse down void, change the line to "startPosX = mousePos.x * 130 - this.transform.loc...... Then do the same for y, mine is 70 (these are the numbers that work for me you might have a different number.) Next go to the update void and in the if function add the * 130 after mousePos.x and do the same for mousePos.y
@bikelovers5039
@bikelovers5039 3 жыл бұрын
I also have this problem . Please tell me if you got solution ?
@bikelovers5039
@bikelovers5039 3 жыл бұрын
@@yalld Sir i make a complete 2D game With this drag and drop method when our dragable objects quantity increase then it slow down drag movement under finger Very too much lag. Sir please Tell me i am fuck of on it for 10 days. But not find any solution ?
@vinodhbalakrishnan2726
@vinodhbalakrishnan2726 3 жыл бұрын
hi Nade, Its very useful video, but i have a question.. why do you add box collider to that sprite, without adding the collider can we move or drag the object, if not could you explain why?
@Umblizm
@Umblizm 11 ай бұрын
This comment was 2 years ago but better late than never. Basically it needs. The collider because without it, it’s just a sprite. Without that component it’s just an image on the screen, so when you add the collider, it lets you click and drag it because your actually dragging the collider, the sprite is just attached to it
@gilgusinsky2513
@gilgusinsky2513 4 жыл бұрын
If I wanted the rectangle to keep moving to the side a bit after I released, any tips on how that's done, I'm new to c#. What I want is to drag the square with mouse hold, then on release I want the square to keep moving to the side that you were dragging in, kinda like real life. I tried adding gravity to the square in unity but it only makes the square fall down
@gilgusinsky2513
@gilgusinsky2513 4 жыл бұрын
i figured in out! its void moveCharacter(Vector2 direction){ rb.AddForce(direction * speed); }
@0x19
@0x19 3 жыл бұрын
@@gilgusinsky2513 Make sure to do Rigidbody2D rb = getComponent(); and add the rb2d to the object, and disabling gravity!
@KoiMapache
@KoiMapache 3 жыл бұрын
gracias, me a servido
Жыл бұрын
Is it possible to make this for mobile?
@peterschrimpel9375
@peterschrimpel9375 3 жыл бұрын
thanks a lot
@harryfenteman6295
@harryfenteman6295 3 жыл бұрын
how would you snap them to a grid?
@topherblair5073
@topherblair5073 2 жыл бұрын
Does anyone here know how to get this to work with a perspective camera? Thanks
@lora6938
@lora6938 3 жыл бұрын
How to make a sprite come to the front on mouse click? Please 🙏
@WakeTheShark446
@WakeTheShark446 3 жыл бұрын
I should point out that this runs into issues if you have other colliders on the parent or any children as those will set off the OnMouseDown event.
@tommytomato4943
@tommytomato4943 3 жыл бұрын
i litteraly copied the code, but when i try it ingame it doenst work does any1 know why??????
@darredYouTube
@darredYouTube Жыл бұрын
Idk why but the script doesnt work. Without any errors. Just my gameObject doesnt want to work
@hansnystrompastor8690
@hansnystrompastor8690 4 жыл бұрын
Sorry, but when i drag the object it dosent seems to move under the cursor, instead, goes to the center of the screen, and kind of moves, but certainly not as it does on the video, any idea?
@hansnystrompastor8690
@hansnystrompastor8690 4 жыл бұрын
i was writing screentowievpoint by mistake loll D:
@letsplaynay9936
@letsplaynay9936 4 жыл бұрын
Is there a way when i drop the object, it moves with physics
@NadeOnRust
@NadeOnRust 4 жыл бұрын
Sure! Add a rigid body 2d, along with some sort of ground, and you can pick up and drop the sprite
@letsplaynay9936
@letsplaynay9936 4 жыл бұрын
Nade Oh thanks!
@TheLastApplePie
@TheLastApplePie 4 жыл бұрын
Please help, It doesn't work. like i checked every line of code i have and him. i see no difference and it doesn't really work. the script is also attached to the sprite as well
@giji3939
@giji3939 3 жыл бұрын
Probably too late, but does your sprite have a collider?
@ayush21399
@ayush21399 3 жыл бұрын
@@giji3939 in my, sprites jumps to center when clicked and don't move!!
@mymans1142
@mymans1142 3 жыл бұрын
How come when using OnClick events the gameObjects dont collide?? Even with a boxcollider? I'm trying to do a puzzle thing where the pieces are blocked by one another, but they aren't colliding. Anyone know why?
@lukasziesemer8252
@lukasziesemer8252 3 жыл бұрын
mabe because its always moving to the mouse and than it isnt working. Do you have a box collider, if yes is "is Trigger" active?
@elferchusmaymax8122
@elferchusmaymax8122 3 жыл бұрын
Did you solve it? I am trying something similar but I can't make it collide either
@tommytomato4943
@tommytomato4943 3 жыл бұрын
i think you need a rigidbody to actually touch
@rik0904
@rik0904 4 жыл бұрын
finnaly some one who don't use canvas
@tetnyrotun3993
@tetnyrotun3993 5 ай бұрын
i can still drag it even if i didnt put my mouse cursor on it, i just click on other spot and i can still drag it man
@mahirminhajk
@mahirminhajk 3 жыл бұрын
thazz love from India
@Chicano3000X
@Chicano3000X 4 жыл бұрын
When I click the object, it jumps to the corner of the canvas..
@spacevolvox4020
@spacevolvox4020 4 жыл бұрын
I had the same problem use this script by Artjom Schmitke private float startPosX; private float startPosY; private bool isBeingHeld = false; public bool isSnapping = false; private Vector3 mousePos; private void Update() { if(isBeingHeld == true) { GetMousePos(); if (isSnapping == false) gameObject.transform.localPosition = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY, 0); else if(isSnapping == true) gameObject.transform.localPosition = new Vector3(mousePos.x, mousePos.y, 0); } } private void OnMouseDown() { if(Input.GetMouseButtonDown(0)) { GetMousePos(); if (isSnapping == false) { startPosX = mousePos.x - transform.localPosition.x; startPosY = mousePos.y - transform.localPosition.y; } isBeingHeld = true; } } void GetMousePos() { mousePos = Input.mousePosition; mousePos = Camera.main.ScreenToWorldPoint(mousePos); } private void OnMouseUp() { isBeingHeld = false; }
@platypus4
@platypus4 2 жыл бұрын
It doesnt work if i click it it only goes 1+ up
@theredlord6178
@theredlord6178 3 жыл бұрын
hey guys I have a little problem and was wondering if someone could help me, when I am starting to drag the object it becomes invisible in the game. However I can still see it in the scene and in the scene its not invisible... its invisible only in the game and only after I start dragging it... any help?
@JAMGGameryTutorialesramdom
@JAMGGameryTutorialesramdom 3 жыл бұрын
may be are you updating the Z value of the object so it moves the object out of the camera vision?? can be xD that's why the value for "Z = 0" no moves
@theredlord6178
@theredlord6178 3 жыл бұрын
@@JAMGGameryTutorialesramdom nope... Not at all... I was using transform.position = new Vector3(xPos, yPos); (if I am not wrong, if I was wrong I'll reply with another comment)
@theredlord6178
@theredlord6178 3 жыл бұрын
@@JAMGGameryTutorialesramdom hey, so I checked and thats what I was using: Vector3 location = Camera.main.ScreenToWorldPoint(Input.mousePosition); transform.position = location;
@JAMGGameryTutorialesramdom
@JAMGGameryTutorialesramdom 3 жыл бұрын
​@@theredlord6178 exactly what i said, "Vector3 location = Camera.main.ScreenToWorldPoint(Input.mousePosition);"
@theredlord6178
@theredlord6178 3 жыл бұрын
@@JAMGGameryTutorialesramdom Thank you man!!! Hope in humanity still not lost! There are still good people who are willing to help!! Thank you !!
@yurchiie
@yurchiie 4 жыл бұрын
How does this work? like you're not even checking if the mouse is over the sprite? what am i missing
@dionesoloria3725
@dionesoloria3725 4 жыл бұрын
Check youre Camera projection to Orthographic
@OnyDeus
@OnyDeus 4 жыл бұрын
I thought I was missing something at first. It must be a unity feature or something built in with sprites. A simple OnMouseDown(){ Debug.Log("Click"); } made me realize it just knows that it's being clicked.
@Atskas
@Atskas 3 жыл бұрын
(41,11): error CS0106: The modifier 'private' is not valid for this item Any help? Here is the code. using System.Collections; using System.Collections.Generic; using UnityEngine; public class StickManDragger : MonoBehaviour { private float startPosX; private float startPosY; private bool isBeingHeld = false; // Update is called once per frame void Update() { if (isBeingHeld == true) { Vector3 mousePos; mousePos = Input.mousePosition; mousePos = Camera.main.ScreenToWorldPoint(mousePos); this.gameObject.transform.position = new Vector3(mousePos.x, mousePos.y, 0); } } private void OnMouseDown() { if (Input.GetMouseButtonDown(0)) { Vector3 mousePos; mousePos = Input.mousePosition; mousePos = Camera.main.ScreenToWorldPoint(mousePos); isBeingHeld = true; } private void OnMouseUp() { isBeingHeld = false; } } }
@NadeOnRust
@NadeOnRust 3 жыл бұрын
Your "private void OnMouseUp()" is inside the brackets for OnMouseDown(). Move it outside of the brackets and it will work
@Atskas
@Atskas 3 жыл бұрын
@@NadeOnRust Is there a way to add this to my ragdoll?
@platypus4
@platypus4 2 жыл бұрын
Cna you also do it so you can rotate the game object please with a d you can rotate it a is right d is left
@sandeepanchoudhury-8j-164
@sandeepanchoudhury-8j-164 3 жыл бұрын
will it work for android
@zunuku4165
@zunuku4165 3 жыл бұрын
you could use OnMouseDrag()
@kenfontanilla
@kenfontanilla 2 жыл бұрын
what if I want to restrict it's movement to x axis only?
@Geshman_Sh54
@Geshman_Sh54 Жыл бұрын
I also want tutorial on that
@ramongonzales5562
@ramongonzales5562 4 жыл бұрын
is this working in mobile phones. i mean the Mousedown will do the touch in the phone screen
@tinypizza4278
@tinypizza4278 3 жыл бұрын
Is any one else having problems with not being able to move the platform
@N1ghtR1der666
@N1ghtR1der666 4 жыл бұрын
why do we need a vector3 in a 2d game? EDIT: I changed to vector 2d and its fine For anyone wanting to limit the axis of movement so for example you only want it to slide side to side then change the line un Update like below: this.gameObject.transform.localPosition = new Vector2(mousePos.x - startPosX, this.transform.localPosition.y);
@ramongonzales5562
@ramongonzales5562 4 жыл бұрын
i cant drag my object. its just change position when i clicked it .
@youtuberyoutuber2495
@youtuberyoutuber2495 4 жыл бұрын
double check your code and make sure its exactly what he has.
@Toopa88
@Toopa88 4 жыл бұрын
It didn't work for me either, maybe because I tried to move a GameObject in a canvas (the canvas is set to Screen Space - Camera with the main camera attached to it). The following worked for me if (isBeingHeld) { Vector2 mousePos = Input.mousePosition; mousePos = cameraMain.ScreenToWorldPoint(mousePos); mousePos -= new Vector2(startPos.x, startPos.y); parentObj.transform.position = mousePos; }
@anonymous14045
@anonymous14045 4 жыл бұрын
@ToFu, How about if i want to move the UI IMAGE (for inventory panel), i tried your code, but it still didn't work for UI ELEMENT...., do you have any solution for me ??
@samuv8864
@samuv8864 2 жыл бұрын
Great tutorial and explaining! However, would you happen to know, how I could make this work the way, that if I have an object which is rectangle and it has gravity and I grab it from the bottom and drag it up somewhere where's no collider, it would flip it's self using the gravity. Sort of like "pinning" the object and rising/ moving it how the cursor moves. So if you were to spin the cursor the rectangle would spin due to G forces with rigidbody. Or if that's not explainable I'd like to know how I could make tossing possible. Like when I do a quick swipe to left and release mouse, the object would go flying that direction. If either of these are possible, it's fine and I'll see what I'll do. That would just make the feeling of the game I was working on much more panic punishing. Thanks in advance, if anyone was able to help! And thanks to you Nade for this great and easy tutorial!
@the_terraria_guy9010
@the_terraria_guy9010 Ай бұрын
the if(isBeingHeld == true) kinda killed me inside, but otherwise great tutorial!
@4orniy468
@4orniy468 3 жыл бұрын
Give the script pls unity says error
@windowsmoke
@windowsmoke 4 жыл бұрын
One question I have is: how do I make it so it can't go through walls
@NadeOnRust
@NadeOnRust 4 жыл бұрын
Add a rigidbody to the sprite
@windowsmoke
@windowsmoke 4 жыл бұрын
@@NadeOnRust I have one but since transform is pretty much teleporting it to the mouse it doesn't care about walls. Basically in the same way as in the scene editor
@windowsmoke
@windowsmoke 4 жыл бұрын
@Jay Dev huh? But it is teleporting. That doesn't care if there's a wall or not what I need is some sort of way to make the object gravitate towards the mouse
@elferchusmaymax8122
@elferchusmaymax8122 3 жыл бұрын
@@windowsmoke Did you solve this problem? I am trying to make the same thing but I can't make it either
@toasterdev8329
@toasterdev8329 3 жыл бұрын
This work for thochscreen
How I learned Unity without following tutorials (Developing 1)
18:11
Game Maker's Toolkit
Рет қаралды 2 МЛН
Drag and drop in Unity UI - create your own inventory UI!
12:47
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 9 МЛН
路飞被小孩吓到了#海贼王#路飞
00:41
路飞与唐舞桐
Рет қаралды 66 МЛН
The child was abused by the clown#Short #Officer Rabbit #angel
00:55
兔子警官
Рет қаралды 25 МЛН
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 164 М.
Simple Drag Drop (Unity Tutorial for Beginners)
10:31
Code Monkey
Рет қаралды 318 М.
What size should your assets be? | HD 2D GAME ART
12:10
Nonsensical 2D
Рет қаралды 110 М.
Professional animator works on subscribers' Unity games for free.
22:20
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 4,1 МЛН
I Wish I Had Known This Before I Started Unity Game Development...
11:11
Super Easy DRAG and DROP Unity Tutorial
4:20
BMo
Рет қаралды 30 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 515 М.
I Made a 1D Game 🎮
11:18
Mashpoe
Рет қаралды 1,7 МЛН
MEGA BOXES ARE BACK!!!
8:53
Brawl Stars
Рет қаралды 36 МЛН