[c#] GameplayCamera class broken methods

Some static methods of the GameplayCamera dont work and throws an error.

Example method that is not working:
GameplayCamera.Direction

World.GetCrossHairCoordinates (is using GameplayCamera.GetOffsetPosition)

For a good bug report you should probably include:

  1. Client (production/canary)
    canary, server:4355
  2. What you expected to happen
    That the methods works without any errors.
  3. What actually happens
    The following error occurs:
Failed to instantiate instance of script Client.Client: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
at System.Buffer.memcpy4 (System.Byte* dest, System.Byte* src, System.Int32 size) [0x00002] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.Buffer.Memcpy (System.Byte* dest, System.Byte* src, System.Int32 size) [0x00073] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.String.memcpy (System.Byte* dest, System.Byte* src, System.Int32 size) [0x00000] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at (wrapper unknown) CitizenFX.Core.Matrix:PtrToStructure (intptr,object)
at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal:PtrToStructure (intptr,System.Type)
at System.Runtime.InteropServices.Marshal.PtrToStructure[T] (System.IntPtr ptr) [0x00000] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at CitizenFX.Core.Native.MemoryAccess.ReadMatrix (System.IntPtr pointer) [0x00000] in C:\gl\builds\master\fivem\code\client\clrcore\Native.cs:161 
at CitizenFX.Core.GameplayCamera.get_Matrix () [0x00000] in C:\gl\builds\master\fivem\code\client\clrcore\External\Camera.cs:544 
at CitizenFX.Core.GameplayCamera.GetOffsetPosition (CitizenFX.Core.Vector3 offset) [0x00000] in C:\gl\builds\master\fivem\code\client\clrcore\External\Camera.cs:553 
at CitizenFX.Core.World.GetCrosshairCoordinates (CitizenFX.Core.Entity ignoreEntity) [0x00000] in C:\gl\builds\master\fivem\code\client\clrcore\External\World.cs:1658 
at Client.Client..ctor () [0x00008] in C:\Projects\Fivem\tbd\resources\ccore\src\Client\Client.cs:39 
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <74fbbe963b7e417b8d715b858c5c584f>:0 
 --- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at System.Activator.CreateInstance (System.Type type) [0x00000] in <74fbbe963b7e417b8d715b858c5c584f>:0 
at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.String assemblyFile, System.Byte[] assemblyData, System.Byte[] symbolData) [0x000c4] in C:\gl\builds\master\fivem\code\client\clrcore\InternalManager.cs:150 
  1. Category of bug (eg. client, server, weapons, peds, native)
    C#,Client
  2. Reproducible steps, preferably with example script(s)
    add the 1 of the following code somewhere
RaycastResult raycast = World.GetCrosshairCoordinates();
//or
Debug.WriteLine(GameplayCamera.Direction);

And the error will occur.

1 Like