Actor spawning one at a time after being collided?

justinodunnjustinodunn Member, PRO Posts: 226

After the main character collides with the coin actor, I want it to destroy that coin actor, but spawn a new one at a different random location at the same time, how do I do that?

Comments

  • justinodunnjustinodunn Member, PRO Posts: 226

    it goes like spawner:

    • spawn coin is false, change attribute spawn coin to true. change attribute (random 1,4), when attribute= 1/2/3/4 spawn coin (different locations)

    for the coin:

    • when actor collides with main character, destroy actor, change attribute spawn coin to false, add 1 to score

    However, the coin only spawns once, and once I collided with that coin, nothing spawns again.

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    You've kind of already written out what needs to be done.

    In the coin actor:

    When coin collides with main character:

    Destroy

    Spawn a new coin actor / random X random Y

    . . . . .

    Example (drag the white actor around)

    Link: https://www.mediafire.com/?vb4j8nz8zak41q1

  • justinodunnjustinodunn Member, PRO Posts: 226

    thanks man but I did what you did, however at some point maybe after colliding with the coin 3 or 4 times, the next coin just doesn't spawn at all?

  • SocksSocks London, UK.Member Posts: 12,822

    @justinodunn said:
    thanks man but I did what you did, however at some point maybe after colliding with the coin 3 or 4 times, the next coin just doesn't spawn at all?

    Can you show us a screenshot of your rules ?

  • justinodunnjustinodunn Member, PRO Posts: 226



  • SocksSocks London, UK.Member Posts: 12,822

    Did you try my method ?

  • justinodunnjustinodunn Member, PRO Posts: 226

    yes i am using your method

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    ...

  • justinodunnjustinodunn Member, PRO Posts: 226

    is there something wrong with the random spawning? Do i need to set up a loop?

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    When coin collides with main character:

    Destroy

    Spawn a new coin actor / X 160 / Y (Random(0,3)*142)+55

  • justinodunnjustinodunn Member, PRO Posts: 226

    doesn't make a change :neutral_face:

    could you please take a look at my project? (tap top of screen to move up, and bottom of screen to move down)

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    @justinodunn said:
    doesn't make a change :neutral_face:

    The best feedback is often the most vague :) My favoutire has always been 'nope, didn't work', but 'doesn't make a change' is good too. :p

    I used the logic that I posted above and it worked just fine.

    Link: https://www.mediafire.com/?75y4b458d9bkg9z

  • justinodunnjustinodunn Member, PRO Posts: 226
    edited May 2014

    my bad! but what is this sorcery?! i used the same code but didn't work for me haha :p maybe its the code in the spawn actor y attribute that I didn't quite understand..

    Thanks man

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    @justinodunn said:
    my bad! but what is this sorcery?! i used the same code but didn't work for me haha :p

    Thanks man

    Every actor in your project (every single one!) is unlocked for some unknown reason (unknown to me at least :smile: ), so I guess you were changing rules in actors in the Actors window - which would have no effect on the actors in the scene ?

    (Just a guess).

  • justinodunnjustinodunn Member, PRO Posts: 226

    hmm perhaps perhaps, i guess there was nothing wrong with the code at the first place, but some silly mistake made, still can't figure out what though. Anyways, thanks for the help, i'll use your logic :)

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    My logic follows your logic in that it places the coin in 4 different locations randomly - one of those locations is directly under the main character - you might not want that - as the coin immediately adds a point to the score and then destroys itself (and spawns the next one) - so to the player it will appear that occasionally (actually 25% of the time) they are awarded a point for doing nothing.

    You might want to spawn the new coin actor randomly at the three locations the main actor doesn't occupy.

  • justinodunnjustinodunn Member, PRO Posts: 226

    it doesn't really matter this is exactly what i want, as long as it spawns randomly then its fine. my game is simple, once it's done you'll see why i want it this way :smile:

  • SocksSocks London, UK.Member Posts: 12,822
    edited May 2014

    @justinodunn said:
    it doesn't really matter this is exactly what i want

    Good ! :)

    @justinodunn said:
    as long as it spawns randomly then its fine. my game is simple, once it's done you'll see why i want it this way :smile:

    Glad it works for you, be interesting to see what you come up with, I scanned your whole project and there was no mention of 'flappy' anywhere, so all good !! ;)

  • justinodunnjustinodunn Member, PRO Posts: 226

    haha don't worry ;)

Sign In or Register to comment.