• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM New Instances Depth Question

J

JarodTheGreat

Guest
I am creating a game kind of like Postal, so there is a lot of killing. How ever my question is every time I kill a person on top of a dead person, the new dead person instance spawns below the old one. How can I make it so it doesn't spawn below the old instance?
 
T

TDSrock

Guest
Check if there is already a dead person on the ground, if so decrease the depth of the new instance.
 
J

JarodTheGreat

Guest
Check if there is already a dead person on the ground, if so decrease the depth of the new instance.
The problem is if I were to do that. When bodies do stack up on top of each other, their depth would infinitely decrease. I liked how it was back with Game Maker 8.0 and older versions where new instances always spawned above each other if each instance had the same depth. If I can't fix this issue, its not going to prevent me from working on the game. But it is annoying. It really doesn't matter if there isn't no fix or option to change this problem.
 
J

JarodTheGreat

Guest
I might try depth = -y however I don't like the idea.
 
T

TDSrock

Guest
The problem is if I were to do that. When bodies do stack up on top of each other, their depth would infinitely decrease. I liked how it was back with Game Maker 8.0 and older versions where new instances always spawned above each other if each instance had the same depth. If I can't fix this issue, its not going to prevent me from working on the game. But it is annoying. It really doesn't matter if there isn't no fix or option to change this problem.
You'd much sooner see your game crash due to the instance count then reaching (-2^32)+1. So I see no reason not to do this.
 
J

JarodTheGreat

Guest
You'd much sooner see your game crash due to the instance count then reaching (-2^32)+1. So I see no reason not to do this.
I have a very strong computer, but I understand others may not. So I'd just go with your suggestion, and have bodies disappear instead of keeping them in place till the level ends. Like probably give them 1 minute to stay or till they are no longer on the screen.
 
B

bojack29

Guest
Why not when they die do something like
Code:
depth = -instance_number(obj_deadBody);
 
T

TDSrock

Guest
I have a very strong computer, but I understand others may not. So I'd just go with your suggestion, and have bodies disappear instead of keeping them in place till the level ends. Like probably give them 1 minute to stay or till they are no longer on the screen.
Computer power doesn't really matter that much concerning this. What is a much more interesting idea if you want to prevent players from having the game lag is running some additional logic which checks real_fps and room_speed. real_fps should remain the same as room_speed, if not it indicates that there is some lag. When you detect lag delete like the 10 oldest body's and keep on doing this check. It would be a compromise between having all of the dead body's and none. But what I suspect you'll see that even computers built 5-6 years ago will handle tons of instances quite well, especially if all of the instances are running no code at all. If you can make it so the dead body's freeze up to the point where they are only drawn via a surface you could probably have hundreds of thousands of dead body's before noticing anything in terms of performance.

I think you are over-concerning yourself with small moot points. There are ways to fix the problems you are referencing. I mean you are (presumably) working in a 2d environment. This means you are working with instances and sprites most of the time. Maybe bones if you chose to animate that way. But that still comes no where close to the amount of data games like Halo 3 were sending to the Xbox's GPU.
The depth = -instance_number solution provided by @bojack29 is an simple and elegant solution. Just keep in mind that the objects you want to be overlayed on-top of the dead bodies(maybe your floor and foreground items) should have a depth such that the instance_number value won't realistically ever exceed it. Probably around -100000 should serve well enough, if not add an extra zero.
 
B

bojack29

Guest
You could actually do away with this whole process. It would be best if you could somehow draw these sprites to a surface and delete the object itself. It would save you all of the overhead and you could have infinitely as many objects as you like.
 
T

TDSrock

Guest
You could actually do away with this whole process. It would be best if you could somehow draw these sprites to a surface and delete the object itself. It would save you all of the overhead and you could have infinitely as many objects as you like.
This won't work if there are any ragdol things going on though. A detail we don't know about currently.
 
B

bojack29

Guest
This is assuming of course that the objects are static and no longer collidable. Otherwise you'll have to do as TDSrock said, you'll have to come up with some kind of compromise where you delete and retain objects. GM has memory limits so don't get too crazy.
 
Top