DukeSoft
Member
Hi guys,
I'm trying to get my player object to play different footstep sounds based on what he's walking on. The ground exists out of objects (big, round, shapes) and they _can_ overlap.
Now the problem is that when I have 2 circles (1 grass, 1 stone), and they overlap, it seems like instance_place picks one at random.
My code;
It works fine when im walking on a single instance, or on none. But once I have stone, overlapping grass (the depth is lower for stone, its visible as well), GM still tends to tell me "grass" and returns that value.
Question is:
1. Can (if so, how) I get a list of all instances that i'm colliding with on that point?
2. Could i replace this code with something that takes depth into account? (e.g. checks for the highest collisions first?)
The other solution is:
create -> make list
Every step, clear list
every collision with obj_terrain, add instance to list
end step -> check list and pick highest obj_terrain (if any) and use that
But that's really lame, ugly, and inefficient.
So, that. Any idea's?
Oh, and if you know the difference between instance_place and instance_position, please let me know.
I'm trying to get my player object to play different footstep sounds based on what he's walking on. The ground exists out of objects (big, round, shapes) and they _can_ overlap.
Now the problem is that when I have 2 circles (1 grass, 1 stone), and they overlap, it seems like instance_place picks one at random.
My code;
Code:
var foundground = instance_place(x, y, obj_terrain);
if (foundground != noone) {
var footstepsound = asset_get_index(global.terrain[foundground.type, TERRAIN_FOODSTEPSOUND] + "_" + string(ceil(random(global.terrain[foundground.type, TERRAIN_FOODSTEPSOUND_COUNT]))));
} else {
var footstepsound = asset_get_index(global.terrain[global.default_terrain, TERRAIN_FOODSTEPSOUND] + "_" + string(ceil(random(global.terrain[global.default_terrain, TERRAIN_FOODSTEPSOUND_COUNT]))));
}
Question is:
1. Can (if so, how) I get a list of all instances that i'm colliding with on that point?
2. Could i replace this code with something that takes depth into account? (e.g. checks for the highest collisions first?)
The other solution is:
create -> make list
Every step, clear list
every collision with obj_terrain, add instance to list
end step -> check list and pick highest obj_terrain (if any) and use that
But that's really lame, ugly, and inefficient.
So, that. Any idea's?
Oh, and if you know the difference between instance_place and instance_position, please let me know.