void FixedUpdate() { PlayState state = PlayState.Selection; if (gameController != null) { state = gameController.State; } if (state == PlayState.PrePlay || state == PlayState.PostPlay) { GetComponent <Rigidbody>().velocity = Vector3.zero; return; } jumpTimer -= Time.fixedDeltaTime; isGrounded = BottomChecker.IsCollidingWith("Wall") || BottomChecker.IsCollidingWith("Player"); if (isGrounded && jumpWasPressed) { jumpTimer = JumpTime; } var move = playerInfo.PlayerActions.Move.Value; MovementUpdate(move); }
public void Shoot() { if (NozzleChecker.IsCollidingWith("Wall")) { return; } var projGo = (GameObject)Instantiate(ProjPrefab, Nozzle.position, Nozzle.rotation); projGo.transform.parent = railShotsBase; RailShot railShot = projGo.GetComponent <RailShot>(); railShot.Player = this; railShot.Shoot(Nozzle); }
private void MovementUpdate(float move) { var rigidbody = GetComponent <Rigidbody>(); float x = 0; float y = rigidbody.velocity.y; if (jumpTimer > 0) { if (TopChecker.IsCollidingWith("Wall")) { jumpTimer = float.MinValue; } else { y = JumpSpeed; } } else if (!isGrounded) { y = -JumpSpeed; //gravity } if (Mathf.Abs(move) > 0.15f) { if (move > 0) { x = MoveSpeed; } if (move < 0) { x = -MoveSpeed; } } rigidbody.velocity = new Vector3(x, y, 0); }