What I want to make is..
'for example, Ezreal, the character is in the game named ‘League of Legends’
and this character has skill that
if this character hit the special arrow(skill), ezreal’s all the skill cooltime reduce 1.5seconds.
so I tried with time.deltatime
but it works very wrong.
first my code is
Script A
void FixedUpdate()
{
UltMode();
if (Input.GetButtonDown("UltMode") && currentUltgauge == maxUltgauge)
{
SetPlayerState(PlayerState.Ultimate);
}
}
public void UltMode()
{
if (isCharge == true)
{
currentUltgauge += 1 * Time.deltaTime;
Debug.Log(currentUltgauge);
if (currentUltgauge == maxUltgauge)
{
isCharge = false;
Debug.Log(“your ult is Ready”);
return;
}
}
}
this code works very well, but if i add function that add value to’ currentUltgauge’ while time.deltaTime works, the log shows infinity.
here’s what i did. Bold letters means, I add some code to perform a function.
ScriptA
void FixedUpdate()
{
UltMode(**0**);
if (Input.GetButtonDown("UltMode") && currentUltgauge == maxUltgauge)
{
SetPlayerState(PlayerState.Ultimate);
}
}
public void UltMode(float gauge)
{
if (isCharge == true)
{
currentUltgauge += 1 * Time.deltaTime;
**currentUltgauge += gauge;**
Debug.Log(currentUltgauge);
if (currentUltgauge == maxUltgauge)
{
isCharge = false;
Debug.Log("your ult is Ready");
return;
}
}
}
Script B
void OnTriggerEnter2D(Collider2D col)
{
if(col.tag == “EnemyShipTag”)
{
col.gameObject.SendMessage(“UltMode”, 10f, SendMessageOptions.DontRequireReceiver);
Destroy(gameObject);
}
}
well.. I tried like this.. but not really works.
may be i tried wrong way(pool programming skill, started learning programming a month ago)
can somebody help me to solve this problem?
I tried the second one you answered, Code works, but I still don't know how coroutine works :( I think, I need to spend a time to master coroutine :) Thank you for answering, it really helped me :)
– FrionielYou have isTrigger checked? I'm running out of ideas here and sense this is something basic that's been missed.
– getyour411Still nothing /:
– nickilak