Search Unity

Help Wanted The type or namespace name 'ImageEffects' does not exist in the namespace

Discussion in 'Unity Distribution Portal (UDP)' started by MacToop, Aug 26, 2021.

  1. MacToop

    MacToop

    Joined:
    Apr 24, 2020
    Posts:
    1
    Hello to everyone. I'm making a car racing game and using a package called 'Extreme Drift'. But I'm having some problems with the script below.
    The error I get is: Assets\Extreme Drift\Scripts\Vehicle\VehicleCamera.cs(4.31): error CS0234: The type or namespace name 'ImageEffects' does not exist in the namespace 'UnityStandardAssets' (are you missing an assembly reference?)

    Code (CSharp):
    1. using UnityEngine;
    2.     using System.Collections;
    3.     using System.Collections.Generic;
    4.     using UnityStandardAssets.ImageEffects;
    5.  
    6. public class VehicleCamera : MonoBehaviour
    7. {
    8.     public static VehicleCamera manage;
    9.  
    10.  
    11.     public float smooth = 0.3f;
    12.  
    13.     public float distance = 5.0f;
    14.     public float height = 1.0f;
    15.     public float angle = 20;
    16.  
    17.     public LayerMask lineOfSightMask = 0;
    18.  
    19.     [HideInInspector]
    20.     public Transform target;
    21.     [HideInInspector]
    22.     public List<Transform> cameraSwitchView;
    23.  
    24.     private bool farCameraView = false;
    25.  
    26.  
    27.  
    28.     private float Xsmooth;
    29.     private float farDistance = 0.0f;
    30.     private float zAngleAmount = 0.0f;
    31.     private float timeScale = 0.0f;
    32.     private float currentDistance;
    33.  
    34.     private int Switch = -1;
    35.  
    36.  
    37.     void Awake()
    38.     {
    39.         manage = this;
    40.         farCameraPosition = transform.position;
    41.     }
    42.  
    43.  
    44.     void Start()
    45.     {
    46.         farCameraView = true;
    47.         farCameraPosition = (AIControl.manage.firstAINode.GetComponent<AINode>().nextNode
    48.             .GetComponent<AINode>().nextNode
    49.             .GetComponent<AINode>().nextNode
    50.             .GetComponent<AINode>().nextNode
    51.             .GetComponent<AINode>().nextNode
    52.             .GetComponent<AINode>().nextNode.position)
    53.             + new Vector3(Random.Range(-5.0f, 5.0f), Random.Range(5.0f, 10.0f), Random.Range(-5.0f, 5.0f));
    54.     }
    55.  
    56.  
    57.  
    58.     void LateUpdate()
    59.     {
    60.  
    61.         if (GameUI.manage.gameFinished)
    62.             Switch = 4;
    63.  
    64.         farDistance = Vector3.Distance(farCameraPosition, target.position);
    65.         if (farDistance < 100.0f && farCameraView) farCameraView = false;
    66.  
    67.         transform.GetComponent<Blur>().enabled = GameUI.manage.gamePaused ? true : false;
    68.  
    69.         // add MotionBlur effect to camera
    70.         if (AIControl.CurrentVehicle.shifting || GameUI.manage.driftAmount > 25)
    71.             transform.GetComponent<MotionBlur>().blurAmount = Mathf.Lerp(transform.GetComponent<MotionBlur>().blurAmount, 0.5f, Time.deltaTime * 5);
    72.         else
    73.            transform.GetComponent<MotionBlur>().blurAmount = Mathf.Lerp(transform.GetComponent<MotionBlur>().blurAmount, 0.0f, Time.deltaTime);
    74.  
    75.  
    76.  
    77.         if (Switch == -1)
    78.         {
    79.  
    80.             RenderSettings.flareStrength = 0.3f;
    81.  
    82.             GetComponent<Camera>().fieldOfView = Mathf.Clamp(AIControl.CurrentVehicle.speed / 10.0f + 60.0f, 60, 90.0f);
    83.  
    84.             currentDistance = distance;
    85.             float yAngle = Mathf.SmoothDampAngle(transform.eulerAngles.y,
    86.             target.eulerAngles.y, ref velocity.y, smooth);
    87.  
    88.             float xAngle = Mathf.SmoothDampAngle(transform.eulerAngles.x,
    89.             target.eulerAngles.x + (angle), ref velocity.x, smooth);
    90.  
    91.             // Look at the target
    92.             transform.eulerAngles = new Vector3(xAngle, yAngle, AccelerationAngle());
    93.  
    94.             Xsmooth = Mathf.Lerp(Xsmooth, velocity.y, Time.deltaTime * 10.0f);
    95.             var direction = transform.rotation * -new Vector3(-Xsmooth / 300.0f, 0, 1);
    96.             var targetDistance = AdjustLineOfSight(target.position + new Vector3(0, height, 0), direction);
    97.  
    98.             transform.position = target.position + new Vector3(0, height, 0) + direction * targetDistance;
    99.  
    100.         }
    101.         else if (Switch < AIControl.CurrentVehicle.cameraView.cameraSwitchView.Count)
    102.         {
    103.  
    104.             RenderSettings.flareStrength = 0.3f;
    105.             GetComponent<Camera>().fieldOfView = 60;
    106.             transform.position = cameraSwitchView[Switch].position;
    107.             transform.rotation = Quaternion.Lerp(transform.rotation, cameraSwitchView[Switch].rotation, Time.deltaTime * 5.0f);
    108.  
    109.         }
    110.         else {
    111.  
    112.             if (farDistance > 120.0f && !farCameraView)
    113.             {
    114.                 farCameraPosition = (AIControl.CurrentVehicle.AIVehicle.nextNode
    115.                     .GetComponent<AINode>().nextNode
    116.                     .GetComponent<AINode>().nextNode
    117.                     .GetComponent<AINode>().nextNode
    118.                     .GetComponent<AINode>().nextNode
    119.                     .GetComponent<AINode>().nextNode
    120.                     .GetComponent<AINode>().nextNode.position)
    121.                     + new Vector3(Random.Range(-5.0f, 5.0f), Random.Range(10.0f, 15.0f), Random.Range(-5.0f, 5.0f));
    122.  
    123.                 farCameraView = true;
    124.  
    125.             }
    126.            
    127.  
    128.             RenderSettings.flareStrength = 0.0f;
    129.  
    130.             GetComponent<Camera>().fieldOfView = Mathf.Clamp(50.0f - (farDistance / 2.0f), 10.0f, 120.0f);
    131.  
    132.             var newRotation = Quaternion.LookRotation(target.position - transform.position);
    133.  
    134.             transform.position = farCameraPosition;
    135.             transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime * 15);
    136.         }
    137.  
    138.     }
    139.  
    140.  
    141.  
    142.     public void CameraSwitch()
    143.     {
    144.         Switch++;
    145.         if (Switch > AIControl.CurrentVehicle.cameraView.cameraSwitchView.Count) { Switch = -1; }
    146.     }
    147.  
    148.     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    149.  
    150.     private float AccelerationAngle()
    151.     {
    152.         zAngleAmount = Mathf.Clamp(zAngleAmount, -45.0f, 45.0f);
    153.         zAngleAmount = Mathf.Lerp(zAngleAmount, Input.acceleration.x * -70.0f, Time.deltaTime * 2.0f);
    154.         return zAngleAmount;
    155.     }
    156.  
    157.  
    158.     float AdjustLineOfSight(Vector3 target, Vector3 direction)
    159.     {
    160.         RaycastHit hit;
    161.  
    162.         if (Physics.Raycast(target, direction, out hit, currentDistance, lineOfSightMask.value))
    163.             return hit.distance;
    164.         else
    165.             return currentDistance;
    166.     }
    167.  
    168.  
    169. }
    170.  
    171.  
    172.  


    I would be glad if you help.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    7,128
    the old ImageEffects is now unity Post Processing,
    https://docs.unity3d.com/Packages/com.unity.postprocessing@3.0/manual/index.html

    so those scripts are probably for quite old unity version.

    *yup, that package is for unity 5.5, so you should cleanup the project a bit, take only what you need and then
    import that new post processing using package manager (to use Blurs, blooms and other effects)
    https://assetstore.unity.com/packages/templates/systems/extreme-drift-88601

    you'll have to modify some of that code also, cannot access new image effects the same way,
    search for: adjust post processing from script, or similar.

    *or if you want easy life, download that specific unity version and use that to learn first:
    https://unity3d.com/get-unity/download/archive
     
unityunity