Enemy AI (418067)

How would u creat an enemy AI Sphere that run toward nother cpher character and crash into him causing him to move.

i would suggest looking at the 3d tutorial - there is a section on AI, along with help on colliders

Thnx WatermelonMana

Wat 3D tutoriauls

The tutorials are located here on the Unity website.

I have to have itunes to play them and i have to download em. Im not gonna get I tunes

I’d love to know what leads you to believe you need iTunes to read PDF files or open Unity projects.

i went on Unity;s website and it says download itunes to watch this video tutorial

I found what u were talking about and i downloaded it but i cant find the tutorials in the file

i’m sure you dont really need itunes you just need quicktime (like adobe flash or shockwave) which can be standalone or is by default a part of itunes.

the request for itunes is just a marketing/advertising gimick to catch the ill informed

Can someone answer my question from the beginning the tutorial didnt help me at all

In this thread, http://forum.unity3d.com//viewtopic.php?t=56264&highlight=finite+state+machine+project I shared a Finite State Machine Project and there´s a state there called ChasePlayerState (it´s a C# class and it´s in the file NPCControl.cs).

What you need is in the method Act of this state. The parameter “player” will be the target you want to reach and “npc” is the object you want to chase the target. You won´t need all the framework I wrote, just create variables in your NPC class, asign them to the correct object (you´ll probably need just to rename “npc” to “gameObject”) and past the code inside your Update method. If you need to translate it to JavaScript just ask.

Both your target and your npc will need Rigidbody in order to this code works.

I agree with Dart. If you want to make a good AI you should look into Finite State Machines. While your needs might be a little simpler then that it is a good place to start.

I would suggest a script that calculates the angle between two objects transforms and then moves along that angle (I believe Quaternion.Angle does this but I’m not sure). Unity’s help files have a script somewhere in them that pushes objects from another. If I find that I’ll post it. Anyway that is everything you need.

thnx ill try doing that

i downloaded the file from the link and i got a bunch of errors when i played it and the scripts donth vae errors but it has somwthing to do with terrian and when i play it and close the error toolbarits just a frozen screen with a cylinder and its nose far away and the pause button is not on

Can anyone help me.

Can you give more detail about what is going on in the game and what you want the ball to do? It’s not easy to suggest AI techniques without knowing exactly how the game should be operating.

O.K, I will explain what I am trying to do!
Im trying to make a sumo wrestling like type of game. In my game ur a sphere who has to knock off the other spheres off a platform and the other spheres also have to try to push u off the platform. Oh and im going to make a couple of levels with a boss sphere whos gonna try to push u off before u push him off and that boss wil be the only sphere u will be facing in the end of the level. He will be in the same scene as the other spheres were in that level. Oh and iI think i might make him fall out of the sky on to the game plaform, when i beat all the others spheres off the platform. GET THE PICTURE.

  • I AM REALLY BAD AT EXPLAINING THINGS!!!

Like I said, the chasing script is really simple and it was in my project. You´ll also need to attach a Rigidbody to your ball.

var player : GameObject;
var rotVel : float = 5;
var moveVel : float = 10;

function Update()
{
        var vel : Vector3 = rigidbody.velocity;
        var moveDir : Vector3 = player.transform.position - transform.position;


        transform.rotation = Quaternion.Slerp(transform.rotation,
                                                  Quaternion.LookRotation(moveDir),
                                                  rotVel * Time.deltaTime);
        transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);

        vel = moveDir.normalized * moveVel;

        rigidbody.velocity = vel;
}

This is a neat script o.O I haven’t been able to grasp scripting, so I was wondering if it is difficult to make the script apply to any object with a tag, such as “Player”, instead of inserting a predetermined player for it to follow. I’m thinking something like in an rpg, if a “Player” enters the range, it chases. If it only looks for the specific player that was put into the script, it would kind of… well… not work. The range part/trigger type thing is out of my abilities for now, but does anyone know about making the script more general to “Player” tag or something? Any help is much appreciated.