I am following a tutorial about how to make a fps controller in Godot. The language that is used in the tutorial is GDScript but I prefer to use C#. I am trying my best to translate GDScript to C# but sometimes I just cannot figure out what to do even with a lot of research. The error I have encountered right now is this: Cannot modify the return value of ‘Node3D.Transform’ because it is not a variable [CS1612]. The lines of code that generates this error are:
these two lines of code from this function.
CAMERA_CONTROLLER is just a Camera3D.
I have researched how I can solve this for hours and tried quiet a lot of different ways to solve this. But I was unable to sadly. Any help is appreciated.
Thank you for your reply and I have taken a look at the documentation about this error. Sadly though my C# knowledge was not sufficient for this. I still am not really aware of what I am supposed to do.
Transform3D newTransform = CAMERA_CONTROLLER.Transform; // Copy the value
newTransform.Basis = Basis.FromEuler(mouse_rotation); // Modify the value
CAMERA_CONTROLLER.Transform = newTransform; // Rewrite the value
In my understanding of structs, when we write CAMERA_CONTROLLER.Transform in script, this does not mean the exact object which the variable CAMERA_CONTROLLER.Transform has. It is the copy of the object which CAMERA_CONTROLLER.Transform has.
Again thanks for the reply. Hmmm. Now I get a null reference exception error at the first line of code you gave me. I have made the same thing for the rotation as well and got the same error. If you want anymore details please ask.
Hmm, I think nullable object in the line is CAMERA_CONTROLLER only, because Transform is struct (I believe it is not nullable). Is it assigned properly?
Sir, I am really sorry for wasting your time with my ignorance.
I had declared the CAMERA_CONTROLLER as an export variable so I had to just assign it the editor. As someone coming from Unity I am ashamed about how I was so blind about this.
My goal was to be able to look around with the mouse. I still does not work properly but I get no errors now at least.
As I said I am really sorry about wasting your time. And I do not want to waste it any further. But if you want to help further I would appreciate it.