Sprint UI Button!
hello unity community, i just start with unity few days a go and i wanted to resolve my self but i see i can`t do it , i have a Input code from Youtube , i managed somehow to make work on CrossPlatformInput , but i want to make a UI Button for sprint instead of Input.GetKey(KeyCode.LeftShift), and i can`t figure out how do to it , can someone help me . many thanks , this is my code for running.
bool running = Input.GetKey(KeyCode.LeftShift);
float targetSpeed = ((running) ? runSpeed : walkSpeed) * inputDir.magnitude; currentSpeed = Mathf.SmoothDamp(currentSpeed, targetSpeed, ref speedSmoothVelocity, speedSmoothTime);
transform.Translate(transform.forward currentSpeed Time.deltaTime, Space.World);,Hello guys, i am new here...i am trying to make a Sprint Button on a mobile platform...i have the code ....but i can`t figure out how to create a UI button that do Running function
bool running = Input.GetKey(KeyCode.LeftShift);
float targetSpeed = ((running) ? runSpeed : walkSpeed) * inputDir.magnitude;
currentSpeed = Mathf.SmoothDamp(currentSpeed, targetSpeed, ref speedSmoothVelocity, speedSmoothTime);
transform.Translate(transform.forward * currentSpeed * Time.deltaTime, Space.World);
float animationSpeedPercent = ((running) ? 1 : .5f) * inputDir.magnitude;
animator.SetFloat("speedPercent", animationSpeedPercent, speedSmoothTime, Time.deltaTime);
Your answer
