Answer the question
In order to leave comments, you need to log in
The scale value does not return to the default value, what should I do?
private bool sit = false;
if (Input.GetKey("s"))
{
sit = true;
}
if (sit)
{
transform.localScale = new Vector3(1, 0.5f, 1);
}
if (sit = false)
{
transform.localScale = new Vector3(1, 1, 1);
}
I want the scale value to return the default value after the key is released
Answer the question
In order to leave comments, you need to log in
1. It is necessary that sit
it takes the value false after releasing.
2. It would not be bad to repeat
you can make things much simpler
[SerializeField] private float SittingValue;
private void Update()
{
OnSit();
}
public void OnSit()
{
if (Input.GetKey("s"))
{
transform.localScale = new Vector3(transform.localScale.x, SittingValue, transform.localScale.z);
}
else
{
transform.localScale = new Vector3(transform.localScale.x, 1f, transform.localScale.z);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question