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.

Colliders do not collide properly

See original GitHub issue

Describe the bug Some of my objects do not collide as they should, sometimes even collide outside each other’s shape. It slightly seems like the colliders of objects are somehow shifted from their position.

Expected behavior I set up colliders for space trash and laser beam in the space shooter game. But they are not computed properly. Objects are slowly rotating and are randomly resized at the beginning of the game. Each piece of space trash had the rectangle shape and the laser have the same shape as well. The laser beam should end at the moment it hit the space trash. But the beam sometimes goes through the objects. And my rocket sometimes collides with the trash even if it is outside its shape (rocket has polygon shape).

Screenshots (recommended) The glitch: obrazek

The colliders: obrazek

The code: Space trash object (OnCreate):

    this.undestroyable = true;

    this.rotation = (ct.random(360));
    this.scale.x = (ct.random(3) + 0.5);
    this.scale.y = this.scale.x;
    this.rotationSpeed = ct.random(0.5);
    this.x += (ct.random(500) - 250);
    this.y += (ct.random(500) - 250);

Space trash object (OnStep): this.rotation += this.rotationSpeed * ct.delta; //trash is not moving

Function called on player:

    function createLaser(player, dir) {
        var direction = (player.direction + dir) % 360;
        if (ct.room.timer < 300) return;
        i = 0;
        while (true) {
            i++;
            var laser = (ct.types.copy("Laser", player.x + ct.u.ldx(25 * i, direction), player.y + ct.u.ldy(25 * i, direction)));
            if (laser.x < 0 || laser.x > ct.roomWidth || laser.y < 0 || laser.y > ct.roomHeight) {
                return;
            }
            laser.rotation = (direction + 90) % 360;
            for (var collider of ct.place.occupied(laser, laser.x, laser.y, 'Hitable', true)) {
                if (collider != player) {    //ship cannot shoot itself
                    laser.show();             //collision effect
                    if (!collider.undestroyable) collider.kill = true;
                    if (collider.hp)
                        collider.hp -= ct.delta;
                    return;
                }
            }
        }
    }

Versions:

  • OS: Windows 10
  • ct.js version: 1.0.2

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
MMLichcommented, Sep 28, 2019

obrazek The ship object drops the blue laser as it moves so the collision spot is visible at the picture. I’ve disabled the rotation of space trash (I rotated it only at start). So this is exactly the point where they collide (and the area where they didn’t collide).

0reactions
CosmoMyzrailGorynychcommented, Oct 2, 2019

The fix will be shipped in the nearest release

Read more comments on GitHub >

github_iconTop Results From Across the Web

Colliders not Colliding - Unity Forum
Hi All, I'm trying to make a "wall" that travels behind the player that destroys objects that pass by the player and then...
Read more >
Troubleshooting Broken Colliders in Unity - Yarsa Labs DevBlog
A collision can not be detected if the Is Trigger attribute is set to the collider. Open the properties pane of the game...
Read more >
Introduction to collision - Unity - Manual
Primitive colliders do not work correctly with shear transforms. If you use a combination of rotations and non-uniform scales in the Transform hierarchy...
Read more >
Unity Collision doesn't work as expected if one is inside a ...
Make sure that your DetectCollider script and RigidBody component are attached to the root GameObject which in this case is Rb. Collision events ......
Read more >
Rope not colliding with Obi Colliders after upgrading to 6.2
is there anything extra we need to do now to get the ropes to collide properly? Similar issue in the 'Chains' demo. Also...
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