Dinamically create objects

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I was just wondering if it is possible to create an object just using his name.

    Let's say I have a turrent and I have two types of ammunition, ammo1 and ammo2.

    If I press a button I can change the ammo type, I save that info in a Instance variable string, so every 3 seconds I shoot the object saved in the instance variable as a name.

    Its that possible?

  • construct.net/en Nickname behavior might help you

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • In the layout pane:

    • Place the ammo in the margin (not in the layout itself)
    • Give the ammo a bullet behavior
    • Set the speed

    In the shoot event that you will create:

    • if instance variable is ammo1
    • spawn ammo1
    • set angle of ammo1 (angle of the turret)
    • else if instance variable is ammo2
    • spawn ammo2
    • set angle of ammo2 (angle of the turret)

    You can spawn by using the "create an object" under system

    I hope that helps

  • Awesome Rabenmutter, yes this seems its he stuff im looking for.

    AlKanadi, thanks for your answer but it's not really what I'm looking for. For example if we had 100 types of ammo that solution isn't going to be easy to maintain, I would have to do 100 if then else loops.

    Putting the name or thenickname on a instance variable will help alot.

    thanks!

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