It is just from the scripting guide. However when I use it the closer to an object i get the slower it gets. If i want a change that how would i? Also why does it do it? The only change i have is the delta time cause i want to use per second not per frame
var speed : float = 3.0;
var rotateSpeed : float = 3.0;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
// Move forward / backward
var forward : Vector3 = transform.TransformDirection(Vector3.forward);
var curSpeed : float = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * Time.deltaTime * curSpeed);
}
It’s early in the morning, but I don’t see anything in that script that would cause a slower speed.
Is it getting “slower” because the object is getting bigger and your rendering speed starts choking?
Well curSpeed is speed * input axis.
then foward is times by curSpeed, so if the input axis is less, then the speed would get slower.
Yeah, but I don’t expect the input axis to drop over time; I’m assuming that’s something like a keyboard input (0, 1), maybe mouse?
it definitly 100% isn’t rendering speed. The scene is very low poly (like inbuilt primatives for testing.
Glass makes an interesting point since currently I haven’t rotated the object to look at the object. However it gets epically slow at the end.
Try adding:
Debug.Log("Forward Vector: " + forward.x + ", " + forward.y + ", " + forward.z);
Maybe your forward vector is being recalculated to smaller and smaller values.
thanks for the log tip, helped heaps!
I am an idiot for not using it in the first place
Also, just to note, you don’t need to multiply the movement vector by Time.deltaTime when you use SimpleMove (although you do when you use Move). SimpleMove already takes the delta time into account so multiplying the vector again will give you the wrong speed.