i have made a game where the player rorotae in freeze posotins
i need to move it by button press yet i can’t found any script that work
i can simplay make speed=0 and make button to incress it but i want to add movement Animations
so how do i make the player move in the dirctions hes facing by press of a button?
(he can rotate 360 degree)
You could try this:
float speed;
public float increasePerClick;
void Update()
{
transform.position += transform.forward * speed * Time.deltaTime; // move based on speed and rotation
if (speed > 0) // If is moving
{
// Movement Animations
}
}
public void ChangeSpeed()
{
speed += increasePerClick;
}
And Link the button to the ChangeSpeed Method.
Depending on whether you use transform.position or Character Controller you should change between transform.position +=
and CharacterController.Move()
.
Hope I could help!