E
EZcomedy
Guest
BACKSTORY:
The issue I believe is with my ID, I’m working on an RTS style game, where my spawner lets say a space station spawns units every 3 seconds of a player object “spaceship”. The battlefield has units running around randomly and when they spot a player spaceship and they attack it. I have an ability that when selected and I press “C” my space ship/ships will cloak and become undetectable or take damage. The code works by having the enemy ship exit it’s code to attack when my spaceships are cloaked.
THIS ISSUE:
Only the first instance created by the spawner stays undetectable. It’s as if it uses the original object and then all the other instances don’t have the ID of the original object. An interesting side note is if I have the original spaceship selected with multiple instances of the same ship and press “C” to cloak...the code works...so it's something with the specific original object.
Is this normal? What should I be looking to correct specifically? Like learning to pass the ID to all instances. Since it's an RTS I will be having multiple Instances of the same “player” so maybe that is the issue? GMS2 won’t allow you to have multiple instances of the same object?
Here is a link to help make my point:
and here is the code when they are detecting my ship:
var enemy = instance_nearest(x, y, oPlayer_Parent);
//Exit If Enemy Is cloaked
if (! instance_exists(oPlayer_Parent)) exit;
if (oPlayer_Parent.cloak = true) exit;
if (collision_circle(x, y, 150, enemy, false, false)) {
mp_potential_step_object(enemy.x, enemy.y, spd, oWall);
} else if (! collision_circle(x, y, 150, enemy, false, false)) {
alarm_set(alarm[0], 1)
}
The issue I believe is with my ID, I’m working on an RTS style game, where my spawner lets say a space station spawns units every 3 seconds of a player object “spaceship”. The battlefield has units running around randomly and when they spot a player spaceship and they attack it. I have an ability that when selected and I press “C” my space ship/ships will cloak and become undetectable or take damage. The code works by having the enemy ship exit it’s code to attack when my spaceships are cloaked.
THIS ISSUE:
Only the first instance created by the spawner stays undetectable. It’s as if it uses the original object and then all the other instances don’t have the ID of the original object. An interesting side note is if I have the original spaceship selected with multiple instances of the same ship and press “C” to cloak...the code works...so it's something with the specific original object.
Is this normal? What should I be looking to correct specifically? Like learning to pass the ID to all instances. Since it's an RTS I will be having multiple Instances of the same “player” so maybe that is the issue? GMS2 won’t allow you to have multiple instances of the same object?
Here is a link to help make my point:
and here is the code when they are detecting my ship:
var enemy = instance_nearest(x, y, oPlayer_Parent);
//Exit If Enemy Is cloaked
if (! instance_exists(oPlayer_Parent)) exit;
if (oPlayer_Parent.cloak = true) exit;
if (collision_circle(x, y, 150, enemy, false, false)) {
mp_potential_step_object(enemy.x, enemy.y, spd, oWall);
} else if (! collision_circle(x, y, 150, enemy, false, false)) {
alarm_set(alarm[0], 1)
}