Solution for handling multiple collisions?


#1

Hi,
I recently noticed that you can place a sprite and choose which animation it’s going to appear.

If I want to create an open world map with a lot of objects (such as desks, computers, trees, phones etc) would it be more simple to just create one sprite (let’s name it "objects) and than add all the different object sprites to different animations and then just place them on the map?

With this, I could use only one event collision for all of them, so maybe the game could run more smoothly?

Thanks!


#2

So, you want computer(animation) to work like computer, phone(animation) to work like phone.
If yes, then make a variable which determines what action this sprite will do.
like if animation = computer, change variable to 1
if variable =1 and return key pressed, do action1
if animation = phone, change variable to 2
if variable = 2 and return key pressed, do action2


#3

It’s possible, but you have to consider lots of others things if you do that, and it will be a hell of development.


#4

Thanks for the replies.
The idea was to use this only with static objetcs (with no animations, for exemple) that composes the scenary of the maps. Because if I don’t do that, I would have to make like 30 events just for collisions with these objects, and I believe this would implicate in a lot of lag, if I’m not mistaken.


#5

Your other option would be to just use a separate, single, object named “Collider” or something similar.

Don’t add any collision at all to your visual objects, and place them as needed.

Place and stretch the Collider object as you need throughout your map, then set up your collision event for that specifically.

You then have only 1 collision event altogether.


#6

Thanks! That’s a nice solution as well. Would that matter if the collider is a tiled sprite or a regular sprite? (More specifically, if I make the Collider a Sprite and stretch it all over the maps, would it lag more than if it was a tiled sprite?)

The thing is, I have a lot of different scenes that shares the same objects, so I though having all of them in just one specific sprite would ease the process of not having to make like 200+ objects global objects. I believe I will combine these two solutions. Use the collider, but also putting all of my objects in just one sprite object (or a handful, like ‘office objects’, ‘bathroom objects’ etc).


#7

I think technically it would lag less as a Sprite vs a Tiled sprite, as you’re only displaying one image rather than the same image repeated.