How to Pick Up + Hold Objects in Unity (FPS)

preview_player
Показать описание
In this video I show how to pick up, rotate, and throw objects in Unity.
CODE (YES YOU HAVE PERMISSION TO USE IT):
Рекомендации по теме
Комментарии
Автор

For anyone else who has trouble with this:
1. Make sure to either name everything the same as Jon does or to rename them in the script file to what you've used.
2. By default the keys are 'E' to pick up/drop, hold 'R' and move mouse to rotate, and 'Left Click' to throw. This can be changed in the script.
3. Make sure the object you're picking up has a box collider and a rigidbody component.
4. Make sure on your camera (where you added the script) that 'Player' is set to the parent file of your camera movement.

Hopefully, that helps some of you out. But if you're still stuck don't bother asking me for help. I just started learning Unity today, so idk lol.

Vorkandor
Автор

For anyone struggling to figure out how to reference another script, I used a video by Game Dev Beginner "How to get a variable from another script in Unity (the right way)" to figure it out.

Thank you Jon for this helpful tutorial.

SleepyMatt-zzz
Автор

Sorry but how does this video only have 60 views when its the best method of doing this I've found

Jarseller
Автор

NO WAY YOU ARE NEW, i want you to be the new brackeys because editing, commentary and tutorials like this are GOLDEN.

hemanarthanamaly
Автор

I loved it completely, and the memes sajkdsakljd so good, hope to see more of your tutorials soon!

kiryrumirz
Автор

This is for anyone who wants to rotate the object to world space!
Replace this:
heldObj.transform.Rotate(Vector3.down, XaxisRotation);
heldObj.transform.Rotate(Vector3.right, YaxisRotation);

With this:
heldObj.transform.Rotate(Vector3.down, XaxisRotation, Space.World);
heldObj.transform.Rotate(Vector3.right, YaxisRotation, Space.World);

Hope this helps! 🧀🧀

pietrosprudente
Автор

Loved the tutorial, keep up the good work

josemanuel
Автор

Thanks!!!! it is easy to implement and can be easily extended

mdmushiransari
Автор

Is there any way to include a text which tells what is the button to pick up the object. I have no idea where to put it since the pickup range is after the getkeydown. This would really help!

jimppui
Автор

hi! thank you so much for the tutorial! i'm a bit confused on how to lock the background lookaround rotation while you're rotating the item. could you advise on this? thanks!

skylarl.
Автор

Make sure that the "Static" checkbox is not ticked in the Inspector at the top right corner. Some objects have this ticked by default

dssolve
Автор

Great video, but I do have one problem. Every time I try to pick up the sphere I want to pick up, nothing happens. I have it on the right tag, but on the default layer. When I try to put it on the Hold layer, it can be seen through walls. Any way these can be fixed?

Ninethemeerkat
Автор

when I make the same settings in both of my cameras I think my unity only uses one camera and that is the pickupcamera in my unity everything goes black other than the objects in holdlayer. how can I fix it

duhanavc
Автор

How can i change R to rotate the object to the Scroll wheel instead?

frog
Автор

why cant i pick up i try to follow these tutoirals but nothing works

summerwheels
Автор

This is nice because the object doesn't move when it hits walls

huguesdepayens
Автор

It worked but when i try on an imported 3d object it still clips through the wall for some reason

notuncleben
Автор

lol been trying to do this for ages with some goofy ass spaghetti code when I realised I can yoink the code. :p

Hyperforg
Автор

hI, can someone help me pls every time I try to click the "E" to pick up the object it doesn't do anything.

lennienicolelorenzo
Автор

When I click play, the object I want to pick up is just gone

KikiKilo