Anyone else have this issue where trail renderers sometime show and sometimes don’t? I put in a few debug statements and closely looked at the hierarchy and it seems that sometimes the objects don’t get instantiated at all. Take a look at the screen shot below.
In the code below the two debug lines get called every time but sometimes no object gets created. And if no object gets created then no arrow, no trail render, no damage, etc. Sometimes I just wait long enough while attacking one enemy and they start firing and sometimes I have to move around in the scene (still in play mode) and they start firing.
What could be the cause of Instantiate just not running? The best thing I could find while Googling is that sometimes the Instantiate operation “lags” the game engine. Maybe the frame that the Instantiate ran on ended up being a frame that was dropped? But it clearly dropped more than the visual pixel rendering. It seems to happen more when my system is stressed in terms of RAM utilization (I have 8GB - brand new system is on order).
Anyone else experience this and have a better idea of what’s going on? I’m at a loss and the above is my best hypothesis.
public void LaunchProjectile(Transform rightHand, Transform leftHand, Health target)
{
Debug.Log("Pre instantiate");
Projectile projectileInstance = Instantiate(
projectile,
GetTransform(rightHand, leftHand).position,
Quaternion.identity);
Debug.Log("Post instantiate");
projectileInstance.SetTarget(target, weaponDamage);
}
Take a look at the hierarchy - no arrow game object! I hit pause just after it was fired. Both debug statements ran and showed up in the console.