0 votes

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.

asked Sep 4, 2016 in Engine by Victor Hernandez Can (76 points)

1 Answer

0 votes
Best answer

What happens if you change this line:

if event.is_action_pressed("SwitchMode"):


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.

answered Sep 4, 2016 by 2D||!2D (383 points)
selected Oct 4, 2016 by Victor Hernandez Can

_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.

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.