ok so im a newbie and im wondering how you would make it to were you pick up an object that your looking at. e.g. i look at a barrel and click “e” and it picks up the object and i can carry it around till i press e again then it drops the object. if anyone know how to do that, plz respond back giveing me a script.
that would be great fully appreciated!
I think that in the standard assets you get a free script called rigidbody grabber or something like that. Just look in assets.
I’m not familiar with “rigidbody grabber”. If you find it can you link it? I did a quick search on “grabber” using the Search Engine linked in my .sig and I found this: http://forum.unity3d.com/threads/79352-Half-Life-2-Object-Grabber
In general, if I were to approach this, I would cast a ray out to the object and if it’s a pickup object I would “pick it up”. To pick it up, I would have a child transform of my game object as the “carry/hold location” and on pickup I would lerp or tween the picked up object to the carry/hold location. When I dropped it, I would add force and throw it away from me. If you want a soft feel, then I’d use some code that regularly tries to lerp/tween the pickup object to the carry/hold location as a target, so when the target moved, the pickup object would take a moment to “catch up”.
It’s called Drag Rigidbody and it’s exactly what he’s looking for. It comes with Unity and should just be in the Scripts folder. You literally just put the script on the player and you can pick up any object as long as it has a Rigidbody component.
And there it is:


Hadn’t played with that before!