Exemplo n.º 1
0
    void TestTurn()
    {
        float mouseSensitivity = 3.0f;
        float mouseX           = -Input.GetAxis("Mouse X") * mouseSensitivity;
        float mouseY           = Input.GetAxis("Mouse Y") * mouseSensitivity;

        testMod.Turn(mouseX, mouseY);
    }
Exemplo n.º 2
0
    private void HandleMouseMove()
    {
        //当鼠标右键未被按下时,才需要对角色的朝向方向作修改
        if (!Input.GetMouseButton(1))
        {
            float mouseX = -Input.GetAxis("Mouse X") * mouseSensitivity;
            float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity;

            objectBehaviour.Turn(mouseX, mouseY);
        }
    }
Exemplo n.º 3
0
 protected void Wander()
 {
     resetCountForWander -= Time.deltaTime;
     if (resetCountForWander <= 0.0f)
     {
         float p = Random.Range(0.0f, 1.0f);
         if (p < 0.8f)
         {
             turnHorizontal      = Random.Range(-0.3f, 0.3f);
             turnVertical        = Random.Range(-0.1f, 0.1f);
             resetCountForWander = Random.Range(2.0f, 5.0f);
         }
         else
         {
             Vector3 dir = GetRandomDirection();
             objectBehaviour.SetForwardDirecion(dir);
             turnHorizontal      = 0.0f;
             turnVertical        = 0.0f;
             resetCountForWander = 0.1f;
         }
     }
     objectBehaviour.Turn(turnHorizontal, turnVertical);
     objectBehaviour.Move(ObjectBehaviour.MoveDirection.Front, speed);
 }