Question by
weirdactivities · Jan 24, 2018 at 02:00 AM ·
charactercontrollerhowwalls
i keep going through walls please help
is my script the problem?
using System.Collections; using UnityEngine;
public class CharacterController : MonoBehaviour {
public float speed = 10.0f;
// Use this for initialization
void Start ()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update () {
float translation = Input.GetAxis("Vertical") * speed;
float straffe = Input.GetAxis("Horizontal") * speed;
translation *= Time.deltaTime;
straffe *= Time.deltaTime;
transform.Translate(straffe, 0, translation);
if (Input.GetKeyDown("escape"))
Cursor.lockState = CursorLockMode.None;
}
}
Comment