Hello everyone,
Since I’ve been doing some research for my game and making different system, I’m actually scratching my head off on something who seems sooooo easy… well i’m making a “ant-man” system where the player is being reduced by 5 is scale when you hit the “f” button. But it keeps being reduced when you hit a second time “f”. I would like not you know haha, just like a jumping system. I konw it will be a simple answer but you know that kind of stuff making you crazyyy… here the script guys and thanks for your time. peeeace.
using UnityEngine;
using System.Collections;
public class changeOnButton : MonoBehaviour {
bool timing = false;
float time = 5.0f;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("f"))
{
transform.localScale = new Vector3(transform.localScale.x / 5, transform.localScale.y / 5, transform.localScale.z / 5);
timing = true;
}
if(timing)
{
time -= Time.deltaTime;
if(time <= 0)
{
transform.localScale = new Vector3(transform.localScale.x * 5, transform.localScale.y * 5, transform.localScale.z * 5);
timing = false;
time = 5.0f;
}
}
}
}