- Home /
Picking Up Objects Using C# Not Working
So, I am trying to make it so that a first person player character can pick up, move, and drop items using the left mouse button. I'm completely new to coding in Unity and I've tried quite a few things but none of them are working. The item I am currently trying to make pickupable is a Rigidbody cylinder with a Capsule Collider, Mesh Renderer, and Cylinder (Mesh Filter). Thank you in advance!
what have you tried, what parts did work, what parts didn't and why didn't they work?
try answering these questions. Asking for a global solution to a vague problem won't get you any answers.
Unfortunately, not much of anything worked. The closest I got was being able to kick the object around, rather than pick it up. I keep looking into it and I'll update the post if I do happen to find something.
Answer by LuisVazquez · Jul 14, 2018 at 11:45 PM
Hi, have you tried with OnTriggerEnter? hope I've helped you
private void OnTriggerStay(Collider col)
{
if (col.gameObject.tag == "Player")
{
if (Input.GetMouseButtonDown(1))
{
//Pick up coin for example
}
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Item pickup and drop function 2 Answers
On raycast hover change crosshair image 1 Answer
Rotate object ON THE CAMERA UP AXIS 2 Answers