Have multiple actors move upon one collision (code included)

ariakbari

  • *
  • Posts: 21
Hello,

I am making a vertical scrolling game where platforms come from the top of the screen to the bottom and a player jumps up the platforms. The platforms should stop scrolling at a certain point down the screen to make it seem as if the player is bouncing up the platforms and he is the only one moving. The best game I could think to relate it to would be doodlejump.

In my game, I would like to have it so that when my player jumps on one platform next to him, multiple other platforms from the top come down (and all platforms move down), simulating the player jumping higher and higher. I obviously cannot build platforms upwards  forever and ever so I have an RNG that spawns platform out of the screen and sends them down when the player jumps on a tile and bounces up, seeming as if the player jumped up higher to the new platforms.

So far, I've been able to set up a collision so that when my player hits a tile, the player goes up a bit and the platforms move down, but only one platform comes down a time from the RNG. I would like to make it so multiple platforms can come down into view at once to jump on, and so forth, creating this idea that the platforms keep going. Things spawn irregularly as is. Could anyone help me to achieve what I am describing here? I have included pictures of the code I have been playing around with and can answer any other questions.

Any help is appreciated, thanks!

Vaibhav Sangwan

  • Posts: 157
hello ariakbari,
there are various errors in your code.
First of all,
in the second image you have set bb to false and then added if bb=true.
the code inside if statement will never run.
Second, in the first and fourth image, you are using Last Created Actor in When Updating.
This will most likely lead to errors.Use attributes instead
Also, in the first image, you are using the event "when this actor hits something else".
Instead of that use "when this actor hits an actor of tiles" event.
Also, use for each actor of type block in the 1st image to move tiles downwards.

« Last Edit: March 13, 2018, 04:27:02 am by Vaibhav Sangwan »

NickamonPoppytail

  • Posts: 911
hello ariakbari,
there are various errors in your code.
First of all,
in the second image you have set bb to false and then added if bb=true.
the code inside if statement will never run.

You should probably place the "bb" attribute into a Created event or scrap it entirely. The Updating event runs 100 times per second, so the game will set bb to false 100 times for every second your game is running.

A better alternative would be to place the "set bb to false" block INSIDE the if statement, before the "set y-speed" block. This way, the event will trigger once when bb is true.

I have used this method multiple times and it has worked every single time.
Currently developing Poppytail 5, Pixeltail and The Poppytales.

Email: nick.rosemarygames.poppytail@gmail.com

;)