Skip to main content

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

Ah yeah cool. Can i ask how you got it working?

I imagine you're asking about the rope-mechanic?

It's actually fairly simple, the hook has a statemachine which tells when to pull the player and the pullcode is super basic: 

case State.Hooked:
                if (connectedBody)
                {
                    var targetVelocity = (rb2D.position - (Vector2)aimPoint.position);
                    if (targetVelocity.sqrMagnitude > 1f) targetVelocity = targetVelocity.normalized;
                    connectedBody.velocity = targetVelocity * pull;
                }
                //pulling player
                break;

_______________

connectedBody is the rigidbody of the player character, rb2D is the rigidbody of the hook and aimPoint is the transform from which the hook got shot.

The players velocity is getting set directly, because just adding force is super wonky in Unitys 2D physics.