You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I was trying to port this code to C#, this is how it looks (It's really 1:1 conversion)
usingGodot;usingSystem;publicpartialclassSmoothCam:Camera3D{[Export]publicdoubletranslate_speed=0.95;[Export]publicdoublerotate_speed=0.95;[Export]publicdoublefov_speed=0.95;[Export]publicdoublenear_far_speed=0.95;[Export]publicNode3Dtarget;publicoverridevoid_Ready(){}// Called every frame. 'delta' is the elapsed time since the previous frame.publicoverridevoid_Process(doubledelta){if(target==null)return;vartranslate_factor=1-Mathf.Pow(1-translate_speed,delta*3.45233);varrotate_factor=1-Mathf.Pow(1-rotate_speed,delta*3.45233);vartarget_xform=target.GlobalTransform;varlocal_transform_only_origin=newTransform3D(new(),GlobalTransform.Origin);varlocal_transfrom_only_basis=newTransform3D(GlobalTransform.Basis,new());local_transform_only_origin=local_transform_only_origin.InterpolateWith(target_xform,(float)translate_factor);local_transfrom_only_basis=local_transfrom_only_basis.InterpolateWith(target_xform,(float)rotate_factor);GlobalTransform=new(local_transfrom_only_basis.Basis,local_transform_only_origin.Origin);if(targetisCamera3Dcamera){if(camera.Projection==Projection){varnear_far_factor=1-Mathf.Pow(1-near_far_speed,delta*3.45233);varfov_factor=1-Mathf.Pow(1-fov_speed,delta*3.45233);varnew_near=(float)Mathf.Lerp(Near,camera.Near,near_far_factor);varnew_far=(float)Mathf.Lerp(Far,camera.Far,near_far_factor);if(camera.Projection==ProjectionType.Orthogonal){varnew_size=(float)Mathf.Lerp(Size,camera.Size,fov_factor);SetOrthogonal(new_size,new_near,new_far);}else{varnew_fov=(float)Mathf.Lerp(Fov,camera.Fov,fov_factor);SetPerspective(new_fov,new_near,new_far);}}}}}
But I always get an exception at the InterpolateWith at local_transform_only_origin; Quaternion is not normalized.
This is really confusing because, as said, it's been ported 1:1 to C# so there should be any problems, right?
I'm using Godot 4.0.3.stable.mono
The text was updated successfully, but these errors were encountered:
Your c# isn’t typed. I suspect you are not converting basis to quaternion using the right methodOn Jun 24, 2023, at 3:03 AM, Night The Fox ***@***.***> wrote:
Basis and Quaternions need special treatment and I don't know your types.
There are no types defined by me, everything is from Godot and what do you mean with "special treatment"? Why does C# need it, but GDScript not?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
So I was trying to port this code to C#, this is how it looks (It's really 1:1 conversion)
But I always get an exception at the
InterpolateWith
atlocal_transform_only_origin
; Quaternion is not normalized.This is really confusing because, as said, it's been ported 1:1 to C# so there should be any problems, right?
I'm using Godot 4.0.3.stable.mono
The text was updated successfully, but these errors were encountered: