using UnityEngine;
using System.Collections;
public class broke : MonoBehaviour {
public GameObject Player;
public GameObject Tre;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
void OnTriggerEnter(Collider Player){
if(Input.GetKeyDown(KeyCode.B)){
Destroy(Tre);
}
}
What’s wrong??
You are using Input.GetKeyDown(). This will only be true for a single frame. The chance that the key will go down in the same frame as the collision is entered is very small. I’m not sure of your intent here, but you could change the code to use Input.GetKey() which returns true as long as the key is held down. Or you could use OnCollisionStay() instead of OnCollisionEnter().
A namespace can only contain types and namespace declarations.
What is this??