I am trying to make A shperical object rotate and the rotation speed to get faster the nearer it is to the player.
I already have it rotating with a changing speed but it gets slower the closer it is to the player with this script:
using UnityEngine;
public class Enemy : MonoBehaviour {
public float speed_for_distance = 50f;
public GameObject player;
// Update is called once per frame
void FixedUpdate ()
{
transform.Rotate(Vector3.back, 180 * Vector3.Distance(player.transform.position, transform.position) / 10 * Time.deltaTime);
}
}
I have tried dividing the vector3(stuff) by Time.deltaTimeinstead of multiplying but that just made it spin VERY quickly instead.
Any help would be appreciated and thank you in advance