public void Interact(GameObject player) { /** * Adds the bouncers velocity to the player on contact */ if (disableTime <= 0) { audsrc.PlayOneShot(bounceSound, 0.5f); PlayerScript ps = player.GetComponent <PlayerScript>(); BottleScript bs = player.GetComponent <BottleScript>(); // Bounce player if (ps != null) { ps.transform.position = bounce_offset; ps.AddVelocity(deltav); ps.UnStun(); disableTime = 0.1f; animator.SetTrigger("bounce"); } // Bounce bottle if (bs != null) { bs.transform.position = bounce_offset; bs.AddVelocity(deltav); disableTime = 0.1f; animator.SetTrigger("bounce"); } } }
private void WithPlayer(ref Vector3 velocity) { if (gapTime > 0) { gapTime -= Time.deltaTime; } Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Jump")); if (input.z == 1 && gapTime <= 0 && !c2d.collision.above || ps.IsDead()) { Release(); return; } ps.DestroyCrumbs(0.25f); ps.MultiplyVelocity(0); ps.AddVelocity(ps.Velocity()); velocity.x += input.x * acceleration * Time.deltaTime; }