Collision detection between Layers
See original GitHub issueIs 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:
- Created 7 years ago
- Comments:5 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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?
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 leverageCrafty.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.