Aim and fire

Hi,

after have resolved the move smooth problem,now i must say to the enemy “if you have the target in sight start particle system”

at this time,this is the code:

var LookAtTarget:Transform;

function Update () 
{

transform.LookAt(LookAtTarget);

}

Not entirely sure what you’re trying to do, but if you want to trigger particles within a given range you can maybe use an invisible sphere to trigger it.

Yeah. A little more info on what you are doing would help. How do you determine what is considered line of sight? Is it just if a target falls in a given field of view? Are you checking for obstacles?

i must do only a simple enemy who must aim to the player and shoot him.

i have make a prototype for this project, the enemy is a prefab of 2 cube with a particle system :

the red cube search the player and the waypoints , and the cube on the top look at the player and start shooting.

(the grey cube is like a turret)

This work (only in the editor),but the particle system must shoot only when the grey cube is aiming to the player.And i have also tried to build the game for test if all work,but the grey cube doesn’t work and stay freezed in while in the unity editor all work.

var LookAtTarget:Transform;

function Update () 
{

transform.LookAt(LookAtTarget);

}

[/img]

so the question are two:

1.How can i do the enemy shoot the player when is under aim?
2.Why in the editor the grey cube aim to the player and in the build do not anything?

ps: the game is a simple navy space war

can anyone give me the mouse look script? plz

@Mr.badatscripting - If you don’t get an answer immediately, I don’t think asking in unrelated threads will help your cause. I see from your other posts you’ve deleted “everything” Unity. Re-install it all. Go to your standard assets and you have the mouse look script. Additionally go to the Unity Wiki, or if for some weird reason you won’t reinstall, download one of Unity’s sample applications that utilizes either a mouse look and/or the Standard Assets and get it from there. Please stop posting now =D

@Ghostfire - Lookat will always orient the object to point towards the parameter you supply. So that’s good for making your turret face your player. However if you want to see if there is a line of sight to your player, you will most likely want to use a RayCast, starting at your turret and in the direction of your player. If it either returns nothing or is something other than your player you can’t see him/her.