Game Development Community

SetAimObject Question

by Geo Miller · in Torque Game Engine · 08/10/2005 (11:59 pm) · 5 replies

I have been trying to learn from the Player Target Locking resource, but am having some trouble understanding. I made a post in the resource thread, but it seems to be dead.

I do no understand the setAimObject function. I tried using %client.player.setAimObject(), but I don't know how to get the enemy in correctly and it always reports back to me (when pressing "L" for the setAimObject call) even when just putting in 0, "player.cs (993): Unable to find object: ' ' attempting to call function 'setAimObject'.

My function reads:
function lockOn ( )
{
%client.player.setAimObject(0);
}

So that you can understand what I am trying to accomplish, I am trying to just have one other player (currently an AI player, but later will be a real player) that the player will lock on to no matter the distance, or FOV. Basically I just want the player to be constantly locked on to the enemy object. I am trying to make a two player game where they are both constantly targeting each other no matter where they move. Getting this to work with an AI player for now is fine... although I am curious if changing that to a client that joins later will be hard.

Any strategies/explanations? Thx in advance.

#1
08/11/2005 (12:03 am)
Oh, and also as a clarification... the Player Target Locking resource:
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4077
attempts to add in setAimObject functionality into player.cc, which I believe I have accomplished correctly, but that could be something I did wrong. Tell me any information you might need to help me figure the problem.
#2
08/11/2005 (3:45 am)
That function is different from the lockon() in the resource, thats why it wont work it has no arguments to use at all, you could set it manualy with someting like this i think?

function ManualLockOn ( %client, %targetObject)
{
%client.player.setAimObject(%targetObject);
}

You would then call this with:
ManualLockOn ( %client, %targetObject);

But if you have the two arguments allready you may aswell just go
%client.player.setAimObject(%targetObject);
#3
08/11/2005 (9:43 am)
How do I set up "%targetObject" correctly?
#4
08/11/2005 (2:31 pm)
Well %target object could be any object so it depends what you want to target?
In the resource they use function Player::getClosestBot(%this), Why didnt you use that?

Edit;
Ok, I se , reading over your first post you only want one other player to target,
so what I would do is , just after you create your target ,assign it to a global var.
Like this;
$targetObject = %player;
error("$targetObject set to = "@$targetObject);

So you can target it anytime you like.
#5
02/23/2006 (5:29 am)
Im looking for a way to just look at a player or bot, and press a Target Lock on Button, but there doesnt seem to be anything around that can do that. Has nobody implemented a getAimObject(); for players? It would be very useful instead of raycasting or something?