Player Layer Mask, not affecting collision on 2 different TileMaps.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Victor Hernandez Can
:warning: Old Version Published before Godot 3 was released.

So i have 2 tile maps. One with a set of tiles different to the others. I will be exchanging each tile map (both visibility and collision) with an input. To affect the collision, i am changing the player’s layer mask so that one tilemap won’t have collision layer in common with the player, thus changing it back and forth.

Here’s a video of it.

:bust_in_silhouette: Reply From: 2D

What happens if you change this line:

if event.is_action_pressed("SwitchMode"):

to

if event.is_action_pressed("SwitchMode") and not event.is_echo():

From your debug output, it looks like you are getting presses over multiple frames.

Link to a question that had the is_echo() recommendation.

_input(event): wont run is_pressed("") every tick, just once. It shows when i click and 2 prints come out in the output everytime i click. and did not work.

EDIT: it worked before i had collision polygons in every tile. just a single static body and polygon 2D as child of tilemap just to test. But not anymore.

Victor Hernandez Can | 2016-09-04 23:27

Ahh. Sorry, I watched your video more closely and I see what you are referring to. From what I can tell in your video, your peace and chaos collision masks bit 0’s are set to true. Try setting those to false so they have no bits set. Keep their Collision layers as they are in the video.

Recall that the formula for collision is:

A.mask & B.layers || B.mask & A.layers credit

          

2D||!2D | 2016-09-08 17:01