• 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!

Problems with block collision in instances created by players

Rexzqy

Member
Hi! So i am trying to make a survival game, and i am working on a construction function where player can build furnitures and stuff.

I am using a block collision, and i wonder how can i make proper collisions for instances thats created by player?

Like if I construct a refrigerator, do i also make a collision block thats specific for refrigerator and then do another Instance_create_layer or is there a better method? Coz there will be a lot of furniture that can be constructed, it could be somewhat time consuming to make a specific collision block for everyone of them.

Any help is greatly appreciated!! I can also specify if anything is unclear, sry english isnt my mother tone :(
 

Dev_M

Member
Hey,

Make a mask sprite that's 2x2, and set it's origin to center middle. Create a parent furniture object.

PARENT CREATE EVENT

sprite_for_mask = spr_mask;
sprite_for_furniture = sprite_index;

sprite_index = sprite_for_mask;

image_xscale = sprite_get_width(sprite_for_furniture) / sprite_get_width(sprite_index);
image_yscale = sprite_get_height(sprite_for_furniture) / sprite_get_height(sprite_index);

sprite_index = sprite_for_furniture;


CHILDREN CREATE EVENT
event_inherited();

then all of your code needed.




This will allow you to set your furniture sprites to whatever you need, and still get a autoscaled boundingbox ON CREATION ONLY!
If you gonna rescale the furniture in anyway then you will need to rescale image_xscale and image_yscale.
 
Top