Moving Ledge Character doesn't follow

I have a character controller sprite, and when I try to jump on a moving ledge that moves left and right. The Character doesn't follow with the platform.

How do I go about fixing this?

Thanks in advance.

2 Answers

2

This is pseudocode:

if(CharacterOnLedge == true)
    Character.transform.position += ledgeDirection * ledgeSpeed;

To make it follow you could just attach it to the ledge an unity will take care of the rest. So if you step on the ledge do this:

transform.position.parent = ledge.transform;

And make sure you deattaching your character when you lose contact to the ledge.

Do you see the values change or the actual size of the object? Value changes would be expected, as they get relative to the paren object.