Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+1)

Oh wow! This tech is really close to some saltation-style character movement I've been working on lately.

Glad I came across this inspiration, it works surprisingly well on a touch screen and is quite fun to play around with!

Is there any chance you'd be willing to directly share some bits of this godot project or otherwise chat about how you developed the physical spring movement? I'd love to ask you some questions or look into some coding if you'd have the energy.

Oh hey, very glad to hear! Sure, I don't mind at all-- I haven't touched the code in 4 years but I'll check through it and see what's what as soon as I get some time.

Checked out the project files, and here is the way I have it set up! (Godot 3.x)

The player is two sphere colliders, one is the parent which is a RigidBody2D with continuous_cd set to Cast Ray, linear_damp set to 1 and angular_damp set to 100; the second is a child KinematicBody2D which is the "hammer head" that follows the cursor.

Inside `_physics_process` is the main update step, which I cleaned up a bit:

var vector = get_global_mouse_position() - get_global_position()
var clamped_mousepos = get_global_position() + vector.normalized() * min(110, vector.length())
var push_force = clamped_mousepos - $Hammer.get_global_position()
if $Hammer.move_and_collide(push_force * 0.59) != null:
apply_central_impulse(-push_force)

Essentially it gets the clamped cursor positions, uses that to determine where the "hammer" should move to, and if the movement finds solid ground, simply apply an inverse impulse to the parent. The magic numbers I used there are the mouse radius/max reach distance around the player (110), and the responsiveness with which the hammer follows the mouse cursor (0.59).

Cheers! Hope it helps!