Esempio n. 1
0
    void moveToGoal()
    {
        Vector2 v   = Random.insideUnitCircle;
        float   len = v.magnitude;

        v *= DISTANCE_SCALE;
        Vector3 start = new Vector3(transform.position.x + v.x, 100, transform.position.z + v.y);

        RaycastHit hitInfo = new RaycastHit();

        if (Physics.Raycast(start, new Vector3(0, -1, 0), out hitInfo, Mathf.Infinity, LayerMask.GetMask("Ground")))
        {
            agent.destination = hitInfo.point;
            moveGoal          = hitInfo.point;


            JerboaCharacter jc = GetComponent <JerboaCharacter>();
            jc.StandUp();
            if (len > 0.4f)
            {
                jc.walkMode = 2f;                       //	関数 Walk() を呼ぶと動作の切り替えと勘違いするので、変数のセットを呼び出す
            }
            else
            {
                jc.walkMode = 1f;
            }
            jc.forwardSpeed = 1f;
            jc.Move();
        }
    }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            jerboaCharacter.Attack();
        }
        if (Input.GetButtonDown("Jump"))
        {
            jerboaCharacter.Jump();
        }
        if (Input.GetKeyDown(KeyCode.H))
        {
            jerboaCharacter.Hit();
        }
        if (Input.GetKeyDown(KeyCode.G))
        {
            jerboaCharacter.Grooming();
        }
        if (Input.GetKeyDown(KeyCode.K))
        {
            jerboaCharacter.Death();
        }
        if (Input.GetKeyDown(KeyCode.L))
        {
            jerboaCharacter.Rebirth();
        }

        if (Input.GetKeyDown(KeyCode.U))
        {
            jerboaCharacter.StandUp();
        }
        if (Input.GetKeyDown(KeyCode.N))
        {
            jerboaCharacter.Sitdown();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            jerboaCharacter.Gallop();
        }
        if (Input.GetKeyUp(KeyCode.R))
        {
            jerboaCharacter.Walk();
        }

        jerboaCharacter.forwardSpeed = jerboaCharacter.walkMode * Input.GetAxis("Vertical");
        jerboaCharacter.turnSpeed    = Input.GetAxis("Horizontal");
    }