Hey Guys, Thankyou for trying to help me out,
I have **"Script A"** that is a component on **enemy gameObjects.**
Within the script i have a variable that gives myself access to **"Script B"**
public AdjustLighting adjustLightingScript;
and a Method that executes every time an enemy collides with my player:
void OnTriggerEnter(Collider col) {
if (col.gameObject.tag == "Player") {
adjustLightingScript.DimPlayerLight();
}
}
On **"Script B"** i have this method (the one that is being called from **"Script A"**):
public void DimPlayerLight(){
playerLight.light.range = Mathf.Lerp (playerLight.light.range, playerLight.light.range - 0.5f, Time.deltaTime);
}
What i'm hoping to achieve is, every time a my player gets hurt, the **point light** i have attached to him gets dimmer in **incremental steps**, but with a smooth lerp, If i stick it in an update loop it won't achieve what i'm after.
Anyway, it works for a split second, but obviously doesn't finish the lerp because the OnTriggerEnter only gets called once,
> how can i get the method to run until> the lerp is complete?
Its very late and i'm sure that there is an easy solution but right now i have no idea and have been trying things for ages..... coding block!
↧