How do I spawn objects with different values of inst. vars.

0 favourites
  • 8 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Hi folks,

    I have a spawner that spawn objects every

    random(4,8)[/code:167togxe] second.
    
    After spawning there is running a "rise" animation. After rising I set animation to "walk". But it seems that these setting isn't individual.    
    
    [code:167togxe]Sprite -> On animation "Rise" finished -> SpriteBox - > Set rised to 1[/code:167togxe].
    [code:167togxe]System -> SpriteBox.rised = 1 -> Sprite -> Set animation to "Walk" (play from beginning)[/code:167togxe]
    
    But after that setting "rise" did not appear anymore. 
    
    Someone got a hint or a tutorial abut spawning objects with random behavior/instance variables?
    
    Thank in advance!
  • got a .capx we can look at? I feel like this should work, unless I'm missing something..

  • wait.. spritebox and sprite are two different things, eh?

    not sure what you're up to there, but why not put the variable on the sprite instead of the spritebox?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • spacedoubt might have it (mixing up instance variables from different objects). If not, try put a System:Once while true after

    System -> SpriteBox.rised = 1 -> Sprite -> Set animation to "Walk" (play from beginning)

    If it's true every tick, your animation will keep going back to the beginning and look like it's not doing anything.

    A screenshot from the actual code would be more helpful.

  • Sounds like a picking problem to me..

    How is C2 supposed to know which spritebox should be affected by which sprite?

    Easiest way would be to put sprite and corresponding spritebox in a container..

  • Hi guys, thanks a lot so far.

    Attached you will find a demo project which demonstrates what I mean.

    As you can see with the first "Sprite" everything is ok. It just starts with an "Idle" animation. After finishing that Sprite.born become 1 and animation "Walk" and simulate control "left" starts. But all upcoming sprites now have Sprite.born = 1 instead of 0 what I think they should have when they have been created.

    Thanks a lot!

  • Change Spite.born=1 to 'Pick by comparison': Sprite.born=1

  • Yep, that works fine! Thank you so much!!!

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