Question by 
               Mazhar_Taylan · Feb 27, 2017 at 11:43 AM · 
                c#animation2d2d game2d animation  
              
 
              Animation location problem!
Hi! I am make 2D Catch Game. I have a problem. Enemy touch my player start player animation but player catch other enemy animation still play old location(enemy touch point). I want to play animation on my player new location.

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class PlayerKontrol : MonoBehaviour {
 
     public GameObject MyMessage;
     public float Speed;
 
     void Start() {
     }
 
     void Update () {
 
     float horizontal = Input.GetAxisRaw ("Horizontal");
     Vector2 way = new Vector2 (yatay, 0.0f).normalized;
         Move (way);
 
 
 }
 
 void Move (Vector2 way) {
 
     Vector2 min = Camera.main.ViewportToWorldPoint (new Vector2 (0, 0));
     Vector2 max = Camera.main.ViewportToWorldPoint (new Vector2 (1, 1));
 
     max.x = max.x - 0.6f ;
     min.x = min.x + 0.6f;
 
 
     Vector2 location = transform.position;
     location += way * speed * Time.deltaTime;
     location.x = Mathf.Clamp (konum.x, min.x, max.x);
     transform.position = location;
 }
 
     void OnTriggerEnter2D(Collider2D obje)
     {
         if (obje.tag == "Enemy") {
             MyMessageAnimation ();
         } 
 
     }
 
 
     void MyMessageAnimation(){
 
         GameObject message = (GameObject)Instantiate (MyMessage);
         message.transform.position = transform.position;
     }
 }
 
 
               
                 
                problem.png 
                (42.0 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Problem with Jump Animation 0 Answers
How do I stop an animation from looping? 1 Answer
Animation Script on GetKeyPressed 0 Answers
How to add alternate idle directions to a top-down game 0 Answers