Tuesday, October 21, 2014
using UnityEngine;
using System.Collections;
public class KeyPickup : MonoBehaviour
{
public AudioClip keyGrab; // Audioclip to play when the key is picked up.
private GameObject player; // Reference to the player.
private PlayerInventory playerInventory; // Reference to the player's inventory.
void Awake ()
{
// Setting up the references.
player = GameObject.FindGameObjectWithTag(Tags.player);
playerInventory = player.GetComponent<PlayerInventory>();
}
void OnTriggerEnter (Collider other)
{
// If the colliding gameobject is the player...
if(other.gameObject == player)
{
// ... play the clip at the position of the key...
AudioSource.PlayClipAtPoint(keyGrab, transform.position);
// ... the player has a key ...
playerInventory.hasKey = true;
// ... and destroy this gameobject.
Destroy(gameObject);
}
}
}
So Unity doesn't like the line I highlighted in the code and I'm not really sure why. I'm trying to figure out why it doesn't like it but I got three different error messages. I'm going to look at the stuff you sent me to see if it's different. (I should have looked at what you sent first but I wanted to see where the tutorial was going to go with it.) But I am working on it and am thinking about it a lot. As soon as I get this down so that I can share it with everyone I will work on my reskin because I'm really excited about doing 8-bit artwork for this. But I'll look at what you sent me and I'll make another post in half an hour or so.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment