I’ve been trying to make a script to pick up weapons and I’m just testing it to see if all the triggers work and whatnot and the GetKeyUp isn’t working.
Heres the script on the player:
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public bool equip;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other){
if (other.gameObject.tag == "weapon"){
if(Input.GetKeyUp("e")){
equip = true;
other.gameObject.SendMessage("Equip");
}
}
}
}
and the weapons:
using UnityEngine;
using System.Collections;
public class Weapon : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void Equip(){
print("picked up weapon");
}
}
I know the triggers work because I tested them but when I added the next if GetKeyUp it doesn’t perform either of those functions. Equip stays false and I get no picked up weapon message in the console. But I also get no error messages. Can anyone see what I am doing wrong?