How to make an effect like "Teleport" when the player attacks?

Hello everyone. I want to make an effect when the player attacks, player can teleport through enemy.

It like this photo...(Sorry about my ugly words...)

alt text

now I can attack.(Trigger) but it dosen't look like teleport.(Just go through the enemy)

have any way or idea can make the effect?

2 Answers

2

You could just make an animation that moves the player forward when he attacks, and have a box collider on the enemy (or player)

I'd use raycast.

Draw a racast from player origin to teleport point - if the raycast hits the enemy, the respond accordingly. Then, do another raycast to check for walls and the like, and move the player accordingly. Something like

var hitObj : RaycastHit;
//will look for any solid object along path(not just enemy)
if(Physics.Raycast(Player.transform.position, Vector3.forward, hitObj, portDistance))
{

//check hit object, if the enemy is there hit anywhere long the line, kill it
if(hitObj.tag == "Enemy")
 Destroy(hitobj);
}

Then it's just a matter of moving the player, by whichever method your movement script utilizes.