Question by
Gareth48 · Nov 16, 2015 at 03:04 PM ·
aienemyacceleration
How to make ball AI
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<Rigidbody>().AddTorque(cross * angleDiff * force);
}
}
Comment
Your answer
Follow this Question
Related Questions
Enemy Spawn System Glitch 1 Answer
More advanced Top down enemy AI 0 Answers
Enemy AI problem 0 Answers
How to enemy animation attack player 0 Answers
Vector 2 only using x (Enemy AI) 1 Answer