Softbody2D & Physics (godot 4.2)

Godot Version



Hi! I’ve been working on a prototype of a game where a lil blob eats balloons and floats around.
I spent some good time working on the physics on a Characterbody2d with a sprite and it worked fine. So then I started investigating how to create a jiggly blob I ended up pulling my hair out trying to understand shaders and I couldn’t get anything right.
Bear in mind I’m very new at this and not very good at it.

After some investigation I found a plugin that did just what I wanted but the physics generated by the plugin appear to conflict with mine.
The first iteration was just bouncing all over the place but when it was time to float it would just stay stuck to the ground while the camera followed an invisible model. I even commented out all gravity related code on the code generated by the plugin so that it would not overlap.
I spent hours tweaking to no avail so I deleted it and created another one.

This one seems to stay in place and I assigned my own gravity to the soft body’s gravity so that they wouldn’t conflict. However how seems like it’s being crushed non stop against the ground and jumps no longer work but crush the body even more.

Can anyone give me a hand to find out what’s causing this? Or should I just give up and go on with some spritesheet or animation?

Here’s my code :slight_smile:

extends CharacterBody2D

@onready var animated_sprite = $Sprite2D
@onready var gravity = 1
@onready var speed = 125
@onready var jump_force = 200
@onready var floating_multiplier: float = 1.0

@onready var blobscene = $blobscene/SoftBody2D

signal airjump

var balloons: int = 0
var active = true
var direction = 0

func _physics_process(delta):
	blobscene.gravity_scale = gravity
	if is_on_floor() == false and balloons < 3:
		velocity.y += gravity *delta
		if velocity.y > 500:
			velocity.y = 500
	if active == true:
		if Input.is_action_just_pressed("jump") && is_on_floor():
		elif Input.is_action_just_pressed("jump") && is_on_floor() == false:
			jump_force = 100
	if is_on_ceiling() == false:
		direction = Input.get_axis("move_left", "move_right")
	if is_on_ceiling() == true:
		direction = 0
	velocity.x = direction * speed
func collect_balloons():
	balloons += 1
	if balloons > 3:
		floating_multiplier *= 1.1

func lose_balloon():
	balloons -= 1
	floating_multiplier *= 0.9

func jump(force):
	velocity.y = -force
func floating(delta):
	if balloons > 3: 
		gravity = 400
		velocity.y += -gravity * delta * floating_multiplier
		gravity = 1
		jump_force = 200
		floating_multiplier = 1.0
		velocity.y += gravity *delta
		if velocity.y > 500:
			velocity.y = 500
func air_jump(force):
	if is_on_floor() == false:
		velocity.y = force

here’s the code from the plugin (on a link cause it’s LOOONG)