Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Turns out getting physics working with drag and drop is pretty tough... I used transform.position and a throw script in the jam version - together with some drop conditions which turned out as weird as you found it. Then I tried it using force on the rigidbody but then the mouse can't keep up and I'll just let the ball drop at this point :(

Glad you enjoyed it :D

(1 edit) (+2)

Recomendation: Use a GameObject with a collider and rigidbody and attach a script with

// On the update method
Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
pos.z = 0;
_rigidbody.velocity = (pos - transform.position) * dragSpeed;

It should work fine

(+1)

You have excellent throwing in your game so this is probably gold! Thanks for sharing

Thanks - that works (updated the game).

However: it only solves the collision bugs, because doing it in this way will make the object lag behind the mouse. That looks and feels great in your game because it adds weight to the falling rocks but when dragging the ball in mine it feels a little off. I tried to mitigate it by setting the dragSpeed pretty high and adding a speed limit to the object while not getting dragged but then some new ways to cheat open up.


I give up now. Thanks anyway :)

(1 edit) (+1)

You can also increase the gravityScale from the rigidbody itself to have less of that moon-like experience.

I notice that you reset the velocity once it hits a wall and this just breaks the game feel and the way that physics works. I don’t actually know if its a line of your code or a really non-bouncy high-friction Physic Material.

I can recomend: increasing the dragSpeed to no more than 20f, increasing the gravityScale up to some point you feel good and natural and, finally: obviosly don’t reset the speed once it hit the wall.

(+1)

Aw, crap - forgot to remove the speedlimiter on the wall collision. Thanks for spotting that. Yeah, I called the speed limiting function that should only activate once you hit the red area or let go of the mouse on hitting the wall... Fixed that now. Still not quite satisfied since the catapult levels are now way to easy but the bouncing and dragging feels pretty decent now.


Thanks again :)