- Home /
Play animation at player's location
Hello,
is there any way I could play animation at player's position. It's 2D game. Basicly, I have 2 animations, for left and right. I made them inside unity animation system. I currently have this:
foreach(Touch touch in Input.touches)
{
if (touch.phase == TouchPhase.Began)
{
fp = touch.position;
lp = touch.position;
}
if (touch.phase == TouchPhase.Moved )
{
lp = touch.position;
}
if(touch.phase == TouchPhase.Ended)
{
if((fp.x - lp.x) > 80) // left swipe
{
animation.Play(animationLeft.name);
}
else if((fp.x - lp.x) < -80) // right swipe
{
animation.Play(animationRight.name);
}
else if((fp.y - lp.y) < -80 ) // up swipe
{
v3_moveDirection.y = f_jumpSpeed;
}
}
}
With this script when I swipe to left on the screen animation is played but it is not played at player's location so my player goes back to the position of the animation. I hope you'll understand what I'm trying to achieve. Greetings!
Comment