Collision/Collider Issue?
I am making a simple 2d platforming game. I should also mention I am still using Unity 4. I wanted to use the character controller for my players jump and have a separate move script. I did this completely fine, but I realized when doing a quick test my player collides only the horizontal edges of colliders. I know my movement script doesn't check for colliders. I thought it would just move right through everything at the time, but he collides with the ceiling and ground of my colliders. I was confused by this. I just figured it has to do with the character controller, but I do not know why. Also I want to know is there anyway to use the character controller to collide with the vertical edges. I currently have the character controllers movement variables all set to zero, as in the forward, backward, and sideways. I am guessing I am doing something stupidly simple wrong and if anyone would like to point me into the right direction. I am fairly new to unity.
Also here is my simple move script. I want to add a lot more to this as I progress with the project. I just made it detect the walls and not allow them to go through them, but I would still like some suggestions.
#pragma strict
var Stop_R : boolean;
var Stop_L : boolean;
function Start () {
}
var speed : float = 14.0;
function Update() {
if(!Stop_L){
if(Input.Get$$anonymous$$ey("a")){
var move = Vector3(-1,0,0);
transform.position += move * speed * Time.deltaTime;
}
}
if(!Stop_R){
if(Input.Get$$anonymous$$ey("d")){
move = Vector3(1,0,0);
transform.position += move * speed * Time.deltaTime;
}
}
var fwd = transform.TransformDirection (Vector3.right);
if (Physics.Raycast (transform.position, -fwd, .7)) {
Stop_R = true;
}
if (!Physics.Raycast (transform.position, -fwd, .7)) {
Stop_R = false;
}
if (Physics.Raycast (transform.position, fwd, .7)) {
Stop_L = true;
}
if (!Physics.Raycast (transform.position, fwd, .7)) {
Stop_L = false;
}
}
Also if you could improve it please help. It is a bit glitchy.