- Home /
Question by
yttehs123 · Apr 19, 2017 at 09:29 PM ·
c#transformcharactercontrollersmooth
I have a basic character controller script set up, but the problem is that it doesn't run smoothly across the surface of a terrain, usually when there are slopes on the terrain.
using System.Collections; using System.Collections.Generic; 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 staffe = Input.GetAxis("horizontal") * speed;
translation *= Time.deltaTime;
staffe *= Time.deltaTime;
transform.Translate(staffe, 0, translation);
if (Input.GetKeyDown("escape"))
Cursor.lockState = CursorLockMode.None;
}
}
Comment
Your answer
Follow this Question
Related Questions
Move position with smoothing 0 Answers
Smooth rotation problem 1 Answer
Distribute terrain in zones 3 Answers
CharacterController.Move Not Corresponding to gameobject.transform.rotation 1 Answer
Multiple Cars not working 1 Answer