How To Make Cerain Blocks Dissapear

I am trying to create 2 blocks where 1 can only be visible at a time

problem the collision is still there. it acts as a wall for the player and collides bullets, how do i make it work properly?

to note both “Dreams” and “Nightmare” are Tiled Sprites

Hi,

your title says: ‘How to make certain blocks disappear’ and then

Could you explain a bit more in detail what your actual problem is (hiding/showing your nightmare/dream-objects or collisions in your scene)? Edit: Tiled sprites don’t have collision, so you apparently mean something else. → Of course Keith is right, collision with tiled sprites can be checked.

1 Like

Tiled objects don’t have custom collision masks but they do have a collision condition.

I believe the issue is that hiding objects only hides the visual part. It doesn’t deactivate behaviors or mouse events or collisions. It’s a pet peeve. It would be nice to be able to deactivate an object similar to the way you deactivate a behavior. An option to deactivate a collision mask or mouse interaction.

You have a few options. You can add/delete the objects or move the objects out of camera view by doing something like adding/subtracting a large number to/from the objects original position. You could save the original position in an object variable. Then when the mode is changed, you could move the objects to and fro by either using the original position or the original Y position minus say 10,000. Any position that’s out of the camera view.

Another option would be to use a boolean variable and seperate conditions and events for anything unique to each state.

If DreamMode is true then seperate player from dream object or disable a behavior or check for the collision between a bullet and the dream object , whatever is different. This would make the intention more obvious but would require more changes and duplicate events depending on the complexity of your project.

2 Likes

It wouldn’t make any sense to deactivate an object just by hiding it.

Hiding and showing are just what they sound like, a hidden object is not rendered on the screen, nothing more, nothing less.

Your solutions would work but may be more complicated than necessary. @LastBast however, I think we do need some more information. What behaviors or conditions are you using for collisions with these objects? For example Platformer behavior, or Physics2? Or just your own events?

If you are using your own events, then there is no need to make a separate variable. Simply add a condition “object is visible” (it is a bit inconsistent that this condition is called visible, typing in hide or show in the conditions search will not find it).

If you have a behavior handling it, then you might be able to use the behavior’s functionality to do what you want. For example, with Physics2 you can enable or disable collision layers. So you could have Dreams on layer 1 and Nightmare on layer 2. The player and other moving objects would then switch between those to change what they are colliding with.

1 Like

I have tried doing the moving position and It worked! @magicsofa It was a platformer behavior style