Alright, I’m working on a simple tank movement script and came across this. It works just fine until I run into a wall, or rather, don’t run into it. I know transform.Translate doesn’t take have a collision detection system, and so I’m looking for a workable alternative. Problem is, every possibility I’ve found sends up an error. Usually that it exist in the context, so I keep looking for other ways.
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public float movementSpeed = 10;
public float turningSpeed = 60;
void Update() {
float horizontal = Input.GetAxis("Horizontal") * turningSpeed * Time.deltaTime;
transform.Rotate(0, horizontal, 0);
float vertical = Input.GetAxis("Vertical") * movementSpeed * Time.deltaTime;
transform.Translate(0, 0, vertical);
}
}
I’m just going to post my own answer in case someone comes across this down the road. In order to fix the skating issue, I upped the angular drag and the drag portions of the Rigidbody. So now there is friction, and running into something results in actual collision.