G
Grimbel
Guest
Hello everyone!
In my game, the player object may happen to collide with multiple instances at the same time. All of those instances come from a same object, but some of them may carry different values for the same variable. What I need to do is to take the highest of all those values and to ignore or discard the rest. How can I do that?
I can give an example if necessary:
There are 3 different instances called "o_wall", all of them with the variable "z_ground_". In one of them the variable "z_ground_" is equal to 0, in the second one it is equal to 16, and in the last one it is equal to 32. I need to take in consideration the value of the last one (32) and ignore the other 2.
At the moment, with my current code, the player object just takes one of those three values, but I can't choose which one. This is what it looks like:
Thank you in advance for helping. I hope what I am asking to do is clear enough.
In my game, the player object may happen to collide with multiple instances at the same time. All of those instances come from a same object, but some of them may carry different values for the same variable. What I need to do is to take the highest of all those values and to ignore or discard the rest. How can I do that?
I can give an example if necessary:
There are 3 different instances called "o_wall", all of them with the variable "z_ground_". In one of them the variable "z_ground_" is equal to 0, in the second one it is equal to 16, and in the last one it is equal to 32. I need to take in consideration the value of the last one (32) and ignore the other 2.
At the moment, with my current code, the player object just takes one of those three values, but I can't choose which one. This is what it looks like:
Code:
var _block;
if place_meeting(x+horizontal_speed_, y, o_wall_) {
_block = (instance_place(x+horizontal_speed_, y, o_wall_));
if _block.z_ground_ > z_ {
while !place_meeting(x + sign(horizontal_speed_), y, o_wall_) {
x += sign(horizontal_speed_);
}
horizontal_speed_ = 0;
}
}
Thank you in advance for helping. I hope what I am asking to do is clear enough.