How do I Recognise All Objects That Can "Catch Fire"

Get help using Construct 2

Post » Mon May 01, 2017 4:41 am

I understand. Thanks so much for your patience and help!
B
15
S
4
G
2
Posts: 43
Reputation: 2,034

Post » Mon May 01, 2017 5:03 am

Anytime dude :D

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Mon May 01, 2017 6:55 am

Hello again,

I'm actually having a lot of trouble trying to get this to work properly with what I suggested in Solution 2. For every Apple Tree, I have an instance variable called Object_UID and every tick I set it to self.UID, so it's UID is in an instance variable. For the FireCloak I also have an Object_UID that I manually set for each instance to match the AppleTree's UID.

Basically, here is my event:

Event Conditions:
FireCloak is overlapping Fire
FireCloak is Burning
FireCloak Health = 0

Subevent Conditions:
AppleTree Object_UID = FireCloak.Object_UID

Subevent Actions:
AppleTree Set animation to Burnt (play from beginning)

It works on the first AppleTree that is set on fire, but it doesn't work on the second one.

And then it's Eradic, sometimes it works and sometimes it doesn't, but there is generally always one of the AppleTrees that does not change it's animation to "burnt" when it should. I haven't changed the code around.

I have tried to Pick by Comparison the apple tree's UID and the FireCloak's Object_UID instance variable. Same thing happens. It does not always work.

I assume I am doing something wrong here, but I'm out of options.

Edit: By the way, I have checked to make sure that the Object_UID instance variable on every FireCloak instance matches the correct AppleTree's UID.
B
15
S
4
G
2
Posts: 43
Reputation: 2,034

Post » Mon May 01, 2017 2:09 pm

Yeah, picking instance ID's can be tricky.

I always create my own numbering system for every object on creation. I have things like "entCount" or "DudeCount" which I start from 0 and just add 1 each time a new thing is spawned that I need to track. This way, I have sequential numbers that are more easily (for me) tracked.

Comparing the UID or custom ID is crucial, but you should have that all nested in a loop "for each appletree" or "for each fire", depending which way your comparison is set up. This will make sure it compares every tree independently. You can even check them in order of UID if you want, if "age" of a tree is important.

Using instances can be tricky, especially when you have multiple instances of multiple objects all trying to interact with each other. You'll get the hang of it after experimenting around. :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Mon May 01, 2017 9:15 pm

Hey Sol, I did try a For Each loop for the Apple tree, as a Sub-event so like I did try this:

Event Conditions:
FireCloak is overlapping Fire
FireCloak is Burning
FireCloak Health = 0

Subevent Conditions:
For each AppleTree
AppleTree Object_UID = FireCloak.Object_UID

Subevent Actions:
AppleTree Set animation to Burnt (play from beginning)

It still seems to do the same thing, so I removed the For Each loop because it didn't seem to make a difference.

What I am seeing in my in-game bug mode details is that the numbers are all there in the instance variables to match the "Object_UID" instance variable on both the AppleTree and the FireCloak objects, but for some reason, it is not always working.

All I essentially need now is for construct 2 to recognise these two objects properly so it works each time. I'm not 100% sure if I'm doing this right. At the moment, I have 4 AppleTrees, and I just tested it again, and it worked for the first two AppleTrees correctly, the third one didn't work, but when the fourth one lost all Health, it changed both the third and the fourth AppleTree to Burnt. I do not understand. Another test shows that the fire started backwards (since fires can start at random flammable objects), this time, the second and third AppleTree would not change. But changed again after it was late for a couple more minutes. It's eradic.

The frustrating thing is I often compare instance variables with quite a few different objects in the game for different things, and a lot of those things are objects I do not know are going to happen, so the game creates them and then assigns them the appropriate numbers to be recognised. I never have a problem doing it that way, and i don't normally have an issue with doing stuff like this. For some reason, I'm just having problems with this. I could try smaller numbers and see what happens, but I definitely think I am missing something here and it's bigger than that.

It's times like this, I feel like I need to re-study the way construct 2 picks objects and instance variables. I actually feel like I may have to specifically program every single flammable object individually, but surely there is a better way to do it, hence why I thought my FireCloak object idea was the best way.
B
15
S
4
G
2
Posts: 43
Reputation: 2,034

Post » Tue May 02, 2017 2:57 am

If your project is simple, feel free to drop me a link and I can take a look at it.

If you can reproduce the issue in a fresh capx showing only the parts of the problem (like, if your project is HUGE or you don't want to risk leaking it) then that will also work.

It sounds definitely like a picking problem... it sounds like perhaps the catching on fire part is working, but when you're changing states of the trees to "burnt" it's picking the wrong target ID, or something.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Tue May 02, 2017 6:19 am

I've managed to extract only the relevant part of my project to show you what I mean.

I've tested it to see if it still happens in this project, and yes it does happen, but it may not happen all the time, so you may have to run it several times to see what I mean.

Feel free to just reduce the Health on the FireCloak object in the debug inspector once you notice the flames on the FireCloak. You'll see what I mean.

https://www.dropbox.com/pri/get/Testing ... u2X157e6nw

I've left notes on the eventsheet, but please let me know if you need anything else. This problem has really lost me. :P
B
15
S
4
G
2
Posts: 43
Reputation: 2,034

Post » Tue May 02, 2017 8:30 am

Your dropbox link appears to be private or something. Did you create a share link or a direct link? Dropbox has changed now, and it has confused a lot of people.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Tue May 02, 2017 10:07 am

Sorry about that. Here's the proper one:

https://www.dropbox.com/s/kd4x0frtc6nzn ... .capx?dl=0
B
15
S
4
G
2
Posts: 43
Reputation: 2,034

Post » Tue May 02, 2017 10:14 am

AARRGGHHHHH lol... it's in a newer version of C2. Must be time to update my software and pray nothing breaks in my project xD

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests