Okay so the pick up script works great i can pick up my object and have it apear in my characters hand.
using UnityEngine;
using System.Collections;
public class PlaceItem : MonoBehaviour
{
private bool inRange = false;
public bool Activated { get; set; }
void Awake()
{
}
void OnTriggerEnter()
{
inRange = true;
Debug.Log("in range of alter place item");
}
void OnTriggerExit()
{
inRange = false;
Debug.Log("out of range of alter ");
}
void Update()
{
if (TP_Controller.Instance.ObjectHeld != null)
{
if (inRange && TP_Controller.Instance.IsHolding == Input.GetKeyDown(KeyCode.E))
{
animation.Play("WIN");// if the item has an animation
//transform.Find("SuperOrb1").renderer.enabled = true;
TP_Controller.Instance.IsHolding = false;
Activated = true;
GameObject.Destroy(TP_Controller.Instance.ObjectHeld.gameObject);
TP_Controller.Instance.Use(); //-- this will animate the character in CControler and animator
}
}
}
}
This script allows me to place the item on a trigger when the character is holding the item then press E to add to the alter.
The problem is that when i go to the alter and press E without the object held it still activates, can anyone help ?