Can not spawn random characters

BaccardaBaccarda Member Posts: 122

Hi everyone!
I recently wrote a topic about random character spawning and i thought that i did it but i was wrong and now i'm struggling , because i cant find a problem in my algorithm.
I have 6 types of clouds and i need them to be spawned in 6 lines from side to side with different speeds.
When the cloud reaches other side of the screen, actor spawns another random cloud which is moving to the opposite side of the screen and so on.
So i made 6 spawning actors and placed 3 on the left side of the screen and 3 on the other side to have 6 lines of clouds moving in both ways.
Then i made 6 more actors with different moving speeds and directions which i used to spawn the clouds itself. ( Spawn cloud spawner - cloud spawner - cloud )
Clouds are constrained to cloud spawners and cloud spawners are moving clouds from side to side because i don't see other way how to make an actor which is replicated and moving in different ways and speeds at the same time.

Might be someone has a spare hint for making it easier?

Comments

  • SummationSummation Member, PRO Posts: 476

    @janis.piziks@gmail.com said:
    Hi everyone!
    I recently wrote a topic about random character spawning and i thought that i did it but i was wrong and now i'm struggling , because i cant find a problem in my algorithm.
    I have 6 types of clouds and i need them to be spawned in 6 lines from side to side with different speeds.
    When the cloud reaches other side of the screen, actor spawns another random cloud which is moving to the opposite side of the screen and so on.
    So i made 6 spawning actors and placed 3 on the left side of the screen and 3 on the other side to have 6 lines of clouds moving in both ways.
    Then i made 6 more actors with different moving speeds and directions which i used to spawn the clouds itself. ( Spawn cloud spawner - cloud spawner - cloud )
    Clouds are constrained to cloud spawners and cloud spawners are moving clouds from side to side because i don't see other way how to make an actor which is replicated and moving in different ways and speeds at the same time.

    Might be someone has a spare hint for making it easier?

    The original spawner can pick a cloud by doing random 1,6
    You can have the cloud check what side of the screen it's on to know which way to move towards, right or left.

  • BaccardaBaccarda Member Posts: 122

    How exactly check it? by recording spawners position on the screen? I've thought about that, but i need clouds to be spawned endlessly as the character goes higher so that would not be possible :/

  • SummationSummation Member, PRO Posts: 476

    @janis.piziks@gmail.com said:
    How exactly check it? by recording spawners position on the screen? I've thought about that, but i need clouds to be spawned endlessly as the character goes higher so that would not be possible :/

    The X position is left and right, so you can use half of the screen width to tell you if the X position is left or right.

  • BaccardaBaccarda Member Posts: 122

    How could i replicate those cloud spawners as my character goes higher? Do i have to make a very large scene and place them one by one?

  • EverwildEverwild Member Posts: 48

    When I have something come up for which I need to spawn random actors/characters anymore, most of the time, I'm really just using one actor, then using table functions to determine what that actor really is, what it does, what image and what size etc etc.

    To do that, start off with just your one actor. Give it a self attribute like self.whichcloud or something.

    Put Change Attribute right in there, not even in a rule, just to be run when the actor spawns. Change Attribute [self.whichcloud] to random(1,6) (since you said you have 6 clouds). So when your actor is spawned, the first thing it's going to do is determine what it is.

    THEN you need your table (or you could make the table first, I don't care, I'm not the cops). All it needs is to have the X,Y coordinates that you plan on having your clouds spawn at. So if you have 6 different places where these clouds need to come from, you're going to have 6 rows, and 2 columns.

    Now back to your cloud actor. Along with the random selection it has to do at the beginning of life, you're going to give it 2 more Change Attribute behaviors. Simply changing self.position X to tableCellValue(tablecloudpositions, (self.whichcloud),1 and self.position Y to tableCellValue(tablecloudpositions, (self.whichcloud),2.

    If you have varying sizes or speeds or images you are going to use, those can be added into additional columns without having to make more attributes in either game or actor.

    Then your cloud actor just needs a rule that says if it's 'these types' of clouds, make it move one direction, and if they're the other clouds, move the other direction.

    Then you just need a spawner, and it only has to spawn that one actor, and the actor does the work of determining where it belongs and where it goes.

  • SummationSummation Member, PRO Posts: 476
    edited May 2015

    @janis.piziks@gmail.com said:
    How could i replicate those cloud spawners as my character goes higher? Do i have to make a very large scene and place them one by one?

    It's a little complicated but here's an idea.

    Constrain an invisible detector across the X axis to a specific amount of pixels below your main character.
    This way, as the character goes higher, the detector will follow.

    When a spawner hits a detector, it can replicate itself above the other spawners wherever you want it, then destroy itself.
    This way only your 6 spawners will be on screen at the same time.

  • BaccardaBaccarda Member Posts: 122

    I think that i have an idea. I'll just make a very large scene and place spawners manually it'll be like endless runner. any way, each time clouds will be different size and speed, so that will make the environment feel different every time but i am only thinking about a fact that because of the scene size i could lose game's performance or size will be much bigger. :/

  • BaccardaBaccarda Member Posts: 122

    @Summation said:
    This way only your 6 spawners will be on screen at the same time.

    But should i make a larger scene or use the same 1024 height ?
    I'm a bit confused now. I don't know how to get them spawning and maintain the effect of large scrollable scene. :/

  • SummationSummation Member, PRO Posts: 476

    @janis.piziks@gmail.com said:
    But should i make a larger scene or use the same 1024 height ?

    I'm a bit confused now. I don't know how to get them spawning and maintain the effect of large scrollable scene. :/

    I believe @jamie_c has a great tutorial on making an endless scrolling background.
    You can apply the same concept to moving up endlessly.
    Should only need two backgrounds, recycling.

  • BaccardaBaccarda Member Posts: 122

    I think i have overheated my brain, cant think straight no more. I'm getting your idea but i can't do it in gamesalad. :/

Sign In or Register to comment.