Hi,
we’re making a multiplayer game with the first version of UFPS and everything was working fine, but we’ve decided to switch from Mono to Il2cpp and problems have shown up.
From this thread: https://legacy.opsive.com/assets/UFPS/forum/index.php?p=/discussion/1685/how-to-fix-executionengineexception-attempting-to-jit-compile-error-on-non-desktop-platforms it seems the problem are those Empty methods in the vp_Value class. The class looks like this:
public class vp_Value<V> : vp_Event
{
#if !ENABLE_IL2CPP
public static T Empty<T>() { return default(T); }
public static void Empty<T>(T value) { }
#endif
public delegate T Getter<T>();
public delegate void Setter<T>(T o);
public Getter<V> Get;
public Setter<V> Set;
... //rest of the code
}
Whenever I want to access some value in build via Get or Set defined in vp_PlayerHandler I get the NullReferenceException: Object Reference not set to an instance of an object. But only on Remote Players and AI.
Example:
I instantiate my prefab of AI player and during the Awake call the InitMaxSpeeds method in the vp_BodyAnimator class is called:
protected virtual void InitMaxSpeeds()
{
Debug.Log("Player.IsLocal " + Player.IsLocal);
Debug.Log("GET: " + Player.IsLocal.Get());
if(Player.IsLocal.Get())
{
...//rest of the code
}
}
where IsLocal is defined as: public vp_Value IsLocal.
The line with the if statement has always thrown NullRefException. So I put those two debugs in there. The output is:
Player.IsLocal vp_Value`1[System.Boolean] NullReferenceException: Object reference not set to an instance of an object.
It’s not just this case where it is happening but since it’s always the variable of vp_Value I guess it’s the same problem in all cases.
I’ve tried to go along this: https://docs.unity3d.com/Manual/ScriptingRestrictions.html to somehow make the Empty methods available in Il2cpp (and not use the #if !ENABLE_IL2CPP directive in vp_Value class), but I have absolutely no idea how to use it and this error shows up:
ExecutionEngineException: Attempting to call method ‘vp_Value`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]::Empty<System.Boolean>’ for which no ahead of time (AOT) code was generated.
Also, the thread I’ve mentioned earlier says to create placeholder methods for events that have no callback when the Empty methods are not in use, but I’m stuck and clueless of how to do it in my case for vp_Value class and its Get and Set method.
So I would really appreciate some help in this matter.
The official forum for this asset is in read-only mode and the newer version, as far as I am aware, is made by a different group, so that’s why I’m putting it here.
Thanks!