Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Dostoi |
Question:
This is possible in gdscript (godot 4.0beta3):
var exampleBasis = get_viewport().get_camera_3d().transform.basis
var expectedResult = (cameraBasis * Vector3(0.4, -0.3, -0.9))
But this won’t compile in C# (godot 3.5 mono):
var exampleBasis = GetViewport().GetCamera().Transform.basis;
var expectedResult = (exampleBasis * new Vector3(0.4f, -0.3f, -0.9f));
To better understand C#, could someone explain me why it is not possible?
Also, what could be a workaround to get a vector3 as an “expectedResult” from multiplying a basis and a vector3 in C#?
Intention:
The meaning of this code would be to get the basis of the camera to establish the forward direction of a moving character. An other vector2 variable would be getting input vectors and the x and y value resulting would then be used in the respective x and z fields of the “new Vector3” that would have been multiplied by the basis. Thus, returning a Vector3 that could be used to calculate the forward, left and right direction of a character relative to the camera.
Thank you for reading.