- Home /
 
 
               Question by 
               mirkop · Dec 16, 2016 at 01:45 PM · 
                rotationgameobjecttransformvector3quaternion  
              
 
              Instantiate GameObject towards player
I have the following code inside my player Game Object. I create an enemy from prefab, and I would like it to move towards player. Now it always goes up.
  Enemy = (GameObject)Instantiate(
                 Resources.Load("Enemy"),
                 new Vector3(-16, 10, 1),
                 Quaternion.identity);
     
             Enemy.GetComponent<Rigidbody2D().AddForce(Enemy.transform.up * 100);
 
               I suppose it would be better to make an empty game object to the scene, and add this script there instead of being inside player Game Object, or I am totally lost?
Any help would be much appreciated. Taking my first steps with Unity.
               Comment
              
 
               
              Your answer