So I’ve just started using Unity and new to C#.
I’m running into a problem where my sphere (player) wont detect collision as it touches other objects (runs right through).
I wanted to have the player move units by units corresponding to my left, right, up, down keyboard inputs instead of physics.
heres the code:
public float distance;
void FixedUpdate(){
if (Input.GetButtonDown("Horizontal") && Input.GetAxisRaw("Horizontal") > 0) {
transform.Translate (distance, 0.0f, 0);
} else
if (Input.GetButtonDown("Horizontal") && Input.GetAxisRaw("Horizontal") < 0) {
transform.Translate (-distance, 0.0f, 0);
} else
if (Input.GetButtonDown("Vertical") && Input.GetAxisRaw("Vertical") > 0) {
transform.Translate(0, 0, distance);
}else
if(Input.GetButtonDown("Vertical") && Input.GetAxisRaw("Vertical") < 0){
transform.Translate(0, 0, -distance);
}
}