I was wondering if anyone knows how to make something like the hammer from getting over it?

I’m trying to make something like the hammer from getting over it.

I can’t figure out how to code in something that works like the hammer from getting over it with Bennett Foddy. @EliasMiettinen

The hammer is just a physics object connected to the player. However, it points towards the cursor, which allows it to rotate and hook onto things, allowing the player to get over obstacles.

As long as you’ve got a hammer-shaped collider on a rigidbody, that is attached to the player, the next step is quite simple. To make the hammer face the cursor, you can just use Quaternion.LookDirection. This returns a rotation that faces a direction.

The direction you need is from the end of the hammer to the mouse cursor position, which you can get like this:

public Transform Hammer;

public Vector3 Direction;

void Update()
     Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

     Direction = mousePos - Hammer.position;

Then, just set the rotation of the hammer to face that direction every update, like so:

Hammer.rotation = Quaternion.LookDirection(Direction);

And that should be enough. It’s untested code, but hope that helps as a basic idea of what the code might look like @dnangle21