Different instances and different variable values

0 favourites
  • 11 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I have a variable for my enemy ship called FireRate. However, the issue right now is that every enemy ship fires at the same rate. How do I make it so that the enemy ships fire at different rates, meaning each different instance would have a different value for FireRate?

    I have a For-Each condition, but I'm not sure how to tie it in with UID.

  • The way you've done it (looking at your older .capx here) you pick the firerate for each enemy from a single instance of the enemy object. Add for each before your fire condition and it should fix it.

  • I'm not sure how to pick each single instance and then give that specific instance a value. Right now I'm going through each instance and giving every enemy the same value.

    <img src="http://i.imgur.com/GXcItuM.png" border="0" />

  • In the capx I was looking at it was done correctly:

    <img src="https://dl.dropbox.com/u/19921470/firerate_fix.PNG" border="0" />

    It works, because the just created enemy is picked and any actions done to enemy objects are thus only applied to that particular enemy.

  • Maybe it's just me, but they all seem to fire at the same rate?

    SpaceGame.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You still need to add the fix I posted in earlier post, add for each enemy before fire condition.

  • Do you mean like this?

    <img src="http://i.imgur.com/BIlWWAa.png" border="0" />

    Sorry, I'm not entirely sure what you mean. I'm still getting the same rate of fire on all of them :/

  • I think I have to go through each particular instance after the enemies are created and set their fire rates that way, but separating the 'For Each' outside the 'Repeat' loop still causes them to all have the same fire rate because I'm not sure how to set the instance variable only for instances that haven't already been set.

  • Create ShipSprite > Set bullet speed: Random

  • I don't think that solves the problem, because in essence that's exactly what I have already done that isn't working.

    I'm setting the firerate in the For-Each loop that creates each ship sprite.

  • Here's an update of what I've done based on vee's feedback, but now I'm getting the issue where one enemy ship seems to be firing and the others don't fire at all.

    Occasionally I get the error where enemy ships have a fire rate that is insanely high, like 0.1 or something, which shouldn't be possible because the default fire rate is zero. Any ideas why this might be happening?

    <img src="http://i.imgur.com/OmhMRfr.png" border="0">

    SpaceGame.capx

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