- Home /
Freelancer of Freespace type Enemy Ai
Hello I've been trying to program a freelancer or a freespace style game, and I'm having a hard time programming the Ai for the enemy.I don't have a clue on where to start... If somebody had some literature or tutorials where I could learn this, would be nice I he could post a link or something...
Here is what I've got so far : https://sites.google.com/site/dimitrijejankov/3d-space-shooter
I somebody needs the source contact me :D
Answer by Rideck · Sep 08, 2011 at 10:00 AM
that is a nice game mate, it's what i have been doing now for awhile but have got nowhere lol any chance i could have your scripts as a start point and your enemy AI looks good to me but i am a noob as i am still learning and would love to see how you have done the scripts for it
Answer by hollisb · May 01, 2012 at 07:11 PM
This is a script that I made that allows any sort of Object to follow you and stop right in front of you, feel free to edit it to fit with what you want, you would have to figure out how to make the enemies bank around you in sort of an oval shape, so write that into the script somewhere!
public Transform target;
public int moveSpeed;
public int rotationSpeed;
public int maxDistance;
private Transform myTransform;
void Awake() {
myTransform = transform;
}
// Use this for initialization
void Start () {
GameObject go = GameObject.FindGameObjectWithTag("Player");
target = go.transform;
maxDistance = 2;
}
// Update is called once per frame
void Update () {
Debug.DrawLine(target.position, myTransform.position, Color.yellow);
//Look at target
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
if(Vector3.Distance(target.position, myTransform.position) > maxDistance) {
//Move towards target
myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
} }
}
Your answer
Follow this Question
Related Questions
Space Shooter Player 2 ship is flipping when going into Play Mode 0 Answers
Any one have an AI spaceship script 1 Answer
Enemy Spaceship Movement AI Curve Movement Need help Please 0 Answers
Advice on my Ship AI... 4 Answers
How To Make Basic AI? 3 Answers