Quantcast
Channel: Questions in topic: "rotating"
Viewing all articles
Browse latest Browse all 173

Making a GameObject rotate faster as the player gets closer to it

$
0
0
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

Viewing all articles
Browse latest Browse all 173

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>