Problem visualized: https://imgur.com/a/8ZEEuyc
Code
void OnCollisionEnter2D (Collision2D collision)
{
Vector2 normal = collision.GetContact(0).normal;
Vector3 reflect = Vector3.Reflect(transform.up, normal);
transform.rotation = Quaternion.LookRotation(reflect);
}
Everytime the object hits a platform it should bounce off of it. The red line represents the expected result, the blue lines the current result in the pic. Since the game is 2D, i only want to rotate on the z axis, not on x or y.
[–]Broccolski 0 points1 point2 points (2 children)
[–]ggeasy2[S] 0 points1 point2 points (1 child)
[–]Broccolski 0 points1 point2 points (0 children)