コード例 #1
0
ファイル: PlayerController.cs プロジェクト: Kazetsukai/Isshun
    void FixedUpdate()
    {
        //Input
        var accel = Input.GetAxisRaw("Horizontal") * Acceleration;

        if (Mathf.Abs(accel) < 0.01f)
        {
            playerPhysics.Hold();
        }
        else
        {
            playerPhysics.Accelerate(new Vector2(accel, 0));
        }


        Debug.Log("Horizontal = " + Input.GetAxisRaw("HorizontalAim") + "    Vertical = " + Input.GetAxisRaw("VerticalAim"));
        var sphere = GameObject.Find("Sphere");

        sphere.transform.localPosition = new Vector3(Mathf.RoundToInt(Input.GetAxisRaw("HorizontalAim")), -Mathf.RoundToInt(Input.GetAxisRaw("VerticalAim"))).normalized * 0.5f;
        if (Mathf.Abs(Input.GetAxisRaw("HorizontalAim")) < 0.01f)
        {
            sphere.transform.localPosition = Vector3.right;
        }

        if (Input.GetButton("Fire1"))
        {
            Debug.Log("JUMP!!!");
            playerPhysics.Jump();
        }

        if (Input.GetButton("Fire2"))
        {
            FireLaser(sphere.transform.position, sphere.transform.position + sphere.transform.localPosition.normalized * 100);
        }
    }