void FixedUpdate()
 {
     if (target != null)
     {
         rotateToMouse.RotateToMouse(gameObject, target.transform.position);
     }
     if (speed != 0 && rb != null)
     {
         rb.position += (transform.forward + offset) * (speed * Time.deltaTime);
     }
 }
Example #2
0
    public void SpawnVFX()
    {
        GameObject vfx;

        var cameraShakeScript = cameras.GetComponent <CameraShakeSimpleScript> ();

        if (cameraShake && cameraShakeScript != null)
        {
            cameraShakeScript.ShakeCamera();
        }

        if (firePoint != null)
        {
            vfx = Instantiate(effectToSpawn, firePoint.transform.position, Quaternion.identity);
            if (!useTarget)
            {
                if (rotateToMouse != null)
                {
                    vfx.transform.localRotation = rotateToMouse.GetRotation();
                }
                else
                {
                    Debug.Log("No RotateToMouseScript found on firePoint.");
                }
            }
            else
            {
                if (target != null)
                {
                    vfx.GetComponent <ProjectileMoveScript>().SetTarget(target, rotateToMouse);
                    rotateToMouse.RotateToMouse(vfx, target.transform.position);
                }
                else
                {
                    Destroy(vfx);
                    Debug.Log("No target assigned.");
                }
            }
        }
        else
        {
            vfx = Instantiate(effectToSpawn);
        }
    }