Problem with rigidbodies and colliders

Hi everyone,

I’m working on a maze-like game, whereby the player has to steer a ball without being detected by guards or cameras! The ball has a kinematic rigidbody and a sphere collider attached to it while the maze itself has a mesh collider attached to it. The problem is that whenever I move the ball towards the wall, the ball simply passes through! Shouldn’t the engine automatically detect that there is a collision and stops the ball from passing through the wall? I tried various collision detection methods (continuous, discrete etc).

Should a script take care of this? Or this can be done natively within Unity? Thanks for your assistance.

There is the simple script attached to the ball gameobject.

using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Rigidbody))]
public class Player : MonoBehaviour {

private float _floatHeight = 0.01f;
private float _floatFrequency = 8f;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
transform.Translate(0f, _floatHeightMathf.Sin(_floatFrequencyTime.time), 0f);

if(Input.GetKey(KeyCode.UpArrow))
transform.Translate(Vector3.forward * 0.5f);

if(Input.GetKey(KeyCode.DownArrow))
transform.Translate(Vector3.back * 0.5f);

if(Input.GetKey(KeyCode.LeftArrow))
transform.Translate(Vector3.left * 0.5f);

if(Input.GetKey(KeyCode.RightArrow))
transform.Translate(Vector3.right * 0.5f);

}
}

I read something on this

I don’t have any idea if that helps with what you want to do.

Not with a kinematic rigidbody, no. The point of kinematic is that it goes precisely where you tell it to. By the way, your movement code is framerate-dependent.

–Eric