question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deactivate collision on individual locations

See original GitHub issue

Hey there. What would be the best approach to deactivate/activate collisions for an individual Position[] dynamically? My use case is the following:

As shown in the image, I have predefined slots (1) where buildings can be constructed. So what I do is that I’ve already created the tiles for the building but used setVisible(false) on them. So at that moment those invisible tiles should be non-collidable. When the player interacts with the building sign (2) and starts construction, the visibility is set to true and the alpha slowly transitions from 0-1. Now the collisions should be available. Once the construction is done (3) everything is as usual Collisiontoggle

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
notchriscommented, May 7, 2022

You canmake a reference to the tilemap you’ve created on your scene and the layer of the specific tiles you want to deactivate collision on.

Set tile index to a non-colliding tile on targetLayer

tilemap.putTileAt(-1, tileX, tileY, false,  targetLayer)

This appears to update grid engine as well since it uses a reference to the tilemap.

0reactions
Annoraaqcommented, Apr 11, 2022

That’s interesting. Unfortunately in Tiled you can only set properties in the tileset and not for individual tiles afaik. But in phaser you seem to have more freedom.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable collisions between objects, but keep the trigger.
For detecting nearby players with a trigger collider, put the collider on a separate GameObject and give it a different layer that can...
Read more >
disableCollisionWith - Bohemia Interactive Community Wiki
Description: Disable collision between provided objects. The collision is always disabled for both objects in the arguments.
Read more >
Disabling collisions for an individual object - Construct 3
I have copies of Object A in one layout, but I want to disable only the collisions with an Object B but in...
Read more >
JavaScript, Matter.js: Disable collision for one body
As already mentioned in the title, I am looking for a way, to disable every collision of a body in Matter.js. It should...
Read more >
Deactivate collision between certain Rigidbody objects?
In those cases, you can create rigid body constraints between objects to disable collision between the two, via the "disable collisions" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found