Spawn Actor more than once with Attribute etc..

hello,

Im working on a game right now and I got stuck.
At the moment I collect score, When score (attrebute) reaches a certen amount it sets "SpawnEnemy" attrebute to TRUE.
But when I destroy this actor of Enemy its dead.. I want it to spawn when point / score hit 10,100,1000 etc so I come to live again when SCORE is higher.

At the moment all functions work but I cannot get the Enemy to respawn when score is X higher then before spawned Enemy.
Also I need help to set EnemyHealth when new enemyActor spawns so its like a new enemy with full health.~~~~

Right now its like this.

EnemySpawnAgain - BOLEAN
EnemyHealth - INTEGER
EnemyDeath - BOLEAN
Score - integer

If Score >= 10 then set EnemySpawnAgain to TRUE.
IF EnemySpawnAgain is TURE then SpawnActor .

Also I would Like to know a good way to make "EnemyHealth" reset / always be 100% when Enemy spawn as new.
And a way that when Actor hits Enemy it takes of like 10% and when it hit 0% the enemy destroys.

Please HELP!!!!

Regards!

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited January 2016

    I can give some help but the rest is not clear as to the code you have as to spawning.

    As to resetting enemy health. Use a change attribute in the enemy at the top of the code stack not in a rule. Since a change attribute only fires once just do change attribute game.enemy.health to 100.

    To take away health when enemy is hit change attribute enemy.health to enemy.health-10

    To destroy
    Rule
    When attribute game.enemy.health = 0
    Destroy

    This is just all logic. Have you done any of the tutorials in the academy? It's good to do some to learn how things work.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Create an integer attribute called game.nextSpawnScore and set it to 10. In your spawner actor, add these behaviors & rules:

    If game.Score ≥ game.nextSpawnScore
         Spawn Actor
         Change Attribute game.nextSpawnScore to game.nextSpawnScore*10

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • KIIVIINKIIVIIN Member Posts: 159

    Lost Oasis, I just started yesterday so Im a bit on my way understanding. I got verry little coding skills so its new to me with all variables etc to put in atrebutes etc.

    Well I managed to make it work.
    Thank you guys :)

    I got one more question.
    If I want to make 3 different actors to randomly spawn from 1 actor that gets destryed, how do I manage to do this random function for 3 vectors in 1 spawn actor?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    An actor can spawn any number of other actors using multiple Spawn Actor behaviors. I don't understand what you mean by "do this random function for 3 vectors."

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    @ervin.veisz said:
    Lost Oasis, I just started yesterday so Im a bit on my way understanding. I got verry little coding skills so its new to me with all variables etc to put in atrebutes etc.

    Well I managed to make it work.
    Thank you guys :)

    I got one more question.
    If I want to make 3 different actors to randomly spawn from 1 actor that gets destryed, how do I manage to do this random function for 3 vectors in 1 spawn actor?

    I really recommend watch a series like my build a brick breaker type game on the academy or on my youtube how rules work et.. Will teach you some basics to work off of.

  • KIIVIINKIIVIIN Member Posts: 159

    @tatiang What I mean is that example:

    Monster spawn actor 1,2 or 3 in random secvenses.

    Lets say that I got a monster that attacks with bullets, I want it to shot different bullets between different times.

    So When I see the monster right now it shot bullet nr 1 .. then nr 1 again .. then nr 2... then nr 1.. then nr 3 etc ...

    In a random order I want the Actor Monster to spawn actor "bullet 1" "bullet 2" "Bullet 3".

    @Lost_Oasis_Games Thanks mate, I have been doing a lot of tutorials here on the tutorial section. Thing is still that Im slow learner so even in video Im lost sometimes. I google, youtube and try to find my way on my own but sometime Im really really stuck.

    I already made a decent game with nice grafics so some functions need to be made that Im a bit lost in.

    Anyways, I´ll find my way here or other places but nice that you guys help :)

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    you should he able to do the same code you have for your hero actor?

  • KIIVIINKIIVIIN Member Posts: 159

    @Lost_Oasis_Games What you mean?
    Right now my hero is flying and only shooting.

    I want my enemy to shot 3 different bullets randomly. So it randomly shoot different actors.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @ervin.veisz said:
    @tatiang What I mean is that example:

    Monster spawn actor 1,2 or 3 in random secvenses.

    Lets say that I got a monster that attacks with bullets, I want it to shot different bullets between different times.

    So When I see the monster right now it shot bullet nr 1 .. then nr 1 again .. then nr 2... then nr 1.. then nr 3 etc ...

    In a random order I want the Actor Monster to spawn actor "bullet 1" "bullet 2" "Bullet 3".

    There have been several questions like this on the forums recently and I find it difficult to provide much help because it's not clear exactly what you want. I understand the concept of random sequences of actors but... how would that actually function? Do you just want the monster actor to spawn a choice of bullet (1, 2 or 3) each time at set intervals? So, say every 0.5 seconds it picks one of the three actors and spawns it? If so, that's easy to do and I can explain it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • KIIVIINKIIVIIN Member Posts: 159

    @tatiang
    At the moment my enemy spawn 1 actor every 2 seconds.
    I want it to spawn 1 actor every 2 seconds but that it chooses between 3 different actors.

    I think its the same as u said it to be.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    You said above your hero fires random of three bullets right? So it's the same code to put in your monster just change the actor being spawned.

  • KIIVIINKIIVIIN Member Posts: 159

    @Lost_Oasis_Games said:
    You said above your hero fires random of three bullets right? So it's the same code to put in your monster just change the actor being spawned.

    Nono, I never said my hero shots the 3 different bullets.
    I want the Enemy to do so. Right now my enemy shots 1 actor every 2 seconds but I want the enemy to choose 3 different actors to shot every 2 seconds

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    How does the monster fire bullets now? Using a timer?

  • KIIVIINKIIVIIN Member Posts: 159

    @Lost_Oasis_Games said:
    How does the monster fire bullets now? Using a timer?

    yes timer then spawn actor :)

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Okay so do this.

    Make a self attribute in the monstor actor call it bullet#

    Since your bullets spawn every two seconds you will need to offset the timing of the random generator.

    Timer after .5

    Timer inside every 1sec (this will cause the random to change a half second before the next fire)

    Change attribute self.bullet# to random(1,3)

    Inside monster fire timer add these rules

    Rule

    When self.bullet# = 1

    Spawn bullet 1

    Rule

    When self.bullet# = 2

    Spawn bullet 2

    Rule

    When self.bullet# = 3

    Spawn self.bullet = 3

  • KIIVIINKIIVIIN Member Posts: 159

    @Lost_Oasis_Games said:
    Okay so do this.

    Make a self attribute in the monstor actor call it bullet#

    Since your bullets spawn every two seconds you will need to offset the timing of the random generator.

    Timer after .5

    Timer inside every 1sec (this will cause the random to change a half second before the next fire)

    Change attribute self.bullet# to random(1,3)

    Inside monster fire timer add these rules

    Rule

    When self.bullet# = 1

    Spawn bullet 1

    Rule

    When self.bullet# = 2

    Spawn bullet 2

    Rule

    When self.bullet# = 3

    Spawn self.bullet = 3

    should the self attru'ibute Bullet be interge?
    And do I need to have Bullet# with the #?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    I really recommend you watch some of the introduction videos. An attributes name means nothing code wise. It is only an identification for yourself. You can name it anything you want.

    Attribute types

    Interger will store number without decimal places and can be negative as well as positive aka -1 0r 1

    Real will hold numbers with decimal places aka 1.33

    Boolean only true or false

Sign In or Register to comment.