Why doesn't this work as intended, and how do I fix it?

0 favourites
  • 8 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • "explosion.size" gets set to 0.5 (in game), but the scale doesn't update on spawn. Why?

  • Because set scale to explosion.size happens at the same time as the object is created, before you actually set size. So it will be scaling at whatever size was before you set it to 0.5, the default value.

  • i moved the set scale to the "on right click" and it works

  • Because set scale to explosion.size happens at the same time as the object is created, before you actually set size. So it will be scaling at whatever size was before you set it to 0.5, the default value.

    That's what I thought. What's a good workaround, then? I'm trying to make it so that whenever I spawn that sprite I can specify it's size as well as a few other things.

  • Where create object is, instead call a function. Then in the function create the object, set its stats etc. You could also make use of parameters within the function so if you call "Create Explosion" (3). Then in the function, you can use Set scale to function.param(0). That way whenever you call the function, the scale size will always be that first param. It really depends on how detailed you want to go.

  • No workarround needed.

    You can do things (actions) with a newly created objects, either right after the creation or in the 'on create' event.

    You can NOT read things (expressions) from a newly created object until the next root-level event.

    Picking depends on expressions (by UID is the only exception), so you can not pick a newly created object until the next root-level event.

    You set the instance variable explosion.size to 0.5. Thats is possible, as said, its just an action. But read that variable is not possible until the next root-level event. 'On created' just runs as it is on the same time and place as the creation action. So it is no new root-level event.

    How to do this the easy way? And that is not a workarround, that is just how things go.

    Give the sprite an instance boolean 'JustCreated'.

    Right after the creation action, set that boolean to 'true'.

    Now just a totaly new event with the condition (root-event) ..

    Condition > Sprite > Is boolean instance set > 'JustCreated'

    Action > set 'JustCreated' to false.

    Action > anything you want to do with/read from the sprite.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No workarround needed.

    You can do things (actions) with a newly created objects, either right after the creation or in the 'on create' event.

    You can NOT read things (expressions) from a newly created object until the next root-level event.

    Picking depends on expressions (by UID is the only exception), so you can not pick a newly created object until the next root-level event.

    You set the instance variable explosion.size to 0.5. Thats is possible, as said, its just an action. But read that variable is not possible until the next root-level event. 'On created' just runs as it is on the same time and place as the creation action. So it is no new root-level event.

    How to do this the easy way? And that is not a workarround, that is just how things go.

    Give the sprite an instance boolean 'JustCreated'.

    Right after the creation action, set that boolean to 'true'.

    Now just a totaly new event with the condition (root-event) ..

    Condition > Sprite > Is boolean instance set > 'JustCreated'

    Action > set 'JustCreated' to false.

    Action > anything you want to do with/read from the sprite.

    So that works, but now whenever the explosion sprite is spawned it there is a slight delay until the variables are updated, and thus a slight delay for the visuals as well. This, quite frankly, looks awful. Any other ideas?

    EDIT: Actually, I came up with a workaround. I set the explosion to be initially invisible, then when the instance variables were to be read I set it the explosion to be visible. Thanks for the help up to this point!

  • Variables take time to set ? Okay. If you say so.

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