How to create bouncing coins (for example; from killing an enemy or opening a chest box) in a top down 2d game? I tried a few things liked the ridge body or adding random impulse but it’s not turning out right so I scrapped what I had. So I’m hoping someone can help me out here with the correct way to do it. Here is an example of what I want, I seen it on the Godot reddit : https://ibb.co/ZWrcVYK

in Engine

I’m hoping someone can help me out here with the correct way to do it

There really isn't a "correct way" - it all depends on what exactly you want to do.

Here is an example of what I want

When referencing someone else's work, I think it's only fair to give them proper credit. Also, as you already know who did what you want, why don't you reach out to them on reddit or twitter and simply ask how the did it?

That being said, here's a quick version I hacked together using Tweens:

``````extends Node2D

const MIN_X =  10.0
const MAX_X = 150.0
const MIN_Y = -80.0
const MAX_Y =  80.0

randomize()

func _process(delta):
if Input.is_action_just_pressed("ui_accept"):
var coins = []

for i in range(5):
coins.append(COIN_SCENE.instance())
coins[i].position = Vector2(960, 540)

var tween = Tween.new()

for coin in coins:
var direction = 1 if randi() % 2 == 0 else -1
var goal = coin.position + Vector2(rand_range(MIN_X, MAX_X), rand_range(MIN_Y, MAX_Y)) * direction

tween.interpolate_property(coin, "position:x", null, goal.x, 1, Tween.TRANS_LINEAR, Tween.EASE_IN)
tween.interpolate_property(coin, "position:y", null, goal.y - 50, 0.4, Tween.TRANS_QUAD, Tween.EASE_OUT)
tween.interpolate_property(coin, "position:y", goal.y - 50, goal.y, 0.4, Tween.TRANS_QUAD, Tween.EASE_IN, 0.4)
tween.interpolate_property(coin, "position:y", goal.y, goal.y - 10, 0.1, Tween.TRANS_QUAD, Tween.EASE_IN, 0.8)
tween.interpolate_property(coin, "position:y", goal.y - 10, goal.y, 0.1, Tween.TRANS_QUAD, Tween.EASE_IN, 0.9)

tween.start()
``````

That's probably not exactly (or even close to) how they did it for "Helms of Fury" and misses further details like rotating the coin or showing shadows on the ground, but it should give you a rough idea anyways. Getting those things "right" is a lot of work and usually the things you'll spend the most time with when developing a game.

by (10,483 points)
selected by

and how to reference the enemy position, when he dies?