#Problems getting kinematic bodies working

1 messages · Page 1 of 1 (latest)

hardy ivy
#

I have two squares with Box Collider 2D components connected to them. When I add a dynamic Rigidbody 2D to the upper one it has no problems with the collision but when i change it into Kinematic and add this little script:

using UnityEngine;

public class Test : MonoBehaviour
{
    void FixedUpdate()
    {
        Rigidbody2D rb = GetComponent<Rigidbody2D>();
        rb.MovePosition(rb.position + new Vector2(0, -1f) * Time.fixedDeltaTime);
    }
}

it does not want to collide with the second square. If i change the body type back to Dynamic and lock the Z rotation it it works fine again but it feels like that is not the right way to do this.

fast spoke
vast nova
#

feels like that is not the right way to do this
What is the "this" you're trying to do?

hardy ivy
#

I want to make a top down player that can't walk into walls

#

So is a kinematic body attached to the player what i want to use here?

vast nova
#

No. Dynamic rigidbody with locked Z rotation is correct

hardy ivy
#

Ah ok