Assets/Scripts/Control/Respawner.cs(70,37): error CS1061: ‘ICinemachineCamera’ does not contain a definition for ‘OnTargetObjectWarped’ and no accessible extension method ‘OnTargetObjectWarped’ accepting a first argument of type ‘ICinemachineCamera’ could be found (are you missing a using directive or an assembly reference?)
I have this error in my project. What it is causing to this error?
Thank you
It’s hard to really understand what exactly is going on because all I see is the error however the error message indicates that there is a problem with the code in the “Respawner.cs” script file on line 70, column 37. Specifically, it seems that the code is trying to access a method called “OnTargetObjectWarped” on an object of type “ICinemachineCamera”, but this method does not exist in that type.
There could be several reasons for this error, but some possible causes are:
The “ICinemachineCamera” interface may not have the “OnTargetObjectWarped” method defined in it. In this case, you need to either add the method to the interface or find a different way to achieve the desired functionality.
The “ICinemachineCamera” type may not have been properly imported or referenced in the script file. You can try adding a “using” directive at the top of the script file to import the required namespace or checking that the correct assembly reference is added.
It’s also possible that the version of the “ICinemachineCamera” type being used is different from the one that contains the “OnTargetObjectWarped” method. In this case, you may need to update the version of the type being used or modify the code to work with the version you have.
You can review the code in the “Respawner.cs” file and try to identify the issue based on the above possibilities.
Hope this helps!
In Respawner.cs ,
ICinemachineCamera activeVirtualCamera = FindObjectOfType<CinemachineBrain>().ActiveVirtualCamera;
This line giving the error.
I changed the related scripts with Respawn.cs. Now, they are same with the codes are in the class. But, I still taking the same error in this line . I guess, i missing something on the scene. I think, this is not related with the code. What can cause that in the hierarchy ?
Interesting, It’s possible that the error is related to the hierarchy of your scene, rather than the code itself. The error message suggests that the “OnTargetObjectWarped” method is not found on the “ICinemachineCamera” interface, which indicates that the problem may be related to a missing or incorrect reference to the Cinemachine package or component.
Here are some possible solutions you can try:
Make sure that the Cinemachine package is properly installed in your project. You can check this by opening the Package Manager window in Unity and verifying that the Cinemachine package is installed and up to date.
Verify that the “ICinemachineCamera” interface is properly defined in the Cinemachine package. You can check this by opening the source code for the package and verifying that the interface contains the “OnTargetObjectWarped” method.
Check that the Cinemachine virtual camera is properly set up in your scene. Make sure that it is added as a component to a game object in the scene, and that the game object is active and enabled.
Verify that the Cinemachine virtual camera is set up to follow a valid target object. Make sure that the target object is active and enabled, and that it has a valid transform component.
Double-check the spelling and capitalization of the “OnTargetObjectWarped” method name. Make sure that it matches exactly with the method name in the Cinemachine package.
My hope is that one of these works, hope this helps!
Paste in your complete Respawn.cs class, and we’ll take a closer look.
- Forum User Guides : How to apply code formatting within your post
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.