How do I create a blackhole effect?

Get help using Construct 2

Post » Thu Mar 12, 2015 8:36 pm

I'm creating an asteroid game. I want to have a blackhole in the center. It sucks everything. And the closer an object to the center of the blackhole, the harder it is to get away.
Posts: 220
Reputation: 1,464

Post » Thu Mar 12, 2015 10:33 pm

easily done.

your objects speed must be calculated. let's say your object has speed 20.
20- e^-koef if koef =0 then e^- koef = 1 if koef > 0 then e^-koef is <1 and if koef <0 then e^-koef > 1
so if koef = 1 speed is 20 - e^-koef = 20 - 1/2.73 if koef =2 then 20 - 1/(2.72)^2 - almost no speed loss.
if koef = -1 then speed is 20 - 2.72, koef = -2 20-2.72^2 and so on.
now if you think about it- koef could be distance. and distance between 2 points is calculated like this: ... /index.php (check formula)

you could use foreach object visible on screen - calculate koef and apply speed formula.
and now for the "sucktion" part - you would have to give objects angle towards the object (Black hole). you could do that by giving it 2 speeds. let's say - bullet for movement, and custom for sucktion. - set angle towards black hole, and speed e^-koef , and use bullet for nomal movement (speed 20). so you would have all the time 20 - e^-koef.

i think that would work

there might be though a simpler (or already completed) solution, but i have no idea if there is one.
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

Posts: 630
Reputation: 9,465

Post » Thu Mar 12, 2015 10:44 pm

maybe...Apply force toward(BlackHole.Y,BlackHole.Y) ?... :D
Posts: 1,519
Reputation: 11,104

Post » Thu Mar 12, 2015 11:03 pm

Here is a quick and dirty capx of an asteroid getting pulled into a blackhole. It may not be the best way, but its a start for you to modify to your needs.

It uses Rexrainbow's gravitation plugin. Get it Here:

Read up on this for checking the distance between multiple instances of the same object. It has some useful information here as well.

Hope this helps.
You do not have the required permissions to view the files attached to this post.
Posts: 80
Reputation: 864

Return to How do I....?

Who is online

Users browsing this forum: fbarraza28 and 6 guests