Legacy GM Changing instance on collision (SOLVED)

Y

YetAnotherGameDev

Guest
I want to make my player object change the colour of the ground when the player collides with it. I've put this code in my step event for the ground (for reference, the object is called obj_ground_1_normal):
if(place_meeting(x, y, obj_player_red))
{
instance_change(obj_ground_1_red, false);
}

Sometimes it works, sometimes it doesn't, and I don't know why. Please help.
 
Last edited by a moderator:

YoSniper

Member
I feel like this effect would be better accomplished by changing the sprite_index of the object, and not the type of object (object_index.)
 
O

Old School Ben

Guest
I agree with YoSniper. You might just want to change the sprite.

You may need to destroy an object while simultaneously creating one at the same x and y location.

Really depends on what you are trying to accomplish.
 
Y

YetAnotherGameDev

Guest
I tried both of those things (both via code and "drag and drop" commands) and it still only works about 60% of the time. That's my problem.
 
Last edited by a moderator:

curato

Member
Probably just an oddball collision issue with the mask or moving too fast. Especially the concept is you are changing the floor color here I would use distance_to_object and check if you are closer that the speed you are traveling.
 
Y

YetAnotherGameDev

Guest
I tried distance_to_object and it works every time now. Thank you!
 
Top