- Home /
How to check hit on tank
Hi, I have a little problem with my game. There's tanks which shoot out rigidbodies as projectiles, now how I can check when this projectile object hits ie. object with tag Player and then it changes material of the object it did hit to another (In this case, it's to damaged material.)
Little piece of script which to add on projectile object would help a lot, or I can try to do it myself if you give good advices.
If you don't know how to write a simple script yet, I suggest you do some tutorials that cover this as you're going to need those skills more and more. Also this is a site to get help, not have work done for you :P
Answer by tigerfoot · Aug 20, 2012 at 01:54 PM
Something like this should work:
var destroyedLookMaterial: Material; //assign this in the Inspector view
function OnCollisionEnter(collision : Collision){
if(collision.gameObject.tag == "player"){
//change current material to the destroyed one
collision.gameObject.renderer.material = destroyedLookMaterial;
}
}
Your answer
Follow this Question
Related Questions
Fireing a tank projectile. 1 Answer
Collision detection for Arrows and Melee. How to properly setup physics/collision? 3 Answers
How can I make a jet script? 0 Answers
Shooting a cannonball. 6 Answers