How do I change instance variables before on create

0 favourites
  • 2 posts
From the Asset Store
Color Variable
$4.50 USD
10% off
Easily store, modify, read and manipulate colors with Color Variables!
  • Hello everyone!

    I have another problem: I wanna...

    • ... create an object
    • ... set the object's instance variables before OnCreate is called
    • ... check within OnCreate the value of the instance variable

    My problem with that is, that OnCreate is called immediately after I create the object. But I want to change the instance variables of the created object first before OnCreate is executed

    Here's an example:

    I have an enemy spawner. The spawner has 2 different modes

    • Spawn the enemies behind a door and set the "invading" boolean to true. In OnCreate of the enemy check if "invading" is true and let the enemy run into the room
    • Distribute the enemies in the room (they're standing still when created). "Invading" is left false

    How can I access the instance variable before the "OnCreate"-event is called?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Short answer - you can't use On Create for this.

    On Create is triggered before the instance is actually created, so many properties and instance variables are not accessible at this time..

    You need to use some other event. Or maybe even add "Wait 0" - this will wait till the next tick, when instance creation is complete.

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