示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (TargetModel != null)
        {
            TargetModel.Move(new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")));

            if (Input.GetKeyDown(ability1Key))
            {
                TargetModel.Ability1();
            }
            if (Input.GetKeyDown(ability2Key))
            {
                TargetModel.Ability2();
            }
            if (Input.GetKeyDown(ability3Key))
            {
                TargetModel.Ability3();
            }
            if (Input.GetKeyDown(ability4Key))
            {
                TargetModel.Ability4();
            }
            if (Input.GetKeyDown(ability5Key))
            {
                TargetModel.Ability5();
            }

            // Mouse position target
            Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);

            RaycastHit hitInfo;
            Physics.Raycast(ray, out hitInfo);
            Debug.DrawLine(hitInfo.point, hitInfo.point + Vector3.up * 10, Color.red);

            TargetModel.Target = hitInfo.point;
        }
    }