Question by
TheCreatorultim · Dec 26, 2016 at 08:03 PM ·
scripting problemcollisioninputchange
Change input to collsiion?
Now the input to trigger the script is "Q'' but i want to change it to when a object touches the other object it will activate the script? the script i use: using UnityEngine; using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public float health;
public GameObject destroyed_ob;
void Update ()
{
if (Input.GetButtonDown ("q")) {
this.transform.SendMessageUpwards ("GetBulletDamage", 20, SendMessageOptions.DontRequireReceiver);
}
}
public void GetBulletDamage(float damage)
{
health -= damage;
if(health <= 0)
{
GameObject destroy_ob = Instantiate (destroyed_ob, this.transform.position, this.transform.rotation) as GameObject;
Destroy (gameObject);
}
}
}
THX FOR HELPING!
Comment