Bounce Back

I have a third person shooter game i am working on. I would like to have the character bounce away from an enemy when the enemy damages the character. both characters use character controllers. I have tried getting the eulerAngles of the enemy and then using those to move the character in the direction the enemy is facing, but i can’t get it right.

these are the variables-

var zombie : Transform;

var speed : float = 100;//speed for bounceback

var hieght : float = 10;//how high is the bounceback

here is the script that detects an enemy hit the character-

function OnTriggerEnter (enemy : Collider) {
if(enemy.gameObject.tag == "zombie"){
	zombie = enemy.transform;

this is bounceBack() -

function bounceBack () {
var controller : CharacterController = GetComponent(CharacterController);
    moveDirection = Vector3(zombie.eulerAngles.x, hieght, zombie.eulerAngles.z);
    moveDirection *= speed;
    moveDirection = transform.TransformDirection(moveDirection);
    controller.Move(moveDirection * Time.deltaTime);


The script gets no errors, but the character just teleports, it isn’t fluid.

It seems like your bounceBack function is accessed only once - after an object enters the trigger. (Time.deltaTime is also called only once)
So you should probably add a for() cycle in your bounceBack() function.