0 votes

Hello:

I'm working on a scene where I want a bunch of disk-looking things to fall from the ceiling and land flat in a stack on a platform.

As I've currently built it, each disk is an instance of a RigidBody2d node with a sprite and a CollisionShape2d that extends slightly beyond the sprite. They land on a StaticBody2d node that has a CollisionBody2d node.

When the disks land, they sort of mush and run over eachother (violating their CollisionBody2d shapes) and overlap and then vibrate as the others above them collide and then keep vibrating until they slowly work their way out of the stack and fall. I want them to simply land and sit. I can get one disk to land and sit happily.

Video here: https://www.youtube.com/watch?v=CwMsWie9Vbo

I've checked all my settings: bounce is at 0, gravity is at 1, etc. unless there's something I don't understand.

Although each instance appears to generate intelligently in a non-overlapping way, I was worried that they were overlapping somehow as they instanced in a way that messed with the collision expectation. So I instance them and change their location before the next instancing like so (this code runs in the video):

var disk_count = 7
var disk_scene = load("res://falling disk.tscn")

func _ready():
    var n = 0
    while (n < disk_count):
        var new_disk = disk_scene.instance()
        add_child(new_disk)
        get_node("falling disk").set_name("disk"+str(n))
        var instanced_disk = get_node("disk"+str(n))
        var current_position = instanced_disk.get_pos()
        print(current_position)
        var new_position = current_position + (Vector2(0,(-100*n)))
        print(new_position)
        instanced_disk.set_pos(new_position)
        n = n+1
    pass

Is this a bug in the physics engine? Or am I missing some key part of the physics engine that would prevent this kind of behavior? Thank you!

in Engine by (14 points)
edited by

Please log in or register to answer this question.

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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.