So, basically, I’d like to be able to control the smoothness of how much the character slides before he fully stops when you’re not holding in a movement key anymore. I’d also like to make it so my character gradually increases its movementspeed until its max speed. I’ve tried several ways of doing this with Vector3.SmoothDamp and Mathf.SmoothDamp. lots of errors pop up, so I guess my logic isn’t in the correct place.
Any help would be Appreciated.
Here’s the character’s script. It fully works, it’s very simple and clean, I guess. I’m hoping that someone could add some stuff to the script that would make the character do what I want it to do, if not that, just guide me in the right direction, please. Thank you so much.
using UnityEngine;
using System.Collections;
public class PlayerControllerScript : MonoBehaviour
{
float MoveHorizontal;
float MoveVertical;
float MovementSpeed = 3f;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
CharacterController();
}
void CharacterController()
{
//Find the camera.
GameObject Target = GameObject.Find ("Camera");
//Initialize the movement Axes to the appropriate keys.
MoveHorizontal = Input.GetAxisRaw ("Horizontal") * Time.deltaTime * MovementSpeed;
MoveVertical = Input.GetAxisRaw ("Vertical") * Time.deltaTime * MovementSpeed;
//Execute the movement.
Vector3 Movement = new Vector3(MoveHorizontal, 0, MoveVertical);
transform.Translate (Movement);
transform.eulerAngles = new Vector3(transform.eulerAngles.z, Target.transform.eulerAngles.y, transform.eulerAngles.x);
}
}