Hey everyone,
first of all, let me tell you that this is just a hobby project of mine. I continue to develop it in my free-time.
I also started using C2 like two week ago, so my skills aren't that advanced and there is probably much much more to improve in my project than just that what my question concerns.
But I don't expect you to correct all my nooby mistakes, should you feel obliged to do so though, I'd appreciate a PM.
Let's get to my main concern, shall we.
My project is a kind of weapon sandbox (.capx download further down), also serving as a playground for new addons and to advance my knowledge of C2.
The feature which is the most important for my issue is the following:
You can shoot grenades (bullet behaviour) which explode on colliding with the ground. You have the option to enable "Shell mortar". This childishly named option causes the grenade to spawn two small grenades to spawn when the initial grenade is at the height maximum of its flying arc.
For checking whether the grenade is at its maximum, I created a function which compares the grenades current angle with its angle from the previous tick (stored in an instance variable). If the current angle is lower than the last known, the function returns a 1 and saves the grenades' UID in a global variable.
This UID is then used to indentify the grenade which should spawn the two smaller ones.
So far, so good. This works fine.
As long as you don't fire multiple shells in a short time. Because when you do that, just some grenades trigger and spawn small grenades.
This is my actual problem.
I don't know what causes this issue, maybe the UID being stored in a global variable, but I see no other way of doing it.
Anybody who is willing to read through some of my events can PM me or just reply here.
Any help is appreciated.
I now removed everything distracting from the project and removed any plugins used. I hope this won't cause any errors anymore for you.
Since this is my first post, I apologize for anything being unclear, I will provide any info needed.
Thanks so much in advance!
Download .capx: (important sections are bookmarked)
dropbox.com/s/3dpfzphgqnx6efv/GrenadeLauncherForumVersion.capx
(Some additional info:
I also have an option called bounce which causes a grenade to bounce once after colliding with the floor and exploding after the second impact.
I noticed that if I enable both bounce and mortar rain options, some of the grenades which don't trigger, do trigger after having bounced and reaching their maximum height in the second arc.)
[EDIT: As I said, I'm still learning, so there is most likely much to improve. Just try to ignore this. :)]