[solved] spawning an object by name?

0 favourites
  • 8 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I did hunt for this.. does such a method exist?..

    basically, i have turrets and want to store the string or some ref value that represents the type of bullet it will spawn..

    I could then have something like Turret.Spawn(Turret.BulletType)

    thanks :)

  • Unfortunately there no way to spawn objects by name at this time.

    Easy solution to your problem would be use of instance variables for bullet sprite.

    example in pseudo code:

    bullet_type = 1 -> bullet.speed = 100

                   -> bullet.power = 20

    bullet_type = 2 -> bullet.speed = 200

                   -> bullet.power = 50

    then after spawning you need to set variable to proper value

    +Turret spawn Bullet

    +set bullet.bullet_type = 1

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thanks :)

    was hoping to avoid doing things like that.. but i guess it will just have to be.. seems strange that its not already there.. but then, i guess they have a big todo list..

  • haha!.. didnt even need to do this.. sorry. still trying to get my head around working with C2. managed to get obsessed with a single approach to the problem.. not that this wouldnt be handy feature.. thanks again :)

  • I haven't tried it myself, but maybe this plugin from rex_rainbow will do the trick: Nickname plugin

  • matt75 what solution did you end up using instead? Just asking as it helps to post the answer when you post questions, that way others with the same answer can find it. Also, if you do post the answer, could you update the title of the post with [Solved] in the subject.

  • Try Nickname plugin as boolean said.

  • Thanks :) will check out that plugin :)

    • Wasnt really a solution, just ended up i didnt really need to take that approach. Each of my turret sprites fires it own type of ammunition.. so all i really had to do was check if the turret is ready to fire and spawn the bullet sprite for that turret (i know, a little dumb). The problem stemmed from the fact i was using families, and thinking i should be firing bullets like this "Family.Fire()", which would spawn the correct bullet in a more abstract, and perhaps easier to maintain way.. but im happy to settle for none family approach in this situation..

    "turret_flak.OnFire(FlakBullet)"

    anyway, thanks for all your help :)

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