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?
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.
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.
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.
I have tried doing the moving position and It worked! @magicsofa It was a platformer behavior style