Game Development Community

Facing

by praju · in Torque Game Builder · 09/28/2010 (9:14 am) · 4 replies

Hi guys,

I want to know how to check whether two players are directly facing each other???

Thanks in advance!!!

#1
09/28/2010 (5:10 pm)
Can you provide more details? Is this a side-view game (i.e. a platformer) or a top-view game? What do you mean by "facing each other"? Please give us some more details on how complex (or basic) this facing sensor function needs to be, theoretically, from the game design standpoint...
#2
09/29/2010 (3:46 am)
Sorry about that!!!

It is kind of a top down soccer game. I need to find out whether a player is exactly facing the ball???? If he is facing directly, then move towards the ball and pass/kick it. Thats the basic idea!!!
#3
09/29/2010 (2:43 pm)
Something along these lines should give you a starting point:
function playerClass:onUpdate(%this)
{
 //don't actually use 0... use a threshold or something
 //also probably want to limit how often this is called
 //and set a distance parameter too.
 if(t2dAngleBetween(%this.getPosition(), $ball.getPosition()) == 0)
 {
   echo("Facing, go get the ball");
 }
 else
 {
   echo("Not facing, how 'bout we use rotateTo or something...");
 }
}
#4
09/30/2010 (4:58 am)
Thanks Patrick!! Thats very useful! I am using rotateTo for rotating, but did not have a condition to check if its facing!!! I will try this out!!!