Hi, I found myself struggling a lot to understand what is really happening with the following:
Let’s say I have a spawner and some player abilities.
All the abilities are working fine, when I use them, a lambda callback is called with the active effect like this:
private Action<PlayerHandler> HealPlayerAction()
{
return (p) => p.HealPlayer((int)value);
}
Everything fine here.
But the following is happening:
When I call an ability to force enemies to the ground, just changing a boolean, it all works nicely on Unity pressing play, but when I compile and upload it to Google Play to test it, the behaviour is totally different:
class AbilitiesHandler
{
...
private Action<PlayerHandler> NoFlyingEnemiesAction()
{
//I don't use the p parameter but it should remain there because of the Action expected
return (p) => EnemySpawnerManager.Instance.ForceAllEnemiesOnGround(true);
}
...
}
class EnemySpawnerManager (is a singleton)
{
...
public void ForceAllEnemiesOnGround(bool enabled)
{
_forceGround = enabled;
}
...
public void Spawn()
{
...
if (!_forceGround)
{
enemy.Flying = newEnemy.Flying;
} else
{
enemy.Flying = false;
}
...
}
}
So, I placed a lot of Logs, and everything is being called right, the ability when pressed… the method on EnemySpawner… BUT, the change on _forceGround is never saw in the Spawn() method, that everytime that checks _forceGround is false.
I can’t debug the code with breakpoints on android because of authentication, and I would really like to understand what might be happening there… are the lambdas working differently on Android? Is the combination between a Singleton and the lambda? First time I face a problem like that, is something so simple as a bool change.
Thanks for the help!