Animation, overlapping and collision help

We are creating a game with 3 spawners at the top of the screen (left, middle and right), each spawning the same actor at random times. We have mostly gotten all that figured out. While they spawn at random intervals however, they fall at a constant rate. Basically the game is catching the objects as they fall. We want the player to be able to miss the falling objects of course. Here is the problem; the falling actors will just keep falling off screen. This isn't really what we want though, we want them to disappear when we hit the ground. To accomplish this we created a "Ground" actor, and in the falling actor we created a rule where when it hits either the "Catching actor" or the "Ground actor" it will disappear, only counting as a point when it hits the "Catching actor," when all conditions are valid. In order to make it so it disappears either when it hits the "Catching actor" or the "ground actor," we had to make it when ANY rather than "all" conditions are valid. This makes everything function pretty well, they disappear when we want them to. Unfortunately, there is a problem with the catching actor. When the catching actor catches a falling object, there is an animation that commences. The problem is that when we make it so "when any conditions are valid" in the falling actor, so that it disappears upon overlapping or colliding with the ground OR catching actor, this animation does not play. The animation attribute is within a rule, in the catching actor.

Apologies for the long winded question, but any help would be appreciated.

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782

    @devmatt, the animation is in the catching actor? What is probably happening is that the rule making the falling actor disappear fires first, destroying the actor. By the time the code checks for an overlap in the catching actor, the falling actor no longer exists.

    What you can to is wrap the "destroy" behaviour in a timer (after 0.04 seconds run to completion). This will let the falling actor survive at least one more code cycle for the catching actor to detect it.

  • devmattdevmatt Member Posts: 38

    We had to make a few other adjustments that we discovered ourselves but your input still provided insight so thank you.

  • devmattdevmatt Member Posts: 38

    We are creating a game where there are three spawn points at the top of the screen (left, middle and right) each spawning the same actor at random times. We got that working pretty great. The only problem we have now, is overlapping. Each spawn point spawns this actor at random intervals. We achieved this by a timer behavior, for every 0.1 seconds, change attribute, self.timing to random(1,10). This is the same for all three actors that spawn the falling actors. The only thing we want to fix right now, is so that these actors being spawned, while still random, never spawn at the same exact time as another. Otherwise it is impossible to catch them as they fall to separate locations. Any advice?

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    Hey @devmatt,

    Just make another timer that says something along these lines:
    *Create a self attribute integer (called something like; WhenToSpawn)

    Create Rule
    When self.WhichSpawne = 1
    activate spawner 1

    When self.WhichSpawne = 2
    activate spawner 2

    When self.WhichSpawner = 3
    activate spawner 3

    Timer
    Every 0.5 seconds; run to completion
    Change Attribute: self.WhichSpawner to random(1,3)

    Hope that makes sense and helps!

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

    Merged your two threads. Please don't create multiple threads for the same issue.

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

  • devmattdevmatt Member Posts: 38

    @KillerPenguinStudios Thanks for the input.

    I don't quite understand what you mean. I created another attribute called "WhenToSpawn", integer and it is 0.0

    Now I can go to one of my spawners and create a rule saying "When self.WhichToSpawn=1" but I cannot make "activate spawner 1."

  • devmattdevmatt Member Posts: 38

    @tatiang we did not create multiple threads for the same issue, at least not with what you merged. Both are two different questions. If any information is restated, this is because both are crucial to the question we are asking. Apologies for misunderstandings, but these are two entirely different questions.

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    Watch my video series on code order and gamesalad logic.

  • KillerPenguinStudiosKillerPenguinStudios Member Posts: 1,291

    @devmatt said:
    KillerPenguinStudios Thanks for the input.

    I don't quite understand what you mean. I created another attribute called "WhenToSpawn", integer and it is 0.0

    Now I can go to one of my spawners and create a rule saying "When self.WhichToSpawn=1" but I cannot make "activate spawner 1."

    Right now how you have it it's not going to work because you don't have anything telling the attribute "WhenToSpawn" to change to a specific number.

    Have an actor that you place your scene rules into placed somewhere in your scene out of view of gameplay. You can also turn its alpha to 0. In this actor, place the timer rule below in it.

    Timer Every 0.5 seconds; run to completion Change Attribute: self.WhichSpawner to random(1,3)

    Now since this is in the scene and constantly running then everything else will work if coded properly. Also, do what The_Gamesalad_Guru said!

    Hope that helps!

Sign In or Register to comment.