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.

Collision detection between Layers

See original GitHub issue

Is it possible that collision detection between entities on different layers is not working as expected when each layer moves differently towards the viewport?

I have a static background layer (xResponse: 0, yResponse: 0)

When I have an entity here on x: 200, y: 200 It will not collide with an entity x: 100, y: 200 on a layer with xResponse: 1, yResponse: 1 when the Viewport.x is 100

(This prevents the sun in my game to be blocked by the moving scenery before it, using the Crafty Layer system)

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
starwedcommented, Jan 11, 2017

Hmm, after thinking about it – is the point to know when another element overlaps the sun entity?

If so, that’s pretty similar to what we do to detect mouse clicks targets. I imagine you could create a method that checks an area of the viewport to find the first entity within it – would that suit your purpose?

0reactions
mucahocommented, May 10, 2017

I propose to add a method, called something like Crafty.searchLayers(rect, filter). It would have similar signature as Crafty.map.search.
Under the hood, it would do pretty much what Crafty.findPointerTargetEventByComponent does (as suggested by starwed).

EDIT: Initially I thought that findPointerTargetEventByComponent could leverage Crafty.searchLayers internally, but the code for checking pointer events is quite different. Pointer events need to check for click areas, plus there is no need to search layers without pointer entities.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layer-based collision detection - Unity - Manual
Layer -based collision detection. Layer-based collisionA collision occurs when the physics engine detects that the colliders of two GameObjects make contact ...
Read more >
Tip of the Day: Collision Layer in Unity - Medium
As you can see, we also created an Enemy Sword/Enemy layers and uncheck the collision detection between them. Attacking working as intended.
Read more >
Check if colliding with a layer - Unity Answers
I want 2 if statements to check if and if not colliding with a layer called ground for jumping in my 2d platformer....
Read more >
Working with Collision Layers in Unity - Dev Genius
I will add 2 more Layers, Player Sword layer and a Player Layer. ... To disable Collision Detection remove the check-mark from the...
Read more >
Unity - Manual: Layer-Based Collision Detection.
Layer -Based collision detection is a way to make Game Objects collide with another specific Game Objects that are tied up to specific...
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