I’ve come pretty far with the game I’m doing currently and it’s scheduled for release on mobile Q4 2015. We are about to have it tested by a lot of outside people to see if we are on the right track, but there is one thing that I really need your help with!
You are a space dude flying around and a black hole starts to rapidly expand. You have to outfly it even though you can’t but for the sake of the game you try. In order to survive longer you can collect fuel cannisters and have to avoid asteroids. When you collect enough fuel you can “jump ahead” some to delay the inevitable of the black hole catching up as it increases in size. When you fly you build up a multiplier to get more points. When you jump ahead you lose the multiplier but keep the points.
What I need help with is the black hole itself. Currently it only moves forward given a time delay but I need to give the player a sense of speed so that it looks like they are actually getting away from it. But I am not sure how to do this. Currently the black hole will keep “expanding” (really just move closer to you) and if your fuel is below a certain threshold it’ll stop moving until it detects your fuel is low enough in which it will expand again until you reach the needed fuel or you get hit by the black hole and die. However we need a way for the player to look like they are speeding away from the black hole if they are playing well enough. I really need your help with this part!
To give you an idea, here is what the game is like right now:
As you can see you can’t really “escape” but we need to give the player the feeling as if they can.
Here is where it starts. When the player first spawns and starts flying:
Would be nice to know if the Ship is really flying, or if the map is moving.
I think the Ship is always at the same position X or and the Map is moving or?
If yes, the speed is affecting the scrolling of the map and the black hole is only moving
a bit from it’s spawn position to the space ship.
So you may just want to check if the ship speed reaches a certain value and then move the
black hole back again.
The Ship flies with a Speed of 10 at base. It can fly with up to 20, but it needs to collect the fuel for this.
The Blackhole starts with 10 Speed, getting more over time, eventually reaching either 19 Speed or 21, which
would either lead to not being able to escape anymore (so no endless gameplay), or into a really hard game
Now you can check if the Blackhole Speed is higher than the Ship speed, if yes, you move the Blackhole over to the
ShipPosition. If not, you move it back to it’s spawn position.
With a bit of math, you can also make it going back and forth differently fast. Like looking how much greater the Blackhole
I have no idea if this helps you, it depends on your setup though x)
The ship is stationary at all times. It can only move up and down to avoid incoming asteroids and collect fuel. It doesn’t actually move back or forth.
But yeah that’s what I’d like to do. Just wanted some pointers on how I’d implement that in my current setup.
I think you are doing something like this already.
Just like i said. Setup a variable for speed on both. Or use the ones you already have if they match this.
Make sure that the Blackhole Speed Variable is in similar range as the SpaceShip Speed Variable.
Let’s say your Blackhole is at X value 0 and the SpaceShip is at X value 100.
Both start with a speed of 10. The SpaceShip can get to a Speed of 20 by getting fuel
and making that jump thing you implemented.
The Blackhole gets a speed up every 10 seconds by, for example 1, up to 19.
Now, in the Blackhole’s EventTick, you add the difference to the X value of the Blackhole.
To follow the example:
At the beginning, the SpaceShip is at speed 10 and the Blackhole already reached speed 11.
Now you add “11 - 10 = 1” to the X-Value on Tick, or each 2 seconds (depends on how fast you want it to move).
A few seconds later, the Blackhole is at speed 15, and the SpaceShip still at 10.
So you have “15 - 10 = 5” for the summation of the Blackhole’s X-Value.
Resulting in the Blackhole coming near the SpaceShip pretty fast. Now the SpaceShip jumps and gets a speed of 20.
Now the equation is “15 - 20 = -5”. It’s the same equation but the result is negative. This gets added to the X-Value
of the Blackhole again, resulting in the Blackhole moving away from the SpaceShip again.
But that doesn’t seem to work quite how you say it should…I’m just wondering whether I need to replace my entire timeline setup and use lerping instead
It seems that the “Reverse” branch is completely ignored even though it does fit the conditions to go that route. It just stops dead in it’s tracks instead of going backwards.
I would use the Lerping. You are now making some weird calculations there, because you are subtracting the Blackhole speed from the SpaceShip ones like i told you, but then you are adding the Blackholes Speed again
and setting it the Speed. This is really weird.
You better make the increasing and the moving in 2 different places. So you increase the way you normally do, and at another point, you use these 2 speed variables to add something to the X Value.
I thought about something like that. I don’t have a SpaceShip actor, so i just added the ShipSpeed as a normal float.
I’ve made a limiter which is made at construction time. It notes down the spawn location of the black hole. I make sure it won’t go past it’s own spawn point because then it will have a hard time making it back to the ship at all.
However I have a new problem with the current setup. The black hole gets fairly close and then if I hold off the speed it’s the same problem as before that it doesn’t go backwards but stops moving instead. However now, when the black hole reaches max threshold (1.95) it goes at the ship so fast you can’t react and ends the game.
I think we are really close! What do you think I’m missing?
Good news! I made the black hole move back and forth!
I changed the math so that it increases the black holes movement speed by 0.1 instead of 0.325 with every increase. Now it moves back and forth as it should