How would I do this?? could use some help

D

Den

Guest
So in the game i'm making the player can possess an enemy which I have manged to do.
The only issue is how can I make the player possess just one enemy at a time?

Here's the code, it's just if I take control of one it controls all of them. Is there a way to make each enemy react differently to the player??
Code:
//Step

///Check if player is over enemy
if(place_meeting(x, y, obj_player)) {
    image_index = 2;
 
    with (obj_player)
    {
      if(obj_player.interact_key)  instance_destroy();
    }

}else if(!place_meeting(x,y, obj_player)) image_index = 0;

if(instance_exists(obj_player)) {
//AI script goes here
}else if(!instance_exists(obj_player)) {
    enemy_input_scr();
    image_index = 1;
}
 

Zerb Games

Member
Is this all of the code? You aren't supplying any information about what enemy_input_scr, so should I assume that is an empty script? Also what object is this in, the enemy?
 
D

Den

Guest
Is this all of the code? You aren't supplying any information about what enemy_input_scr, so should I assume that is an empty script? Also what object is this in, the enemy?
Enemy_input_scr just lets the player move the enemy. It's just standard platformer type movement code. The players movement code is in the player obejects step so if it doesn't exist there's no longer any input, so while the player doesn't exist the enemy runs its own input script
 

Zerb Games

Member
Enemy_input_scr just lets the player move the enemy. It's just standard platformer type movement code. The players movement code is in the player obejects step so if it doesn't exist there's no longer any input, so while the player doesn't exist the enemy runs its own input script
Did you ever think perhaps the problem with ever enemy being moved could lie in the script that moves the enemies?
 
D

Den

Guest
Did you ever think perhaps the problem with ever enemy being moved could lie in the script that moves the enemies?
Yeah I know that lol what I need is a way for the enemy to check that the player is only interacting with it and not another enemy too,
That's the reason there all reacting the same coz I don't have some sort of check that makes each encounter unique.
 

sp202

Member
Looks like you're missing brackets after the second place_meeting. Use a variable to check whether the enemy is being controlled. When the player takes control, controlled=true:
Code:
if controlled=true
{
enemy_input_scr()
}
 
Top