Projectiles dont give damage

Hello, I did the challenges than watch the video but couldn’t find the difference, i looked for other topics but their solutions didn’t work for me. my projectiles dont give damage to lizards also i got an error but i couldn’t figure what it means.





5

Hi Sarp,

Welcome to our community! :slight_smile:

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.

Also make sure that at least one involved Rigidbody2D is “dynamic” because “kinematic” Rigidbody2D components can collide with “dynamic” only.

Hope this helps :slight_smile:


See also;

Thanks for your reply, today i am not getting an error massage but my projectiles still not giving any damages,i deleted the scripts than copied from lecture project changes and i also tried making one of them Dynamic but problem still continues :frowning:

Are all error messages gone?

Could you please share a screenshot of a Lizard game object? Also add a Debug.Log to your collision and trigger methods to see if a collision happens.

Added Debug.Log and no collision happens.


Both Rigidbody2D components are “kinematic”. One of them needs to be set to dynamic. Set the Lizard to “dynamic”.

I changed it to dynamic, but still no collision :frowning:

Leave it this way.

Now remove the Edge Collider 2D and replace it with a BoxCollider2D. There is a chance that the projectile, if it’s moving too fast, is missing the edge. A “solid” collider might work better. Test that, please.

If that didn’t improve anything, add Debug.Logs to your collision and/or trigger methods to see whether the messages appear in your console.

Yes, its working now. It seems edge collider is not a good choice :slight_smile: Thanks for your help, have a nice day.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms