Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

How to make ball AI

$
0
0
I want to create an enemy for the roll-a-ball tutorial that follows the player and has acceleration. here's the current script: using UnityEngine; using System.Collections; public class Homing : MonoBehaviour { public Transform target; public float force = 10f; void Update () { Vector3 targetDelta = target.position - transform.position; float angleDiff = Vector3.Angle(transform.forward, targetDelta); Vector3 cross = Vector3.Cross(transform.forward, targetDelta); GetComponent().AddTorque(cross * angleDiff * force); } }

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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