So i’m using the character controller and have set standards for when to apply gravity and normalized input into controller.move but since adding a new movement command I am getting stuff totally out of sync for some reason…
here’s what my code looks like for the two situations…
Void Update()
{
float yStore = moveDirection.y;
moveDirection.y = yStore;
moveDirection = (transform.forward * Input.GetAxis("Vertical") + (transform.right * Input.GetAxis("Horizontal")));
moveDirection = moveDirection.normalized * moveSpeed;
if (moveDirection.y > -20)
{
moveDirection.y += (Physics.gravity.y * Time.deltaTime * gravityScale);
}
controller.Move(moveDirection * Time.deltaTime);
if (Input.GetKeyDown("d"))
{
ButtonCooler = 2.0f;
ButtonCount += 1;
if (ButtonCount = 2)
{
moveDirection = transform.forward * rollDist * moveSpeed;
ButtonCount = 0;
}
}
}
now…
When I switched this last piece…
if (Input.GetKeyDown("d"))
{
ButtonCooler = 2.0f;
ButtonCount += 1;
if (ButtonCount = 2)
{
moveDirection = transform.forward * rollDist * moveSpeed;
ButtonCount = 0;
}
}
to above the line…
controller.Move(moveDirection * Time.deltaTime);
this causes the transform forward to work but then breaks my gravity for some reason…
Please can you Help? I think this comes down to how I am ordering these operations and for some reason my brain isn’t clicking onto the “proper” order to do these functions.
I tried moving this d button piece around and it doesn’t change the fact that gravity remains broken, it actually causes more issues with movement…
Even just a general explanation on how the character controller is taking input on .move would help…
I have read this Unity - Scripting API: CharacterController.Move
but it doesn’t cover what i’m asking for or maybe i’m misunderstanding…