system
1
I’m making a jackhammer. I can’t figure out how to make it where when the jackhammer hits the rock it changes a variable. Please help. (By the way I’m a beginner so I’m sorry if this seeems simple. :D)
You can use OnCollisionEnter to detect when the jackhammer hits the rock (NOTE: at least one of them must have a rigidbody attached). Place this code in the jackhammer script:
function OnCollisionEnter(col: Collision){
if (col.transform.name == "Rock"){ // you could compare tag as well
// do whatever you want when the jackhammer hits the rock:
rockHit = true; // like setting a boolean variable, for instance
}
}