[SOLVED] Need help with my project, very specific though.

Discussion and feedback on Construct 2

Post » Mon Sep 26, 2016 6:15 pm

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)
https://www.dropbox.com/s/3dpfzphgqnx6efv/GrenadeLauncherForumVersion.capx?dl=1

(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. :)]
Last edited by randomly on Wed Sep 28, 2016 11:41 am, edited 2 times in total.
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Tue Sep 27, 2016 2:14 pm

You probably wonder why no one is reacting. Well, there are two reason, i think.

1/ The linked file is a backup file. Can be made a capx by just renaming it, but is it really the last version of your project ?

2/ It leans on a bunch of plugins. It is a bit rude to expect me to dive in the forums, search & find all those plugins and install them. You should at least link to each plugin. Better, and nicer, is to isolate the problem in a new capx. You will get more and better responses.

Nevertheless, when i have time later, i will make you an example. Starting from scratch. Plz, show me at least a picture of your layout. Is it top view ? Is it side view ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Sep 27, 2016 3:44 pm

Thanks for your response and thanks for clarifying what I did wrong.
Sorry for the errors I made.

I removed everything distracting from the project and deleted all used plugins from the project.
I then exported the capx and included the new link in the edited post.

The last time when the link redirected to a backup file, that was a Dropbox issue since C2 automatically creates backups, even for .capx.

Thanks again for taking the time to help me solve my problem.

(By the way, English is not my first language as you might notice)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091

Post » Tue Sep 27, 2016 5:58 pm

I haven't seen your capx, but it sounds like simplest option would be rather storing uid as global, set a boolean or similar on the instance. Then you can identify all projectiles that meet the criteria by their instance variables. At the moment it sounds like subsequent grenades overwrite the uid of their predecessors, which are then lost.
B
18
S
12
G
1
Posts: 45
Reputation: 2,340

Post » Tue Sep 27, 2016 8:53 pm

Wrong? Did't want you to spell a lesson. Just wanted you to know why you had no responds, in a forum that is very alive.
My English is way away from my moms language, an it is all self taught, it is for sure worse then yours.
Never say sorry, you adapted to the best of your abilities, (as i try), they dont. But in here, i never seen one complain about bad English, lucky for me.

For only using C2 for weeks, it is pretty nice. Just a bit to much 'If-Then'. I could not do all that in two weeks. And i sure have this particles still not under control as you do.

Now, i think this is what you want to do :
https://www.dropbox.com/s/xnjag04aisd0q ... .capx?dl=0

I wrote comments in the capx, plz read them.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Sep 28, 2016 11:36 am

Thanks so much for taking the time and creating this (beautifully named) project for me.
My first ever time I ask for help in this forum and I immediately get such a friendly response.
This community is awesome.

I read through the .capx you provided. I fixed my project now by changing the Angle check to the one that you proposed (Pick shell where int(Shell.Bullet.AngleOfMotion) > 0) which also allowed me to remove the now unnessecary UID instance variable.
I also removed the CheckShellMovement function which isn't needed now anymore because I can just pick the needed shells.

Thanks so much for taking the time to take care of my issue. If you have a problem at some point (maybe with particles), I will do my best do help you too. :)

Also, thanks to @DankP3 for proposing the global variable to be changed to an instance variable. Would probably have fixed my problem too.
Now I have a compact and working new version of my project, thanks everyone.

(Btw, @99Instances2Go, you said there are too many "If->Then" in my project? Could you tell me how I can improve this? Not in this thread, but via PM maybe? I don't have gained the power of writing PM's yet though. Maybe you could send me one quickly? Just if you have the time of course.)
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
B
27
S
11
G
8
Posts: 528
Reputation: 7,091


Return to Construct 2 General

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests