Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
0 registered members (), 938 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Object Detection #143202
07/24/07 18:50
07/24/07 18:50
Joined: Nov 2006
Posts: 193
England
RyuShinji Offline OP
Member
RyuShinji  Offline OP
Member

Joined: Nov 2006
Posts: 193
England
how do i check if anouther object is to the left, right, infront or behined
the player object

Last edited by RyuShinji; 07/24/07 19:54.
Re: Object Detection [Re: RyuShinji] #143203
07/24/07 23:52
07/24/07 23:52
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Well, here's a little example.

Code:

entity* ent1;
entity* ent2;
var offset[3];

DEFINE youPos, skill10;
DEFINE oFront, 1;
DEFINE oBack, 2;
DEFINE oLeft, 3;
DEFINE oRight, 4;

Action Object1
{
ent1 = my;
while(1)
{
// get the offset
vec_diff(offset, ent2, ent1);
// normalize the offset relative to me
vec_set(temp, my.pan);
vec_inverse(temp);
vec_rotate(offset, temp);
//
if (abs(offset.x) >= abs(offset.y))
{
if (offset.x > 0)
{my.youPos = oFront;}
else
{my.youPos = oBack;}
}
else
{
if (offset.y > 0)
{my.youPos = oRight;}
else
{my.youPos = oLeft;}
}
}
}

Action Object2
{
ent2 = my;
}



Object1's skill10 (.youPos) will be set to a flag (oFront, oLeft, ...) if Object2 is (in front, left, ...).


xXxGuitar511
- Programmer

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1