3rd Person, target locking, like 3D fighting games
by Andre C. Anderson · in Torque Game Engine · 08/08/2002 (2:04 pm) · 4 replies
I'm trying to mod Torque (in script if possible) to make the player's movements relative to its current target, like in Soul Caliber for example.
When you move to the left or right you circle strafe around the target. When you move forward or backward, you move closer to or further away from the target. Basically, you ALWAYS face the current target. If there was a "player.lookAt" setting/function that would constantly force the player to look at the current target it would work fine, but I can't find anything like this in the engine and it seems like it should be there.
I know someone has done this sort of thing before. If you know a simple way to do it, please let me know. I've been trying to make a new class to do it and it, but I think I'm writing too much code to make it work (badly).
When you move to the left or right you circle strafe around the target. When you move forward or backward, you move closer to or further away from the target. Basically, you ALWAYS face the current target. If there was a "player.lookAt" setting/function that would constantly force the player to look at the current target it would work fine, but I can't find anything like this in the engine and it seems like it should be there.
I know someone has done this sort of thing before. If you know a simple way to do it, please let me know. I've been trying to make a new class to do it and it, but I think I'm writing too much code to make it work (badly).
#2
Is there a main loop for things like this where I should put it?
08/17/2002 (9:26 am)
That's how I got this far was from that example, but I couldn't find a loop of some sort to continue making the player look at his target.Is there a main loop for things like this where I should put it?
#3
When the fight starts, you should make a call to this function. Obvoiusly there will only be 2 clients active during the fight so we must get the client->player ID's.
In your spawn function add these lines.
Assuming we have the client (%client)
08/17/2002 (4:17 pm)
I would know how to write it though scripting but adding a loop to the engine I dont know how yet.When the fight starts, you should make a call to this function. Obvoiusly there will only be 2 clients active during the fight so we must get the client->player ID's.
In your spawn function add these lines.
Assuming we have the client (%client)
// This checks the clients and chooses the one other than you.
for(%i = 0; %i < 2; %i++) // May be a ">" instead I cant remember
{
%cl = ClientGroup.getObject(%i);
if(%cl != %client)
{
%targ = %cl;
keepTarget(%client, %targ);
}
}
//-------------------------------------------------------
// Heres the function you must add.
// Assuming you have added the needed functions to the player.cc files this should work ok.
funtion keepTarget(%client, %targ)
{
if(!isObject(%targ.player)) // Make sure we have a valid fighter
return;
%pos = %targ.player.position;
%client.player.setAimLocation(%pos);
// We now repeat every 1/4 of a sec, this may not be fast enough to be smooth but any lower could crash the game.
schedule(250, 0, "keepTarget", %client, %targ);
}
#4
08/17/2002 (8:24 pm)
Thanks, Sam! I didn't know there was a "schedule" function. This should work. I'll post back here when I get it working.
Torque Owner Sam Guffey