actions based on position relative to player

Non-platform specific questions.

actions based on position relative to player

Postby j2graves » Sun Nov 20, 2011 1:54 pm

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?
No games to my name...
User avatar
j2graves
 
Posts: 1302
Joined: Thu Aug 16, 2007 6:42 pm
Location: on the other side of infinity
Score: 19 Give a positive score

Re: actions based on position relative to player

Postby savvy » Tue Nov 22, 2011 8:32 pm

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
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest