Author Topic: Targeting with Camera  (Read 570 times)

I'm fairly new to scripting and would like to make a mod that when you put it in, makes the target in your camera sight follow you(AIPlayers). How would you go about targeting something with camera?

If you mean what I think you mean, try this.
Code: [Select]
%start = %obj.getEyeVec();
%vec = vectorScale(%obj.getEyeVector(), DISTANCE);
%end = vectorAdd(%start, %vec);
%raycast = containerRayCast(%start, %end, $Typemasks::PlayerObjectType);
if(isObject(%hit = getWord(%raycast, 0)))
{
   if(%hit.getClassName() $= "AIPlayer")
   {
      %hit.setMoveObject(%obj);
   }
}
This will make any bot that %obj is looking at follow %obj.

Thanks, although I didnt need the whole code since I need practicing.

Oh well :D

If you mean what I think you mean, try this.
Code: [Select]
function bot() {%start = %obj.getEyeVec();
%vec = vectorScale(%obj.getEyeVector(), DISTANCE);
%end = vectorAdd(%start, %vec);
%raycast = containerRayCast(%start, %end, $Typemasks::PlayerObjectType);
if(isObject(%hit = getWord(%raycast, 0)))
{
   if(%hit.getClassName() $= "AIPlayer")
   {
      %hit.setMoveObject(%obj);
   }
}
This will make any bot that %obj is looking at follow %obj.
« Last Edit: September 10, 2009, 12:08:50 AM by Deep2 »

Well, you have to put that all in a function and define the %obj. I think you should setup %obj as %client.camera. I think...

Well, you have to put that all in a function and define the %obj. I think you should setup %obj as %client.camera. I think...
%obj is a player or bot.

%obj is a player or bot.
Well, can you get the Eye vector of the camera? The topic name says with the camera, so I assumed you meant %obj to be the client's camera.

Well, can you get the Eye vector of the camera? The topic name says with the camera, so I assumed you meant %obj to be the client's camera.
I believe so.

If the eye vector doesn't work, try the getForwardVector.

I'm fairly new to scripting and would like to make a mod that when you put it in, makes the target in your camera sight follow you(AIPlayers). How would you go about targeting something with camera?
Call "the target in your camera sight" "raycast from eye".