I have a character jump and moveable land.
When the character stands on the land i want character to move with the land. And I use collision and position.y to check and set Parent:
private void OnCollisionEnter2D(Collision2D collision){
if(collision.gameObject.tag == "Player"
&& collision.transform.position.y - 0.5f > transform.position.y)
//not good when fix distance is 0.5
collision.transform.SetParent(transform);
}
My character can rotate while playing so I put the character position as the center. 0.5f is the distance from the character's position and his feet.
It's not a good idea because my character can change Box Collider 2D so 0.5 from character's position and foot is no longer correct.
How can i dynamic check a character on a land when Box Collider 2D changed.
[Link to describe confused solution] https://www.youtube.com/watch?v=pWh5G17US5U&list=PLGA8cn0qTCtjAUvtWsWo3JlneDUqqsqvy&index=5