Тёмный

HOW TO PICK UP AND PLACE / THROW OBJECTS WITH C# - Mini Unity Tutorial - EASY & FUN 

Jimmy Vegas
Подписаться 146 тыс.
Просмотров 126 тыс.
50% 1

In this Mini Unity Tutorial we learn how we can pick up, place and throw objects using C# and physics.
✦ Subscribe: bit.ly/JimmyVegasUnityTutorials
✦ Patreon: / jimmyvegas
✦ FREE Assets: jvunity.com/
✦ Facebook: / jimmyvegas3d
✦ Twitter: / jimmyvegas17
-----------------------------------
✦ Start your game development career today in Unity 2017 - Unity 2018.1 and even Unity 2018.2 and learn how to make a game through the power of Unity. Every Unity Tutorial at JV Unity costs NOTHING from you, and any support received through RU-vid, Patreon or Facebook is greatly appreciated.
-----------------------------------
-----------------
Who Is Jimmy Vegas?
-----------------
Jimmy Vegas is one of the top RU-vid tutorial developers. In depth Unity Tutorials teaching you how to make a game in unity 3d! My unity tutorials include development, programming in C#, coding logic and more. For beginners, it's easy how to learn unity with tips and tricks you can make a game for FREE. I provide FREE assets for you to use and learn.
Start your game development career today, for free. #JIMMYVEGAS #UnityTutorial #UnityTutorialForBeginners

Опубликовано:

 

