Page 1 of 1

actions based on position relative to player

PostPosted: Sun Nov 20, 2011 1:54 pm
by j2graves
Okay, I have two actors: Actor A and Actor B. There's an invisible rod going out to the right of actor A, that detects when it's colliding with actor B. If the rod is colliding with actor B, and you press the J key, then actor B will do something. However, there's a problem here. I want to clone actor B, and I want it to be that when you press J, only the clone closest to actor A will respond. How do I make actor B2 detect if actor B1 (or any clone of B for that matter), is between itself and actor A?

Re: actions based on position relative to player

PostPosted: Tue Nov 22, 2011 8:32 pm
by savvy
on the rod put this.

Collision - actorB - repeat ON
Code: Select all
Char* key = GetKeyState();
if(key[KEY_j]==1&&repeat==0)
{
repeat=1;
DO ACTION HERE;
}

repeat is a variable to stop the action happening over and over again.
(an actor variable preferably.)
in the rods draw actor event use.
Code: Select all
char* key = GetKeyState();
if(key[KEY_j]==0&&repeat==1)repeat=0;

This will set repeat back to 0 so you can press j again.

help?

savvy