Artificial intelligence detailed help

Haven't the slightest clue how to make an object move around freely. Please don't simply spam scripts and links as you did in all the other AI questions as I have searched them and none really explain how to do it. Obviously people that posted these answers Thought that the owner already has a clue about AI, although in several posts the poster said he has no clue where to start, so pelase explain to me how to actually Make an object, animated if possible, simply roam the terrain without any instructions and without falling off it.....

First, I would recommend reading Ricardo's links; as mentioned, semi-autonomous generic AI isn't easy. I will nevertheless try to give an example here. Please bear in mind this is going to be basic, and best to get the idea with which to start.

A good way to tackle AI is to implement a script that controls an object in the same way a human does. This is best for situations where AI and humans both control the same kind of object [eg. a fighterplane], but works in other situations too.

To begin, detach the controls from the actions. If you have a character script with boolean or float variables for moving, shooting etc [ eg. isShooting (bool) or movingForward (float) ], you can use a second script to control those values either by human or computer commands, while the object script itself is what actually does the moving or shooting [ transform.Translate(0, 0, movingForward); ].

Take a car game, where the car script handles moving the car by carSpeed and turning by steerBy. Those variables should be private to the car script, so we make functions to access them, like:

function Steer(amount : float) {
  steerBy = amount;               // change steering value by whatever is passed

Then our human controls object simply finds the object's car script (carScript) and calls the Steer function:

carScript.Steer(Input.Axis("Horizontal"));   // uses the human input to steer

To control this same object with AI, we replace the key controls secondary script with an AI secondary script, which can interface like so:

carScript.Steer(turnRate);  // turn by the AI's variable for steering

This uses the AI script's own variable, called turnRate here, to control the car. All we need now is to change this number and we can steer the car, without fiddling with the car script. For random roaming, simply plug in a sin wave [turnRate = Mathf.Sin(Time.time);]. You can do anything to that number; so long as you get something between +1 and -1, the computer 'plays' by the same rules as the human.

How do you actually detect obstacles or the playfield edge, and transfer this to changing a steering value? Well, I understand this might be the crux of your question but it's also where that 'vastness' really comes in. This is a complex problem, very much determined by your particular game. You can use raycasts forward to the left and right slightly, then turn away from whichever is closest. You could steer toward an object by finding the difference between the "lookAt" angle and the current direction, then steering by it.

Hopefully those basic steps will help you to apply higher-level AI techniques to Unity!

If you have no clue about AI, then this is the wrong place to try and get one - it's too broad a topic. It seems that what you want is a tutorial, but as Unity provides no built-in steering components, there's little you'll be able to do in a pointy-clicky fashion. You could use UnitySteer to accomplish exactly what you want, as shown on this demo, but without a good understanding of the basics you'd only be fiddling with black box.

I'd recommend you start with, which contains some free resources on top of the paid ones. The main topics you'll want to read up on are:

  • Autonomous steering
  • Obstacle avoidance
  • Pathfinding (not necessary for wandering aimlessly, but it'll probably be useful later on)

You may also want to check out this navigation framework, as the authors are active on the forums, but I'm not sure if they have tutorials or not.