This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by Cedriking

It been a while since I've used Impact, now i'm trying to do an online game, in this game I have one entity ( EntityPlayer ) and each player have the same entity, what it's strange is that I'm currently using just 2 players, each player have an unique id. I've created two variables inside the main game, and (this.player and this.enemy) and when I first log in with one, I set to that id, and when the second player (the enemy) log in, I set to the enemy id, what it's strange is when I look into my code, both (the enemy and the player) have the same ID after I set the new id to the enemy, they are both EntityPlayer.

How is that possible if I have player and enemy that when I change something to enemy, it's changed also the player variable is changed?

Is there a way that I can have both with EntityPlayer but both aren't the same player or Entity.

Thank you for your help =D

1 decade ago by Cedriking

BTW I use (this.spawnEntity) to create the player and the enemy.

Thank you again.

1 decade ago by Xatruch

i'm not sure if I followed right what you're saying but if you do something like

var a = EntityPlayer );
var player = a;
var enemy = a; = 10;  // 10

it's the same instance so what happens to one will happen to the other.

1 decade ago by Cedriking

Hi, thanks for your help, what I did was:
this.player = this.spawnEntity( EntityPlayer );
this.enemy = this.spawnEntity( EntityPlayer ); = 10; = 20; // 20 // 20

why? they are not the same entity, they are two entities in the game, there is just one of them in both variables.

1 decade ago by mglnunez

I just tried your code in my game but I got the expected result.
Is there another place where you change the id of the entities?

1 decade ago by Cedriking

Hi everyone, just to let you know that I found my problem, I dont know why I did this, but inside EntityPlayer I had = this; when in init function, so that's why every entity of EntityPlayer became :P

Thank you for the help anyway :D
Page 1 of 1
« first « previous next › last »