public void Player1AirMovement(Player1State p1) { if (this.gameObject.tag == "Player1") { if (p1 == Player1State.Solid) { _Rb.velocity = new Vector3(Device.Direction.X * _AirSpeed, _Rb.velocity.y); if (Device.Direction.X >= 0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 90f, 0f); } else if (Device.Direction.X <= -0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 270f, 0f); } } else if (p1 == Player1State.Liquid) { _Rb.velocity = new Vector3(Device.Direction.X * _LiquidAirSpeed, _Rb.velocity.y); if (Device.Direction.X >= 0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 90f, 0f); } else if (Device.Direction.X <= -0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 270f, 0f); } } } }
private void Start() { if (this.gameObject.CompareTag("Player1")) { _Player1CurrentState = Player1State.Solid; } else if (this.gameObject.CompareTag("Player2")) { _Player2CurrentState = Player2State.Fire; } _OriginalCapsuleHeight = _CC.height; }
public void Player1Movement(Player1State p1) { if (this.gameObject.tag == "Player1") { if (p1 == Player1State.Solid) { _AudioSource.loop = false; _SoundCheckWaterMoving = false; //walking into a wall //posiiton at wall _Rb.velocity = new Vector3(Device.Direction.X * _Speed, _Rb.velocity.y); if (Device.Direction.X >= 0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 90f, 0f); } else if (Device.Direction.X <= -0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 270f, 0f); } if (Grabbing == false) { if (_IsGrounded == true && Device.Direction.X >= 0.001) { _Anim.SetFloat("Moving", Device.Direction.X); } else { _Anim.SetFloat("Moving", Device.Direction.X); } } else if (Grabbing == true) { if (_IsGrounded == true && Device.Direction.X >= 0.001) { _Anim.SetFloat("Grab_Moving", Device.Direction.X); } else { _Anim.SetFloat("Grab_Moving", Device.Direction.X); } } if (Device.Action1.WasPressed && IsGrounded() && Grabbing == false) { _AudioSource.PlayOneShot(_Jump[Random.Range(0, _Jump.Length)], 0.4f); _AudioSource.PlayOneShot(_VoiceJump[Random.Range(0, _VoiceJump.Length)], 1f); _Jumped = true; _Anim.SetTrigger("Jump"); _Rb.velocity = Vector3.up * _JumpHeight; } else if (Device.Action1.WasPressed && IsGrounded() && Grabbing == true) { _AudioSource.PlayOneShot(_Jump[Random.Range(0, _Jump.Length)], 0.4f); _AudioSource.PlayOneShot(_VoiceJump[Random.Range(0, _VoiceJump.Length)], 1f); _Jumped = true; _Anim.SetTrigger("Grabbing_Jump"); _Rb.velocity = Vector3.up * _JumpHeight; } } else if (p1 == Player1State.Liquid) { Grabbing = false; _Rb.velocity = new Vector3(Device.Direction.X * _LiquidSpeed, _Rb.velocity.y); if (Device.Direction.X >= 0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 90f, 0f); _SecondStateObject.gameObject.transform.rotation = Quaternion.Euler(0f, 180f, 0f); } else if (Device.Direction.X <= -0.01) { this.gameObject.transform.rotation = Quaternion.Euler(0f, 270f, 0f); _SecondStateObject.gameObject.transform.rotation = Quaternion.Euler(0f, -180f, 0f); } if (_IsGrounded == true && Device.Direction.X >= 0.001) { if (_SoundCheckWaterMoving == false) { _AudioSource.loop = true; _AudioSource.clip = _WaterMove; _AudioSource.Play(); _SoundCheckWaterMoving = true; } _Anim.SetFloat("Moving", Device.Direction.X); } else if (_IsGrounded == true && Device.Direction.X <= -0.001) { if (_SoundCheckWaterMoving == false) { _AudioSource.loop = true; _AudioSource.clip = _WaterMove; _AudioSource.Play(); _SoundCheckWaterMoving = true; } _Anim.SetFloat("Moving", Device.Direction.X); } else if (_IsGrounded == true && Device.Direction.X == 0) { _AudioSource.loop = false; _AudioSource.Stop(); _SoundCheckWaterMoving = false; } } } }