- Home /
Picking up objects
Looked for an answer but all i can find is clicking objects with the mouse to pick them up, but i want the ability to pick up a block with my character and carry it. Can anyone point me in the right direction?
Comment
This question is a bit too general, but I shall try to help.
Click on an Object to select it :
private var imSelected : Transform;
private var imClickedOn : boolean = false;
// in function
if (Input.Get$$anonymous$$ouseButtonDown(0))
{
var rayHit : RaycastHit;
if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), rayHit))
{
imSelected = rayHit.transform;
if (imSelected == this.transform) {imClickedOn = true;}
}
}