Last created object in a loop is not getting set up correctly

0 favourites
  • 2 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • hello,

    I have this block of code. it's a loop on start of layout for a platform to generate all of the plants on it. the plants then are added as children to the platform, and they have their height set by the platform. for some reason, the last plant a platform generates does not inherit the height (certain platforms always have the problem, but others do not), and has height 0. this happens even if I set the default height to be 1, so I'm assuming it's returning 0, but I have no idea why it would--you can see in the comment I was having a similar problem referring to another variable on the same object. is it somehow unpicking platforms? but why would it be set as a child correctly then...? and why would it work for n plants but fail on the last one?

    the platform's plantHeight is 3 even after it's finished loading. t1h3w2 is the default animation for this plant. it also happens with other object types which are groundPlants family as well. if I replace the variable with a number it works fine. I can just set everything at the end of the loop by picking all of the platforms's children, but I think this is the same problem that's making me have to use the 20 value instead of referring to a variable on the object which I would greatly prefer, so I thought I should ask anyway.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • augh!! nevermind, I got it. there was a platform that wasn't making its own plants so it just kept grabbing the most recently created plant and repeatedly setting its values. not sure why it was happening for multiple platforms, but I fixed it anyway.

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