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!!!
I want to know how to check whether two players are directly facing each other???
Thanks in advance!!!
About the author
#2
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!!!
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!!!
Ignis
Ignis Design LLC