Example #1
0
    // Update is called once per frame
    void LateUpdate()
    {
        isGrounded = Physics.CheckSphere(
            groundCheck.position,
            groundCheckRadius,
            groundLayerMask);

        if (isGrounded && vel.y < 0)
        {
            vel.y = -1;
        }

        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 movement =
            transform.right * x +
            Cam.transform.forward * z;

        controller.Move(movement * movementSpeed * Time.deltaTime);

        if (Input.GetButton("Jump"))
        {
            if (!HeadWaterSurfaceScript.AboveWater())
            {
                vel.y = Mathf.Sqrt(jumpForce * -2 * startGravity);
            }
        }

        vel.y += Gravity * Time.deltaTime;

        controller.Move(vel * Time.deltaTime);
    }
Example #2
0
    private void Start()
    {
        UpdateShader();

        //for prototype fps scene
        HeadWaterSurfaceScript.OnAboveWater e = delegate()
        {
            ToggleFog();
        };

        HeadWaterSurfaceScript.AddOnAboveWaterEvent(e);
    }
Example #3
0
 private void Awake()
 {
     s = this;
 }