0 votes

Hi everyone!

I'm working on a 2D physics-based space game and ran into some issues.

Basically I'm looking for a way to destroy my RigidBody2D-Spaceship on impact.
I tried a few things and ended up connecting the four rocket parts with 2x3 pinjoints which are deleted on impact. (1 is attached to 2 with two joints (to stop rotation), 2 is attached to 3, and so on)
Everything works fine until I start turning my rocket more than about 360 degrees...

comparison of four connected rigidbodies and one solid rigidbody

All the forces are applied on the lowest part of the breakable rocket.
Steering code looks like this, pretty basic:

func _integrate_forces(state):
if alive and fuel > 0:  
        if Input.is_action_pressed("ui_up"):
        applied_force = thrust.rotated(rotation)
        applied_force = Vector2()
    var rotation_dir = 0
    if Input.is_action_pressed("ui_right"):
        rotation_dir += 1
    if Input.is_action_pressed("ui_left"):
        rotation_dir -= 1
    applied_torque = rotation_dir * torque

To have the rocket already exist of multiple parts seemed more straightforward to me than spawning the broken ship on impact and applying velocity and other forces on the individual parts. if you have another idea to implement a breaking ship I'd be happy to hear it :)
Thanks guys!

asked May 25 in Projects by bonkoponko (12 points)

I enabled collisions and put one pinjoint in the middle of the segments instead of two at the corners. look here

Seems to have fixed the issue.

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.