Misael644
Member
Hello again! I'm here because I'm having problems with my game's collision event.
Basically, I'm trying to simulate a starfield that works like this:
I have an object called "obj_star", in the game, it is spawned by "obj_starcreator", which spawns a star in a random place on the screen. And so that the stars don't move in random directions around, I created an object that I call "obj_ramp", to give the illusion that you are traveling through a starfield, just like in this Wikicommons gif: https://upload.wikimedia.org/wikipedia/commons/e/e4/StarfieldSimulation.gif
The "obj_ramp" works like this:
I have a variable called "RampD" (D is for direction), and I have four ramps on the screen, each of which occupies 1/4. Each of the ramps has a RampD variable that works like this:
if a star collides with one of the ramps, if the rampD variable is number 0, the "obj_star" has to go to the northwest, and even to other numbers; 1 for NE, 2 for SE and 3 for SW.
The problem is that all the stars in the room will go in a specific direction, no matter which "obj_ramp" it is colliding with. I think it has to do that all stars share a single variable for direction, no matter the instance.
The code works like this:
Do you have any idea what I could do to make all the stars move in the given direction?
Basically, I'm trying to simulate a starfield that works like this:
I have an object called "obj_star", in the game, it is spawned by "obj_starcreator", which spawns a star in a random place on the screen. And so that the stars don't move in random directions around, I created an object that I call "obj_ramp", to give the illusion that you are traveling through a starfield, just like in this Wikicommons gif: https://upload.wikimedia.org/wikipedia/commons/e/e4/StarfieldSimulation.gif
The "obj_ramp" works like this:
I have a variable called "RampD" (D is for direction), and I have four ramps on the screen, each of which occupies 1/4. Each of the ramps has a RampD variable that works like this:
if a star collides with one of the ramps, if the rampD variable is number 0, the "obj_star" has to go to the northwest, and even to other numbers; 1 for NE, 2 for SE and 3 for SW.
The problem is that all the stars in the room will go in a specific direction, no matter which "obj_ramp" it is colliding with. I think it has to do that all stars share a single variable for direction, no matter the instance.
The code works like this:
GML:
//in obj_star event colliding with obj_ramp:
switch(obj_ramp.RampD){
case 0:
direction = irandom_range(90,180);
break;
case 1:
direction = irandom_range(0,90);
break;
case 2:
direction = irandom_range(270,0);
break
case 3:
direction = irandom_range(180,270);
break;
};