Hey guys I have been working on a game for Uni and I have been researching how to make a player pick up and read a piece of paper lying on the ground, I would like it if I could pick it up on mouse click, I saw a couple of decent already answered questions like this for example,
although that doesn’t seem to be working for me, any advice?
Try using the MonoBehaviour.OnMouseUp callback. Make sure to assign a collider to the “paper” GameObject, and that it uses a layer different from “Ignore Raycast”.
using UnityEngine;
using System.Collections;
public class Example: MonoBehaviour {
void OnMouseUp() {
Debug.Log("Clicked on the object this script is attached to");
}
}