Unity for Noobs #1 First Person Controller and Delete Item Scripts #4

using UnityEngine;

using System.Collections;

public class PickUp : MonoBehaviour {

public int distanceToItem;

void Update{



void Collect(){

if (Input.GetMouseButtonUp(1)){

RaycastHit hit;

Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);


if(Physics.Raycast(ray, out hit, distanceToItem)){
if(hit.collider,gameObject,name == “item”){

Debug.log(“item hit”);





There may be spelling errors as ive just wrote this up in the blog without referencing mono develop. Im sure they would be obvious in the console though. If there are any questions shoot me with a comment on the video!


Have a good one