2D Keeping player stuck to a square platform

Hi,

Just looking for advice and to be pointed in the right direction. Don’t feel obliged to write and code really suggestions could work too, thanks.

But the issue I’m having is making my character walk around a cube as if it was stuck to it, like walking round a corner of the cube. (described in the screenshots attached)

The way I’m achieving this now is just by adding a:

rb.AddForceAtPosition (-10f * transform.up, transform.position);

This doesnt work completely really since if you walk of the edge to quickly it will just send you of the screen. If you can recommend a better way to do this that would be amazing.

Thanks in advance!!


  1. disable gravity
  2. add 4 empty game objects with colliders @ the 4 corners of the square
  3. use OnCollisionEnter2D to detect there names or tags to send them to the desired direction example :

void OnCollisionEnter2D(Collision2D coll) { if (coll.gameObject.tag == "Down") rb.velocity = new Vector2(0, -5); }