Question by
liuxuqing11 · Nov 13, 2015 at 01:42 PM ·
if statement
add score when collide with gameobject
hi guys i need some help here. I want to destroy my collided object only when the respective key is pressed. but i can detect the get key down on onCollisionEnter??? here's my code thanks in advanced!
IEnumerator OnCollisionEnter(Collision col) {
//Debug.Log (("") + col.gameObject.name);
if(col.gameObject.tag == "destroy")
{
gameObject.GetComponent<Renderer>().material.color = Color.yellow;
if(col.gameObject.name=="Drop_(3)(Clone)" && Input.GetKeyDown(KeyCode.D))
{
Destroy(col.gameObject);
gameObject.GetComponent<Renderer>().material.color = Color.white;
Debug.Log ("hi");
}
Comment
Your answer

Follow this Question
Related Questions
mathf.abs(0) is higher than 90, why? 1 Answer
Compare a value to all other values in an array 2 Answers
Check a bool method with if statement 1 Answer
Two IF Statements not working in one method 2 Answers
If statement not working correctly 0 Answers