Hello, I’m having problems with trails, they are bent and sometimes show weird artifacts too:
I’m using Unity 2017.2.1p1 and I can’t upgrade to the newest version because it bugs my UI.
Is this a bug or is it an error in my code? I don’t think I’ve ever noticed this bug in older versions of Unity, but I might be mistaken.
This is the code of the skill used in the screenshot:
public void Skill2A()
{
float projNum = 5;
float multishotAngle = 6f;
Vector2 projPos = new Vector2(transform.position.x, transform.position.y + (transform.Find("Hitbox").GetComponent<BoxCollider2D>().size.y / 2));
Vector2 targetPos = _player.skillPos;
Vector2 projDir = (targetPos - projPos).normalized;
float dirAngle = Vector2.Angle(Vector2.right, projDir);
float distY = (projPos.y - targetPos.y);
if (distY > 0)
dirAngle = 360 - dirAngle;
PlayerDmgInfo dmgInfo = _statsManager.CalculateDamageToGive(_skill2ADmg, PlayerDmgInfo.DmgType.physical, 2);
dirAngle = dirAngle - ((projNum - 1) / 2 * multishotAngle);
for (int i = 0; i < projNum; i++)
{
bool canPierce = false;
if (Random.Range(1, 100 + 1) <= piercingAtkChance)
canPierce = true;
Vector2 newProjDir = (Quaternion.AngleAxis(dirAngle + multishotAngle * i, Vector3.forward) * Vector3.right).normalized;
Vector2 newProjPos = projPos + (newProjDir * 0.5f);
GameObject newProj = Instantiate(_multishotArrow, newProjPos, Quaternion.identity);
newProj.transform.rotation = Quaternion.Euler(0, 0, dirAngle + multishotAngle * i);
newProj.GetComponent<RangerMultishotArrow>().InitializeProjectile(newProjDir, dmgInfo, ccInfo, canPierce, _statsManager);
newProj.GetComponent<RangerMultishotArrow>().InitializeAudio(_audioManager, _multishotHit);
}
}
Basically I spawn an arrow, than rotate it and initialize it by giving it the direction it needs to follow. Then I move the arrow with this “transform.Translate(_direction * _speed * Time.fixedDeltaTime, Space.World);” inside the FixedUpdate() function.
Thanks for your help.