Function another function
-
Two functions.
void Update () { float input_x = MovementJoystick.GetAxis("Horizontal"); float input_y = MovementJoystick.GetAxis("Vertical"); bool isWalking = (Mathf.Abs(input_x) + Mathf.Abs(input_y)) > 0;
anim.SetBool("isWalking", isWalking); if (isWalking) { anim.SetFloat("x", input_x); anim.SetFloat("y", input_y); transform.position+=new Vector3(input_x, input_y, 0).normalized*playerSpeed*Time.deltaTime; }
}
and
void fastRun()
{
playerSpeed = 12;
}
They're in the same violin. I need something in.
void fastRun
Call.void Update
but with other importance playerSpeed. Is that possible?
-
playerSpeed
You seem to have a class field.Method
Update
always use current (current) meaningplayerSpeed
♪ I mean, to call him "with different meanings," you just need to take that meaning.playerSpeed
and after the challenge, return the original:I mean, you need something like that.
void fastRun() { var temp = playerSpeed; playerSpeed = другое значение; Update(); playerSpeed = temp; }
Although, to be honest, you probably just have to call Update:
void fastRun() { playerSpeed = 12; Update(); }