When learning Unity, I have been going through the 2D Beginner: Adventure Game tutorial. Everything has been going well, except when it comes to the physics and healing + dealing damage. Whenever the avatar interacts with damageable, it simply just moves through it like it is nothing, as well as the simple metal cube. I am not sure if the health items work, since the player cannot take damage. For an error a while back, I accidentally changed the healing script when moving it with the damageable. Even though I fixed it and all, it still does not work, and I am not fully sure how to fix it.
In the tutorial, I have just completed Heads-up UI Display, in case you’re wondering where I am at.
For my scripts, in terms of how they are written, they are in their proper form, and no mistake in the typing. This is more with the physics themselves.
All of the collision and trigger functions in Unity3D have extremely well-defined prerequisites for generating collision callbacks for you to compute the damage.
Pay close attention to the provided documentation because missing even one prerequisite generally means it won’t work.
If you have it all set up and it isn’t working, that just means you wrote a bug… and that means… time to start debugging!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...);
statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
It is not useful to assert such a thing because: with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.