Bouncy petal platform

Godot Version

4.3

Question

I’m trying to make a flower petal shaped platform that bounces up and down slightly when the player is jumping on it.

I’ve tried parenting the rigid body to and from a static body.
I’ve tried incorporating the animatable body but that doesn’t seem like an appropriate node to use
locking or anchoring the base of this petal is very challenging.
I even built a cage like structure around the platform and set gravity of the rigid body to -1 so that it floats up but the weight of the character doesn’t impact the petal at all.
I can’t find a tutorial quite like what I’d like any help is welcome.

Thank you

You probably want to use DampedSpringJoint2D

See my little demo:

Here’s scene structure. There is only one script on the “Player” node so that I can jump to demonstrate. The petal itself has no script, it’s all just built in behavior.

1 Like

THIS IS EXACTLY IT I’ve never been so happy to receive a notification !!! I’m so eternally grateful to you ! thank you so much for taking the time to make a vid and show your scene structure it makes all the sense in the world.

I’ve never heard of dampedSpring and will study it thoroughly

I was so desperate I had written a rotation script that was supper janky to achieve the effect. I’m so glad I don’t have to use it.

extends Area2D

@onready var firstpetal = %firstpetal
@onready var bounce_timespan : float =  0.1

func _ready():
	pass
	
func _on_body_entered(body):
	if body.is_in_group("players"):
		if firstpetal.rotation <= 0.1:
			_lowering_to_o_one()
			if firstpetal.rotation >= 0.1:
				firstpetal.rotation = 0.1
		
func _lowering_to_o_one():
	await get_tree().create_timer(bounce_timespan).timeout
	firstpetal.rotation += 0.01
	await get_tree().create_timer(bounce_timespan).timeout
	firstpetal.rotation += 0.01
	await get_tree().create_timer(bounce_timespan).timeout
	firstpetal.rotation += 0.01

func _on_body_exited(body):
	if body.is_in_group("players"):
		await get_tree().create_timer(bounce_timespan * 5).timeout
		if firstpetal.rotation != 0:
			firstpetal.rotation -= 0.01
			await get_tree().create_timer(bounce_timespan).timeout
			firstpetal.rotation -= 0.01
			await get_tree().create_timer(bounce_timespan).timeout
			firstpetal.rotation -= 0.01
			firstpetal.rotation = 0

1 Like