- Home /
Cube with colliders ignores other colliders, why?
I am building a game where there is a cube (the player)who needs to get through gates on a track. I wrote a motor script and now the colliders don't work. Why? I can not for the life of me figure this out. I think it has something to do with the script.
using UnityEngine;
using System.Collections;
public class testMotor
: MonoBehaviour {
public float MoveSpeed = 10;
public float RotateSpeed = 40;
void Start()
{
}
// Update is called once per frame
void Update ()
{
// Amount to Move
float MoveForward = MoveSpeed * Time.deltaTime;
float MoveSide = Input.GetAxis("Horizontal") * MoveSpeed * Time.deltaTime;
// Move the player
transform.Translate(Vector3.forward * MoveForward);
transform.Translate(Vector3.right * MoveSide);
}
}
also the cube is the parent with the script, a mesh renderer and a mesh collider. It has 2 child objects: a camera and a spotlight. The walls are just planes with mesh renderers and colliders on them.
thank you
Comment
Best Answer
Answer by LesPaul · May 16, 2013 at 01:20 PM
Transform.Translate does not use colliders, you could raycast in the direction you want to move before actually moving to see if it is possible...