public override void OnOverlap(PlayerMovement pm) { PlayerMovement jumpIncrease = pm.GetComponent <PlayerMovement>(); if (jumpIncrease) { /// once you pick up the item your character now has super jump, doubling your jump impulse jumpIncrease.jumpImpulse += 7; Destroy(gameObject); } }
/// <summary> /// this will check to see if the player has overlapped the object and if so pick it up and changed the player jump impulse /// </summary> /// <param name="pm"></param> public override void OnOverlap(PlayerMovement pm) { // if the boost is picked up then apply boost to player movement PlayerMovement jumpIncrease = pm.GetComponent <PlayerMovement>(); if (jumpIncrease) { /// once you pick up the item your character now has super jump, doubling your jump impulse jumpIncrease.jumpImpulse += 7; // increases jump impulse by 7 Destroy(gameObject); //destroys the boost item after it is picked up by player } }
/// <summary> /// once the player overlaps with the hazard /// </summary> /// <param name="pm"></param> public override void OnOverlap(PlayerMovement pm) { // hp Health hp = pm.GetComponent <Health>();// is getting a reference to the player healrh if (hp) { hp.TakeDamage(damageAmount);// do damage to the player } Vector3 vToPlayer = (pm.transform.position - this.transform.position).normalized.normalized; pm.LaunchPlayer(vToPlayer * 7);// when the player its the hazard it will knock it back }