23 ноя 2018

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 324   
@silencer3kmg
@silencer3kmg 3 года назад
I'm going to say, I'm only 4 minutes in and I respect that you aren't flying through the coding like way prepared and making it impossible to follow along easily just to make yourself look like you're an uber coder. This comment may be 2 years late but worth a thumbs up anyway.
@JonJonGames
@JonJonGames 3 года назад
Its not the code, its the way you set it up.
@giridharahnbalajikannan6747
@giridharahnbalajikannan6747 5 лет назад
To make it stop floating and rotating , just after the line : GetComponent().useGravity = false; add another line : GetComponent().freezeRotation = true; This will stop if from rotating. And in the mouse up function before the line :GetComponent().useGravity = false; add GetComponent().freezeRotation = false; This should fix it :)
@ruralplayer
@ruralplayer 5 лет назад
Takk!!
@GlenvilleCowMilk222
@GlenvilleCowMilk222 5 лет назад
Did not work for me
@morpionite
@morpionite 4 года назад
Works fine, thank you!
@real5386
@real5386 4 года назад
My brain hurts
@mihirkamat5782
@mihirkamat5782 4 года назад
Just enable iskinematic.
@SSTC10
@SSTC10 5 лет назад
You are my favourite teacher of the world
@idalnborg3983
@idalnborg3983 4 года назад
Thank you for making this video. You made it easy to understand, as it was short but relevant.
@DamanD
@DamanD 5 лет назад
finally! i wanted a tutorial about this! thanks man! :D
@madbitscience6230
@madbitscience6230 3 года назад
This is exactly what I needed! Thank you so much!
@morpionite
@morpionite 4 года назад
Thanks, great video!. Just a comment, since Destination is a child of the First Person Character and uses local coordinates, simply leave X and Y as zero, and adjust Z to keep Destination right in front of the camera. That worked well for me. I also froze rotation in the script as suggested in a post below.
@dyasio655
@dyasio655 5 лет назад
very good for beginners, easy to follow.
@ionic_
@ionic_ 3 года назад
This enspired me to start unity and make my dream game thx man
@xoduk
@xoduk 2 года назад
Nice! I'm glad you found where to start with game development. Good Luck with your dream game!
@ChristianWayne12
@ChristianWayne12 5 лет назад
Really Helped thanks man !!
@aykutbakar3217
@aykutbakar3217 3 года назад
Thank you so much man, its great tutorial
@danielcraft1584
@danielcraft1584 3 года назад
This tutorial is awesome thank you thumbs up for you! 👍
@carmelwild857
@carmelwild857 4 года назад
Thanks So Much Jimmy.... Awesome!
@elsenussi
@elsenussi 3 года назад
You are the best teacher , thanks.
@twigg_on_fortnite
@twigg_on_fortnite 4 года назад
Very helpful tutorial!
@mexikanecfilda
@mexikanecfilda 3 года назад
"box collider...because it is a box duh" im dying xD
@motiejausvaliunoanimacijos3408
@motiejausvaliunoanimacijos3408 3 года назад
whats so funny about that
@confusedcoder.3777
@confusedcoder.3777 4 года назад
Great Tutorial!.:
@linii1820
@linii1820 3 года назад
Thanks, work great!
@dolarq7115
@dolarq7115 2 года назад
Super cool
@raido3664
@raido3664 3 года назад
Thank you very Much!
@luchianvasile
@luchianvasile 4 года назад
It helped me very much
@alex94i60
@alex94i60 5 лет назад
very practical!
@jacksonwood3906
@jacksonwood3906 3 года назад
Amazing tutorial! Only, how would i go about making the object rotate in my hand using the mouse when holding down a button???
@thunderbulletin7143
@thunderbulletin7143 5 лет назад
Best teachah
@dunderguy
@dunderguy 2 года назад
Thanks this tutorial was awesome but what would I have to do if I wanted the object I'm picking up to be picked up by pressing E? Also, now whenever I move it's almost like the object I'm trying to grab is moving slower than me for a few seconds but a few seconds later it goes my speed and vice versa
@openroomxyz
@openroomxyz 2 года назад
Thanks!
@ristence
@ristence 4 года назад
thanks youuuuuuu so much
@mogaolimpiu7190
@mogaolimpiu7190 4 года назад
thank you, i am new to game dev, and this really helps, idk if you will ever read this, but i really love your way of explaining things
@hydricbluen8498
@hydricbluen8498 4 года назад
could you do a tutorial where you could pick up say, a flashlight. it goes into the players inventory and you can click on a specific button to equip the flashlight? I think that would be very cool!
@MobileScrap
@MobileScrap 4 года назад
Great tutorial, but the object won't move along with my character when I walk. It moves when I look left and right, but it just doesnt when i'm walking. Is there a way to fix this?
@GamesStraight
@GamesStraight 4 года назад
I hope you’re still making this videos as I need you’re help to learn
@JimmyVegasUnity
@JimmyVegasUnity 4 года назад
I put put tutorials every week.
@felixtedesco4136
@felixtedesco4136 3 года назад
Hey @jimmy Vegas! If I want the player just pick the object if he's in a certain distance or close to the player.. how can I do that?
@cvastardo
@cvastardo 3 года назад
nice vid
@ragnar8871
@ragnar8871 Год назад
if you have the problem of object flying in the air on contact with any other game object just set it to is kinematic true when you grab it ;)...I have a problem though, I read that it's a bug of unity but not I am convinced, that is, when the object becomes a "child" of the player it deforms on the Y axis if the scale of the player is for example 1,2,1, instead if it remains on 1,1,1 it works perfectly.
@palkeeratsingh
@palkeeratsingh 2 года назад
thanks
@Rosathan
@Rosathan 3 года назад
So how would i move the object around but not having it rotate as i move it? As of now i can pick it up but not move it up or down dew to the game object being static baced off of the direction im facing, I want to move it like in portal when you move the companion cube
@adkinsy85
@adkinsy85 4 года назад
Will this works on enemy player? And then after grabbing i can chokeslam him with animation ?
@openingchain328
@openingchain328 3 года назад
when im holding the box then when i drop it the size of the box gets smaller on the y axis
@Brand0n_Tardis
@Brand0n_Tardis 3 года назад
How can we make it so that the box will always appear in the same and be locked in that area? my Destination seems to get glitched and will sometimes push the object out of the map or out of the view of the camera. It works fine when I first pick it up but if I pick it up again it won't be centered anymore and will start to bug out of the world
@miaofeila
@miaofeila 3 года назад
I had the same problem
@boftoa
@boftoa 4 года назад
Great Video! Buuut my player is only created after loading the scene. How do I assign variable "theDest" at runtime? Nvm i got it.
@michael-angel9413
@michael-angel9413 4 года назад
You can search it with GameObject.Find(), either with a Tag or Object name
@linfois1771
@linfois1771 Год назад
Hi, when i pick up my cube and drop it and pick it up again while its falling newtons 3rd law is applied (any object will not change its motion unless a force acts on it.) is there any tips on how to fix this problem?
@jaheim1872
@jaheim1872 5 лет назад
It's just come to my mind how crazy is your storage to store videos and projects
@JimmyVegasUnity
@JimmyVegasUnity 5 лет назад
Everything together takes about 2TB I think.
@jaheim1872
@jaheim1872 5 лет назад
Yikes I guessing everything is backed up
@MythicOneOne
@MythicOneOne 2 года назад
Hey Jimmy, I have a weird issue where the object won't move with my player. Any advise what's wrong?
@DAATChannel
@DAATChannel 2 года назад
Any bugs?
@thebasketclubs
@thebasketclubs Год назад
Same
@tomvandenabeele1748
@tomvandenabeele1748 3 года назад
If i pick an item up it slowly fly's away☹️?
@hyioxh5247
@hyioxh5247 2 года назад
me too :(
@shivamprajapati172
@shivamprajapati172 5 лет назад
Can u help me to learn the scene or if u already done can I get the video link plz.
@odinniereece4096
@odinniereece4096 2 года назад
This is great, the one point he forgot was to set the drag to a high number. That would have solved any problems with the object floating away.
@glord5292
@glord5292 3 года назад
just thanks ( :
@reversiblelag
@reversiblelag 5 лет назад
What gives i needed this tut like a week ago but i figured it out
@headrushgaming2614
@headrushgaming2614 3 года назад
could you not use a raycast and apply the Hit.transform to a new gameobject, then use that "hitObject" as the "this.transfrom" so you can just have the single script on say your camera?
@JimmyVegasUnity
@JimmyVegasUnity 3 года назад
If you wanted to you could. There's a million ways to do things in Unity :)
@alfalfadelta6378
@alfalfadelta6378 2 года назад
I'm having an issue where it won't allow me to add the Destination child to my transform script. I'm not sure what went wrong to make it do that.
@svenk3913
@svenk3913 3 года назад
cant walk with the box
@NapkinHolder_AH
@NapkinHolder_AH 4 года назад
What if you have a box collider and a sphere collider on one object, but only a box collider on another object?
@bradleyadams7716
@bradleyadams7716 4 года назад
Thank you so much, this is very helpful. Is there anyway I can stop it from throwing it through walls? And also, how do I make use the right mouse button to pick objects up instead of the left mouse button, because that's my shoot button.
@toaster2940
@toaster2940 4 года назад
I dont know if youve solved this, but replace the input.getmousebuttondown(0) with a 1 in the brackets
@stevengibson4773
@stevengibson4773 4 года назад
Any idea why I am experiencing this? I originally tried doing this on my own without a tutorial and ran into the same problem, tried to see if I was missing something and I am still experiencing the same issue with your method. The object moves at a slower rate than the player when the player is moving using the arrow keys. It seems to move fine when rotating with the mouse.
@list9016
@list9016 2 года назад
thats weird.- I've never seen that happen to me
@mythco.3461
@mythco.3461 5 лет назад
You're so cool. How long did you study coding?
@JustJordanGames
@JustJordanGames Год назад
my was gitchy at first but I put the mass at 10 and it worked
@AvarageMilkEnjoyer
@AvarageMilkEnjoyer 2 года назад
Question: when I click and pickup a box, all the boxes get picked up, and it also works when my mouse is not on the box f.e I'm at the other side of the map but I can still drag around stuff
@XyLeeeen
@XyLeeeen 2 года назад
did you find a solution? i have the same problem
@ApexArtistX
@ApexArtistX 4 года назад
Can u do 3d platfomer ledge climbing
@vilhola2187
@vilhola2187 2 года назад
How can i assign the destination if the object is a prefab?
@leandrogomez7731
@leandrogomez7731 4 года назад
Sorry how could i be able to pick these objects preesing the key of a keyboard? Pls help
@roshanacharya4618
@roshanacharya4618 5 лет назад
Please make a video for parkour movement :)
@OriginalZypher
@OriginalZypher 2 года назад
Let's say you have a tree that falls on its side when you pick it up it's still on its side. What script would allow me to pick up an object and have its rotation stand straight back up when its picked up?
@ewanjones5591
@ewanjones5591 Год назад
YourGameObject.transform.eulerAngles = new Vector3(0, 0, 0); Just set "YourGameObject" to your object reference.
@tristang5051
@tristang5051 2 года назад
how can i make it so that the object cant go through walls? i got rid of the code that disables the box collider, but it doesnt do anything
@chrischase9601
@chrischase9601 3 года назад
i cannot set the transform dest while out of game, what i mean by this is i cant set the dest in any prefab, it has to be set in game. i.e. i have an animal that needs to pick stuff up in its mouth and move it, and i cant set the dest in the prefabs that require it.
@ScoutIsDeliciousTF2
@ScoutIsDeliciousTF2 3 года назад
when i try to play i cant cause there is an error saying "Assets/PickUp.cs(24,2): error CS1513: } expected" what do i do? oh and by the way i also added the lines of code from Gridharahn Balajikannan's comment
@JimmyVegasUnity
@JimmyVegasUnity 3 года назад
you’re missing the } from your code, as the error says
@ScoutIsDeliciousTF2
@ScoutIsDeliciousTF2 3 года назад
@@JimmyVegasUnity ooooh thank you
@rodolf5941
@rodolf5941 5 лет назад
How did you make the player have that "up and down" movement while walking?
@JimmyVegasUnity
@JimmyVegasUnity 5 лет назад
Its the standard assets.
@rodolf5941
@rodolf5941 5 лет назад
@@JimmyVegasUnity What does that mean? How do I get it? Is it an animation? A C# script? I know what assets are (kinda) but the walking scrips I have is only moving around, not actually walking. Like there's no walking (up and down swing).
@JimmyVegasUnity
@JimmyVegasUnity 5 лет назад
ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-9cQts-kJp_4.html&index=23&list=PLZ1b66Z1KFKg01Qniy1C5S2FPph61if6V
@rodolf5941
@rodolf5941 4 года назад
@Bartek270 Don't bully me, it was my first time ever using Unity ;D
@micmalawi
@micmalawi 4 года назад
But how do you get the mouse arrow to show when you press play...?
@MasthaX
@MasthaX 4 года назад
Hi my name is Jimmy Vegas, the fucking coolest name I've come across on RU-vid could be straight out of a Q.Tarantino Movie.
@djkorou
@djkorou 2 года назад
any idea why when i hit play the object is there but isn't floating with the player??
@enjoyriotgames
@enjoyriotgames 2 года назад
my object is moving to the destination but it does not sticking with my player after moving (top down movement)
@stryder12345
@stryder12345 3 года назад
What is destination? I connect it to Main Camera, and my object just teleport to camera instead of dragging, could you help?
@viniciusmoraes424
@viniciusmoraes424 3 года назад
Create a Empty GameObject and drag it to the front of your character, this is your destination
@GrimBirthday
@GrimBirthday 4 года назад
on mouse down GetComponent().isKinematic = true; on mouse up GetComponent().isKinematic = false; That is equivalent to disabling the box collider in this case. The same problem occurs where you can put it through walls. So why do people keep suggesting it like it's the right answer
@tristang5051
@tristang5051 2 года назад
people are suggesting to use kinematic instead of gravity, bc if the object is moving when you pick it up, it will keep moving unless you use kinematic
@Cade-nm6so
@Cade-nm6so 2 года назад
Hi, Thanks for the amazing tutorial, although it doesn't work for me, it keeps giving me the error of : Assets\Scripts\PickUp.cs(14,14): error CS1061: 'SimpleGrabSystem' does not contain a definition for 'transorm' and no accessible extension method 'transorm' accepting a first argument of type 'SimpleGrabSystem' could be found (are you missing a using directive or an assembly reference?). Im new to C# and have no clue how to fix this, please can someone help me?? Edit: nvm its was a spelling error lol =)
@JimmyVegasUnity
@JimmyVegasUnity 2 года назад
spelling errors in your script
@nerdagaming
@nerdagaming 2 года назад
transform, not transorm
@Tomijones
@Tomijones 3 года назад
how to rotate the item with mwheel up/down?
@hekbdodjdk4924
@hekbdodjdk4924 3 года назад
why my player pick up the box collider not the object ?
@noname82152
@noname82152 3 года назад
If there is 5f value between the object and the player, I want to prevent the player from taking the object. How can I do that?
@cgglitch333
@cgglitch333 3 года назад
if u found it please tell me also please
@gabrieldealca4829
@gabrieldealca4829 3 года назад
upon picking up, the longer I hold mouse up, the higher the object goes, can someone help?
@baxterclagmoar9333
@baxterclagmoar9333 5 лет назад
A slight problem where when you pick up the object, if you look around whilst holding the object it actually stretches and deforms it. I noticed it happen in your video too, and it happens for me. Any solution?
@JimmyVegasUnity
@JimmyVegasUnity 5 лет назад
Where did it happen in the video?
@baxterclagmoar9333
@baxterclagmoar9333 5 лет назад
@@JimmyVegasUnity I rewatched the video and I was mistaken, you picked up a long box, not a square one. I assumed it was square and then diformed like mine! Anywho, I fixed the issue, I'd changed the y size of my fps controller rather than the "height" this causes children of it to stretch with the axis
@baxterclagmoar9333
@baxterclagmoar9333 5 лет назад
Thanks for this super helpful video though!!
@JimmyVegasUnity
@JimmyVegasUnity 5 лет назад
Good stuff :)
@randem2348
@randem2348 4 года назад
The ability to assign a variable for theDest isn't popping up for me.
@Someguy204
@Someguy204 3 года назад
For some reason it scales when I drop it not sure why I tried to fix it but failed anyone can help?
@hsmyv
@hsmyv 3 года назад
Can I use this script in unity mobile?
@lost1796
@lost1796 4 года назад
i followed the tutorial and it say the script needs to follow mono behavor. please help
@luisgonzalez5374
@luisgonzalez5374 4 года назад
Forreal i think its our version bro
@theonlyfry
@theonlyfry 3 года назад
This works perfectly fine but I keep getting a "NullReferenceExpectation" error and I am clueless Like I said, it does what it's supposed to do, pickup and drop, but that error keeps showing up. Any help?
@JonJonGames
@JonJonGames 3 года назад
Did you follow the video?
@theonlyfry
@theonlyfry 3 года назад
@@JonJonGames i fixed it. But in the end I ended up just scrapping the entire thing a followed another tutorial, it works much better
@courier8702
@courier8702 4 года назад
help me I want to make the input different but i dont know how
@nimbusgaming793
@nimbusgaming793 4 года назад
me too
@colemorrow5042
@colemorrow5042 3 года назад
you would use keycode for that
@ShootLuckGaming
@ShootLuckGaming 5 лет назад
My only problem is when walking forward or backward the box will just glitch and sometimes it wont move, sometimes its will fly away
@laok
@laok 5 лет назад
me too
@porlaresjeitresa.9256
@porlaresjeitresa.9256 3 года назад
hey i'm having a problem, i did everything, and i copied everything. But when i pick up the item, it does not go with the player, it just stays in that position. hope you reply thank you
@gamedevtutor2799
@gamedevtutor2799 3 года назад
Just put the "Destination" which is an empty gameobject under "FirstPersonCharacter" then transform the item in the Destination position as child object
@Rectangle101
@Rectangle101 5 лет назад
Jimmy Vegas can you please remake this in unity 5 and have a asset downloaded please!
@JimmyVegasUnity
@JimmyVegasUnity 5 лет назад
It's the exact same whatever version you use. I don't even have Unity 5 installed anymore, nobody should. 2017 and 2018 are far superior.
@Brand0n_Tardis
@Brand0n_Tardis 3 года назад
How can we make it so that when a player looks up or down the box will go up or down
@JimmyVegasUnity
@JimmyVegasUnity 3 года назад
Attach the empty game object to the fps character object and it will work :)
@Brand0n_Tardis
@Brand0n_Tardis 3 года назад
@@JimmyVegasUnity Cool thank you, you responded really fast to a 2 year old video. I've been looking for a way to do this all day yesterday. Thank you again so much :D
@_bowlofsoup
@_bowlofsoup 3 года назад
can i make it do keypresses
@zerinism4111
@zerinism4111 4 года назад
Thanks for the code..I try to play my VR game mode with bluetooth joystick on android..but it can't grab object like this even with cursor(on android) and I need to touch screen to grab object..I wonder how to fix this..ya I know this script for PC build..Thanks if there any solution for this
@penwozhere
@penwozhere 4 года назад
Muhamad Azri Use a different button press.
@outofstepbaritone
@outofstepbaritone 4 года назад
Map a button on your vr controller to a click
@ellieblaber4243
@ellieblaber4243 5 лет назад
this is alright, however the pickups float away if you pick them up while they're in motion, and deactivating the box collider to stop it from floating around as much just means you can drop objects through the floor
@mihirkamat5782
@mihirkamat5782 4 года назад
Just enable iskinematic instead of usegravity
@5ManaAndADream
@5ManaAndADream 4 года назад
@@mihirkamat5782 then it goes through walls....
@pranav2310
@pranav2310 5 лет назад
Pls can you teach how to make a text based game like life lime
@Uprank
@Uprank 4 года назад
Help! when i press e it picks up ALL of my objects at once!
@Trashboat1060
@Trashboat1060 3 года назад
@Clara Smith @uprank Im currently finding a fix for this
@bfnv9972
@bfnv9972 3 года назад
I would recommend using raycast or adding an additional trigger collider to detect which object u wanna pick
@jt8821
@jt8821 3 года назад
I also have this problem. I use a raycast Edit: I have partially fixed it by instead of using "this." i use the value from the raycast "hit."
@MumblinGamer
@MumblinGamer 2 года назад
the object picked up for some reason isn't moving with the character
@marianogarcia7246
@marianogarcia7246 3 года назад
How do i script the pick up and throw item for Mobile/Android in Unity?
@JimmyVegasUnity
@JimmyVegasUnity 3 года назад
use a button. if you adapt the code slightly and apply it to a button, it functions the same
@betrayedpickle291
@betrayedpickle291 4 года назад
what if i want to make it pick up with E instead of LMB?
@Trashboat1060
@Trashboat1060 3 года назад
Make it if if (Input.GetKeyDown(KeyCode.E)) Grab(); else if (Input.GetKeyUp(KeyCode.E)) Drop();
@iantakacs8771
@iantakacs8771 3 года назад
@@Trashboat1060 Where do i put it, below the Transform theDest; or OnMouseDown or OnMouseUp
@iantakacs8771
@iantakacs8771 3 года назад
@@Trashboat1060 also when ive tried it in every spot for the grab and drop it says the name (grab or drop) does not exist in the current context
@michaelbabcock6997
@michaelbabcock6997 4 года назад
when i clickon the object it snaps to that position and does not follow me as I move the player. It follows where I am looking but not my position.
@twigg_on_fortnite
@twigg_on_fortnite 3 года назад
Make sure you are finding the correct Destination object in this line: this.transform.parent = GameObject.Find("Destination").transform; this should help ;)
@michaelbabcock6997
@michaelbabcock6997 3 года назад
@@twigg_on_fortnite I dont remember what I was using this for but I am sure I got it. Ty tho.
@fattypatty75
@fattypatty75 3 года назад
Is there a way to make this "e" rather than it being mouse clicks?
@JonJonGames
@JonJonGames 3 года назад
Just add the key binding in your player input settings, then do a couple of if statements and reference that.
@fattypatty75
@fattypatty75 3 года назад
@@JonJonGames I've scrapped that small little project I appreciate the reply :)
@dattoproduction4450
@dattoproduction4450 3 года назад
How can I change the button to pick up? for example "e"
@JimmyVegasUnity
@JimmyVegasUnity 3 года назад
use GetKeyDown and use KeyCode.E
Далее
How to Pick Up + Hold Objects in Unity (FPS)
3:42
Просмотров 20 тыс.
Мама ударила дочь #shorts #iribaby
00:17
UFC 302: Пресс-конференция
22:48
Просмотров 1,4 млн
3D Isometric Games - Pros and Cons | Unity Tutorial
10:56
I Tried C#
4:32
Просмотров 226 тыс.
How to Pick up and Place objects in Unity P1
20:21
Просмотров 25 тыс.
olcPixelGameEngine
20:17
Просмотров 162 тыс.
Мама ударила дочь #shorts #iribaby
00:17