How to stop climbing walls?

Maybe I was asking wrong. How do I stop my tank from climbing walls??

I’m at a loss. How do I stop my tank from climbing walls and going all wonky. I was it to hit a wall and stop. My full controller is here. The relevant bits are below.

89763-screen-shot-2017-03-11-at-45327-pm.jpg

void FixedUpdate () {
		if (!isServer) {
			return;
		}

		CheckGrounded ();
		Hoover ();

		if (_moveForward) {
			float moveAmount = moveSpeed * Time.deltaTime;
			_rigidbody.MovePosition (_rigidbody.position + _rigidbody.transform.forward * moveAmount);
		}
		if (_moveBackward) {
			float moveAmount = (-moveSpeed * 0.6f) * Time.deltaTime;
			_rigidbody.MovePosition (_rigidbody.position + _rigidbody.transform.forward * moveAmount);
		}

		if (_turnLeft) {
			Quaternion rotateAmount = Quaternion.Euler (new Vector3 (0f, -angularSpeed, 0f) * Time.deltaTime);
			_rigidbody.MoveRotation (_rigidbody.rotation * rotateAmount);
		}
		if (_turnRight) {
			Quaternion rotateAmount = Quaternion.Euler (new Vector3 (0f, angularSpeed, 0f) * Time.deltaTime);
			_rigidbody.MoveRotation (_rigidbody.rotation * rotateAmount);
		}

		if (_jump && _isGrounded) {
			_isJumping = true;
		}

		if (_isJumping && _jumpTimeLeft > 0) {
			float moveAmount = jumpSpeed * Time.deltaTime;
			_rigidbody.MovePosition (_rigidbody.position + _rigidbody.transform.up * moveAmount);

			_jumpTimeLeft -= Time.deltaTime;
		} else if (_isJumping) {
			_isJumping = false;
			_jumpTimeLeft = jumpTime;

		}
	}

	void Update() {
		// Keep things level
		if (q.x - transform.rotation.x > maxTilt) {
			transform.rotation = new Quaternion (q.x + maxTilt, transform.rotation.y, transform.rotation.z, transform.rotation.w);
		}


		if (q.x - transform.rotation.x < -maxTilt) {
			transform.rotation = new Quaternion (q.x - maxTilt, transform.rotation.y, transform.rotation.z, transform.rotation.w);
		}

		if (q.z - transform.rotation.z > maxTilt) {
			transform.rotation = new Quaternion (transform.rotation.x, transform.rotation.y, q.z + maxTilt, transform.rotation.w);
		}


		if (q.z - transform.rotation.z < -maxTilt) {
			transform.rotation = new Quaternion (transform.rotation.x, transform.rotation.y, q.z - maxTilt, transform.rotation.w);
		}
	}

	void CheckGrounded() {
		Ray ray = new Ray(centerPoint.position, -centerPoint.up);
		RaycastHit hitInfo;

		if (Physics.Raycast(ray, out hitInfo, groundedThreshold, _groundLayer)) {
			_isGrounded = true;
		} else {
			_isGrounded = false;
		}
	}

	void Hoover() {
		foreach (Transform hoverPoint in hooverPoints) {
			_rigidbody.AddForceAtPosition (-hoverPoint.up * hooverForce / 10, hoverPoint.position, ForceMode.Force);

			Ray ray = new Ray (hoverPoint.position, -hoverPoint.up);
			RaycastHit hitInfo;

			if (Physics.Raycast (ray, out hitInfo, hooverHeight)) {
				float distance = Vector3.Distance (hoverPoint.position, hitInfo.point);

				if (distance < hooverHeight) {
					_rigidbody.AddForceAtPosition (hoverPoint.up * hooverForce * (1f - distance / hooverHeight), hoverPoint.position, ForceMode.Force);
				}
			}
		}
	}

If the wall is on a slant maybe try placing a cube which is transparent (Or close enough so it still works) but if it is a straight wall then you may need to change your script

Never forget that games are nothing else than smoke and mirrors, i imagine a lot of workarounds. If your terrain is fully designed and it is quite “important”, you may put some invisible box colliders where you dont want your player to go to… pretty much like AAA games. In my opinion this is the most realistic way to do this, but it is incompatible with auto generated terrains unless you have auto generated colliders too.

Another posiblity is to make this through code. Scince you dont want your tank to move at all into those walls, you can cast a ray from the bottom of your tank (perhaphs you’ll have to do it from a little more above if your terrain is not flat) and if it hits something at a certain distance, let’s say 0.1 metres, you can disable movement in that direction.

However if you chose this second alternative remember that one ray may not be enough, you may need to make a for loop and cast rays from all your tank base (from left to right, relative to where your ray is going). Because if not it will only collide with something in front of it but not at the front sides of the tank.