Hello GE Users.
This topic is a bit old but, i was interested in this problem.
SO I am assuming that the two (or multiple) players are the same base actor (clones), not saying that you can't have different clones with different
behavior and animations, but what's the point of them being clones then?
now let's say as in my demo below that the player have those controls :
Right Key - to move right
so instead of using fixed key down / up events with the same key, you need to have 4 int Actor variables keys representing the controls for that particular
clone and then using an abstract KeyDown with "any key" and checking the the keyboard state in a draw actor event with the function char * getKeyState()
and storing it in a global keyboard variable.
- Code: Select all
// an example of Key Down "any key" event
if(keyboard[ attackKey ] == 2 && state != attack) // Attack key is pressed
{
Attack(clonename);
}
if(keyboard[ jumpKey ] == 2) // Jump key is pressed
{
if(canJump == 1)
Jump(clonename);
}
Note : Assigning the keys in the first place should not be done in the players->Create Actor event , because then ALL the clones will have the same keys
instead you should use another actor called ClonesManager to do so..
ClonesManager -> Create Actor
- Code: Select all
// Assign keys for the first clone
// Note: you can find the all keys enumeration in GE Scripting Refference
getclone("player.0")->rightKey = KEY_d;
getclone("player.0")->leftKey = KEY_a;
getclone("player.0")->jumpKey = KEY_w;
getclone("player.0")->attackKey = KEY_SPACE;
// now say that we have another clone in the editor
// we just kive it different keys here, like so:
// getclone("player.1")->rightKey = KEY_RIGHT;
// getclone("player.1")->leftKey = KEY_LEFT;
// getclone("player.1")->jumpKey = KEY_UP;
// getclone("player.1")->attackKey = KEY_RETURN;