jongallant / Unity-Bullet-Hell

An extremely efficient projectile generator for unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flickering bullet

mlanci opened this issue · comments

I'm having an issue that I haven't narrowed down completely..

But it seems like when a bullet hits an edge, maybe the player collider or a tilemap corner collider.. the bullets kind of freeze and just flicker over and over again until I go out of frame and it resets.

I've just gotten back into developing again after a break and got some more info on this. In your protected override void UpdateProjectile function - theres a comment block that says "Put whatever hit code you want here such as damage events".

So under the if (result > 0) I tried to say when there was a collider with a specific name was hit, do something.

if (result > 0) { // Put whatever hit code you want here such as damage events RaycastHit2D hit = Physics2D.Raycast(node.Item.Position, deltaPosition); Debug.Log(hit); if (hit.collider.name == "PlayerSprite") { hit.collider.gameObject.transform.parent.gameObject.GetComponent<Player>().TakeDamage(5); } ...

This works for the most part - ill see my console printing UnityEngine.RaycastHit2D when a bullet collides with my player but sometimes the bullet will land and give me the following error
"NullReferenceException: Object reference not set to an instance of an object
BulletHell.ProjectileEmitterAdvanced.UpdateProjectile (BulletHell.Pool`1+Node[BulletHell.ProjectileData]& node, System.Single tick) (at Assets/Unity-Bullet-Hell/Scripts/Emitters/ProjectileEmitterAdvanced.cs:348)"

The bullets freeze and stop moving and flick until I either rotate my player (which has a circle collider 2D) or run my player out of scene of the bullets and they seem to disappear and the enemy will begin firing again.