Having an issue with separate instance variables.

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hey all!

    I'm hoping someone can help me with an issue I'm having. I'll try to describe my issue, and I'll post a .capx below.

    I'm working on a gamejam, and my game is acting kind of buggy, and I'm hoping someone can help me pinpoint the problem. I've been at it for two days, and I'm going nuts trying to get this to work the way I want to.

    The player is a were-banana, and can exist in two states: transformed or not transformed. The player changes between states by pressing Space.

    Basically, when the player gets close enough to a strawberry, it turns to face the banana, and the strawberry's field of view is supposed to be mirrored when the strawberry is mirrored, and not mirrored when the strawberry is not mirrored.

    The issue that's happening is that if the player walks across the screen in an untransformed state all the way to the right, and then comes back to the left, the third strawberry's field of view gets wonky, and won't mirror properly.

    I think it has something to do with the "serial" instance values between the Strawberry and StrawberrySight objects. Originally I had them set as numbers, and if the strawberries weren't killed in order of smallest to greatest value, their field of views would get skewed and not act the way I wanted them to. I tried to change them to strings, but I'm pretty sure they still have a certain "least to greatest" value, because they're still wonky, and occasionally don't mirror properly.

    Also, if you beckon a strawberry so it sees it's fallen friend, it will run to the fallen friend and cry. If you leave the crying strawberry and walk past the remaining strawberries, their fields of view don't mirror when they should either.

    Anyhow, this: https://www.dropbox.com/s/ctlurxsr0cwav37/Were-Banana!.capx.backup1 is the .capx for where I'm at now. If anyone can help me figure this out, I'd greatly appreciate it.

    I have my events organized in groups and labels above what the functions are supposed to do to the best of my ability. This is my second game, so I'm sorry if it's a little messy.

    The controls for the banana are:

    Arrow keys to move

    D while untransformed to wave at a strawberry (makes them either follow or stop following you if they see you and you are facing them)

    D while transformed to attack with your hand (should kill the strawberry)

    D while transformed and jumping to kick (also kills strawberry, but I have to make the hitbox easier)

    The banana can only jump while transformed, and will move faster while transformed as well.

    Thank you so much!!

    • Scott
  • Replace event 32 with 'For each' Strawberry. Whenever you get weird results from multiple instances, it tends to be an implicit picking issue. You can only get away without a 'For each' if ONLY the same object is referenced in the event/action. The second you add any other object (StrawberrySight in this case), you have to explicitly cycle though each instance. The issue here (I think) is that Strawberry 3 & 4's line of sight overlap, so there is confusion on which Strawberry/StrawberrySight are picked to act on.

    My general rule of thumb (as C2's picking can be confusing), is to always use a 'For each' to cycle through instances, and then if I care, try toggling them off to see if they are needed when I'm happy with the results.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Replace event 32 with 'For each' Strawberry. Whenever you get weird results from multiple instances, it tends to be an implicit picking issue. You can only get away without a 'For each' if ONLY the same object is referenced in the event/action. The second you add any other object (StrawberrySight in this case), you have to explicitly cycle though each instance. The issue here (I think) is that Strawberry 3 & 4's line of sight overlap, so there is confusion on which Strawberry/StrawberrySight are picked to act on.

    My general rule of thumb (as C2's picking can be confusing), is to always use a 'For each' to cycle through instances, and then if I care, try toggling them off to see if they are needed when I'm happy with the results.

    Oh my god, you're a wizard!!

    Thank you so much!! I had no idea that was even a condition!!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)