Have multiple actors move upon one collision (code included)

ariakbari

  • *
  • Posts: 22
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: 1022
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.
046 121 116 105 116 110 101 100 105 032 121 109 032 116 117 111 098 097 032 110 111 105 116 115 101 117 113 032 111 110 032 101 118 097 104 032 100 108 117 111 104 115 032 117 111 089 032 046 084 074 032 101 114 097 032 115 108 097 105 116 105 110 105 032 121 077 032 046 117 111 121 032 107 099 097 116 116 097 032 108 108 105 116 115 032 108 108 105 119 032 073 032 100 110 065 032 046 116 114 105 104 115 032 115 105 104 116 032 103 110 105 114 097 101 119 032 108 108 105 116 115 032 109 097 032 073 032 046 110 111 115 032 115 105 104 032 109 097 032 073 032 046 101 109 032 119 111 110 107 032 121 097 109 032 117 111 089