Question by 
               Maui109 · Mar 08, 2018 at 02:15 AM · 
                c#2d gamespace shooter  
              
 
              Need help with enemy rotation in a 2D space game
I have the script typed out but I can't get the enemy to rotate to look towards the player. The enemy will follow the player, but I can't figure out where I'm going wrong! Please help me! My C# script is as follows! ->
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class EnemyBehavior : MonoBehaviour { public float speed = 0.5f; public Transform Player;
 // Use this for initialization
 void Start()
 {
 }
 // Update is called once per frame
 void Update()
 {
     Vector3 displacement = Player.position - transform.position;
     displacement = displacement.normalized;
     if (Vector2.Distance(Player.position, transform.position) > 1.0f)
     {
         transform.position += (displacement * speed * Time.deltaTime);
     }
     else
     {
         //do whatever the enemy has to do with the player
     }
 }
 
               }
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
On trigger enter void is calling twice 0 Answers
Moving an object on a Grid 1 Answer
Z position moving in 2D space 1 Answer
I can't seem to rotate my character depending on what side he is running to (2D sidescroller) 0 Answers
How to make -Count down Timer on entrance and exit triggers and display remaining time 0 Answers