Below is the code for the picking up of the objects such as the torch and batteries. The code for the battery pick up isn't complete yet as there are no batteries in the scene as of yet. The game object i.e the flashlight will be destroyed (taken off the scene) when it has been picked up, as shown in this code. As of yet the object will be picked up when it is simply walked into, I want to improve this so the player is prompted with a button to press to pick up objects.
using UnityEngine;
using System.Collections;
public class PickUp : MonoBehaviour {
public enum Item
{
Flashlight,
Battery
}
public Item item;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
HUD.HasFlashlight = true;
Destroy(gameObject);
}
//else
//HUD.BatteryCount++;
//Destroy (gameObject);
}
}
No comments:
Post a Comment