Beispiel #1
0
    public void Shoot(int i)
    {
        // animator.SetInteger("Shoot", i);
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出一条射线,到点击的坐标
        var point = GetPoint(ray.GetPoint(0), ray.direction, Vector3.up, new Vector3(0, hitPoint.y, 0));

        realPosition = new Vector3(point.x, transform.position.y, point.z);
        isShoot      = true;
        //SetRotation(realPosition);
        if (i < 30)
        {
            return;
        }
        BulletModel bulletModel = new BulletModel()
        {
            Count = 3, Speed = 5, Angle = 30
        };

        bulletModel.Set(hitPoint, transform.rotation); // , Count, LifeTime, BulletSpeed, Angle, Distance

        if (LimitI > CdTime * 50)
        {
            BulletManager.Instance.DoShoot(bulletModel, bulletPool);
            LimitI = 0;
        }
    }
Beispiel #2
0
    void FixedUpdate()
    {
        _timer += Time.fixedDeltaTime;
        if (_timer >= FireCD)
        {
            bulletModel.Set(this.transform.position, this.transform.rotation);
            BulletManager.Instance.DoShoot(bulletModel, bulletPool);
            _timer = 0;
        }

        transform.rotation = Quaternion.Slerp(transform.rotation, (transform.rotation * Quaternion.Euler(0, 0, rotateEulerZ)), 3 * Time.fixedDeltaTime);  //slerp
        rotateEulerZ      += 5;

        if (MoveEndPoint != Vector3.zero)
        {
            Vector3 vector = -(this.transform.position - this.MoveEndPoint) * MoveSpeed * Time.fixedDeltaTime; // 这种方式移动速度会渐慢
            Debug.Log(vector);
            this.transform.position += vector;
        }
    }