コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        float translation = Input.GetAxis("Vertical") * speed;
        float straffe     = Input.GetAxis("Horizontal") * speed;

//		float translation = Input.GetAxis ("Vertical");
//		float straffe = Input.GetAxis ("Horizontal");

//		movementVec = new Vector3 (straffe, 0, translation);
//		movementVec = movementVec.normalized;

        translation *= Time.deltaTime;
        straffe     += Time.deltaTime;

        positionOne = transform.position;
//		if (Input.GetAxis ("Vertical") > 0) {
//			transform.Translate (straffe / 100, 0, translation);
//		}
//		if (Input.GetAxis ("Horizontal") > 0) {
//			transform.Translate (straffe / 100, 0, translation);
//		}
//		if (Input.GetAxis ("Vertical") < 0) {
//			transform.Translate (straffe / 100, 0, translation);
//		}
//		if (Input.GetAxis ("Horizontal") < 0) {
//			transform.Translate (straffe / 100, 0, translation);
//
//		}
        if (Input.GetAxis("Vertical") > 0)
        {
            transform.Translate(0, 0, translation);
        }
        if (Input.GetAxis("Horizontal") > 0)
        {
            transform.Translate(straffe / 50, 0, 0);
        }
        if (Input.GetAxis("Vertical") < 0)
        {
            transform.Translate(0, 0, translation);
        }
        if (Input.GetAxis("Horizontal") < 0)
        {
            transform.Translate(straffe / 50, 0, 0);
        }

        positionTwo = transform.position;

        if (positionOne != positionTwo && audso.sourceTwoIsPlaying() == false)
        {
            Debug.Log("play footsteps");
            audso.playFootsteps();
        }

        if (positionOne == positionTwo)
        {
            audso.stopFootsteps();
        }

        if (Input.GetKeyDown("escape"))
        {
            Cursor.lockState = CursorLockMode.None;
        }
    }