Hi, unity noob here. I have a box as a terrain; floor and 4 walls. So far the movement is almost done except for one thing, making the player stop moving once he hits a wall. The code I have is this -
public class Movement : MonoBehaviour {
public int mSpeed = 10;
Collider playerColl;
void Start () {
playerColl = this.GetComponent<BoxCollider>();
}
void Update () {
if(Input.GetKey(KeyCode.S)){
transform.Translate(mSpeed*Time.deltaTime,0f,0f);
}
if(Input.GetKey(KeyCode.D)){
transform.Translate(0f,0f,mSpeed*Time.deltaTime);
}
if(Input.GetKey(KeyCode.W)){
transform.Translate(-mSpeed*Time.deltaTime,0f,0f);
}
if(Input.GetKey(KeyCode.A)){
transform.Translate(0f,0f,- mSpeed*Time.deltaTime);
}
}
}
The issue Im having is, since the movement is done like above, the player effectively ignores all colliders in the scene. How do I make it not ignore collision?