I have added RigidBody component as well as Mesh collider to an object moved with keyboard. I know that it the object will go through another (with RigidBody and Mesh collider too) if I use transform to move the object. Could you give me example of code how to move an object with RigidBody. Here is my current code (still using Transform)
if (Input.GetKey(KeyCode.RightArrow))
{
character.transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
character.transform.position += Vector3.left * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.UpArrow))
{
character.transform.position += Vector3.forward * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.DownArrow))
{
character.transform.position += Vector3.back * speed * Time.deltaTime;
}