Hi i wanna have a Field In my FPS game which will Shrink you for a bit of time and then it will put you back to normal,but the Game is FPS so i cant list the Player In the Inspector and i tried the Prefab but it no workie,
Any idea how to do this?
Sounds as simple as this. You probably want to check whether the collider is the correct one. And you probably want to add some checks so that the effect doesn’t stack. (Happens twice at the same time.)
protected void OnTriggerEnter(Collider collider) {
StartCoroutine(AdjustScale());
}
private IEnumerator AdjustScale() {
transform.localScale *= 0.5f;
yield return new WaitForSeconds(5);
transform.localScale /= 0.5f;
}
OnTriggerEnter has a Collider parameter. That is a reference to the collider that has entered the trigger. The Collider has a property called gameObject, which refers to the game object that the collider is attached to. gameObject has a member called transform which you can update the scale