- Home /
How do I get a charge shoot with power equal to time?
Hi I want to create an Powershoot by holding the Firebutton. The power shold be equal to the seconds I hold the Firebutton. And I want to change the transform-size of that shoot. But I also want to keep the singel shot by klicking on the same Firebutton too. So klick 1 ore more times fire 1 time ore fire everytime you are klicking (4 times per sec is max). klick and hold the firebutton the chargeshoot shold be loadet up.
please give me a hint how to solve this problem.
This is how far I got...... yes I am new ;)
public float chargeLevel; public float chargeLimit; public float chargeStart; public float chargeEnd;
void Update()
{
if (Input.GetButtonDown("Fire1") && chargeLevel < chargeLimit)
{
chargeLevel += Time.deltaTime;
chargeStart = Time.time;
}
if (Input.GetButtonUp("Fire1"))
{
chargeEnde = Time.time - chargeStart;
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
chargeLevel = 0;
}
}
Thanks to all for your help
Hyro
Your answer
Follow this Question
Related Questions
Transform.position assign attempt error - NaN 0 Answers
Rotation-Trouble 4 Answers
Fixing Diagnol Speed Boost C# 1 Answer
Anomaly: Mouse Y also affects its X value. Values tied to object position. 2 Answers
[SOLVED] Object keeps sliding? 2 Answers