how to move the player away when it's hit

Hello, i'm trying to make a tank game. and it just won't work for the player to die. I wanted to test it by tagging the enemy projectile. but the projectile disappears when it collided to the tank and a huge explosion came.. but i didn't "die" are there any other ways to do this?? here is my code

private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "rocket") { dead = true; }


function LateUpdate() { if(dead) {

transform.position = Vector3(100,100,100); dead = false; } }

If your player die, you have to think of what's going to happen next. Is it going to respawn elsewhere, or displaying a game over splash screen ? The destruction seems unlikely, you don't need it either way.

What happen if you do a Debug.Log( hit.gameObject.tag ); in OnControllerColliderHit? Anyway for your tests, I'm not sure playing with your player transformation is a good idea, better to do a CharacterController.Move or something like that.

What do you mean by die? Do you want the tank object to be destroyed, etc. We need more information to help you.

yes i want the tank to be destroyed. but the tank is the player.. i control it what do you need to know more ?

the moving to 100, 100, 100 was just to test if the script worked correctly

is there a way to destroy it when it hit a explosion ?