Hello!
In my game i have two spheres, and i move them via Rigidbody.AddForce but one sphere is the player, the second is the enemy.
When i move my player sphere via imput and addforce it rotates like in real life.
But my enemy sphere has a simple AI to look at player sphere and to move forward also via addforce, but the enemy is not rotating like the player. Why?
Here is the enemy shpere script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class EnemyController : MonoBehaviour {
public float speed;
private Rigidbody rb;
public GameObject player;
void Start () {
rb = GetComponent<Rigidbody>();
}
void FixedUpdate () {
transform.LookAt(player.transform);
rb.AddForce (transform.forward * speed);
}
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag ( "Player"))
{
player.GetComponent<PlayerController>().winText.text = "You lose!";
Time.timeScale = 0;
}
}
}