// Use this for initialization void Start() { controller = GetComponent <Controller2D>(); player = Player.instance.gameObject; jumpTimer = gameObject.AddComponent <BoolTimer>().Constructor(true); updateInput = gameObject.AddComponent <BoolTimer>().Constructor(true); gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; }
private void Awake() { weapon = FindObjectOfType <PlayerWeapon>(); if (instance == null || instance == this) { DontDestroyOnLoad(this.gameObject); instance = this; } else { Destroy(this.gameObject); } if (instance != null) { Debug.Log(instance); Debug.Log(instance.gameObject); Debug.Log("Instances same: " + (instance == this)); } else { Debug.Log("instance = null"); } /* if (instance == null) * { * DontDestroyOnLoad(this.gameObject); * instance = this; * } else { * Destroy(this.gameObject); * } */ controller = GetComponent <Controller2D>(); animator = GetComponent <Animator>(); collider = GetComponent <BoxCollider2D>(); gravity = -(2 * jumpHeight) / Mathf.Pow(timeToJumpApex, 2); jumpVelocity = Mathf.Abs(gravity) * timeToJumpApex; inputScale = gameObject.AddComponent <FloatTimer>().Constructor(1f); accelerationTimeAirborne = gameObject.AddComponent <FloatTimer>().Constructor(baseAccelerationTimeAirborne); accelerationTimeGrounded = gameObject.AddComponent <FloatTimer>().Constructor(baseAccelerationTimeGrounded); dashOnCooldown = gameObject.AddComponent <BoolTimer>().Constructor(false); }
private void Start() { player = GameManager.Instance.player; portalCooldown = gameObject.AddComponent <BoolTimer>().Constructor(false); }