Doppleganger mimicking player's every move

Get help using Construct 2

Post » Mon Dec 30, 2013 5:12 am

Recall one of the final stages in Rayman, where there is this doppleganger following you and mimicking your every move? Take a look at this video on 1:25

I used to make something like that in other game engine that has fixed framerate, so I simply record all of player's moves, and then "inject" all these movements to the doppleganger x seconds later.

But in C2, with event running every tick and variable framerate, the method above is not possible. So in variable framerate game, ...how?keroberos2013-12-30 06:47:02
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Dec 30, 2013 7:13 am

If all your actions use delta time using seconds won't be a problem.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 30, 2013 7:51 am

@LittleStain It would be a problem.

Imagine you are running around with 60 fps for now, then suddenly, the game drops to 20 fps for whatever reason. So here, your inputs are logged from 60 times a second and 20 times a second respectively.

If you feed your doppleganger's input that is 60 times a second in a 20 fps situation. The position of the doppleganger will be off.

See the problem?
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Dec 30, 2013 7:56 am

I always thought that frame rate independant meant that things happened at the same time regardless of framerate, but I could be wrong..




I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 30, 2013 8:41 am

@LittleStain check out http://www.koonsolo.com/news/dewitters-gameloop/ and you will know what I meant.

C2 decided to go with the "Game Speed dependent on Variable FPS". So to tackle this problem, we need some ways that make the values identical in every run.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Dec 30, 2013 8:46 am

Like I tried to explain before, using delta time construct2 uses the "Constant Game Speed independent of Variable FPS"
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 30, 2013 9:23 am

@LittleStain Read this part from the link carefully:

[quote]Slow Hardware
Slow hardware can sometimes cause certain delays at some points, where the game gets heavy. This can definitely occur with a 3D game, where at a certain time too many polygons get shown. This drop in frame rate will affect the input response time, and therefore also the players reaction time. The updating of the game will also feel the delay and the game state will be updated in big time-chunks. As a result the reaction time of the player, and also that of the AI, will slow down and can make a simple maneuver fail, or even impossible. For example, an obstacle that could be avoided with a normal FPS, can become impossible to avoid with a slow FPS. A more serious problem with slow hardware is that when using physics, your simulation can even explode

!

Fast Hardware
You are probably wondering how the above game loop can go wrong on fast hardware. Unfortunately, it can, and to show you, let me first explain something about math on a computer. The memory space of a float or double value is limited, so some values cannot be represented. For example, 0.1 cannot be represented binary, and therefore is rounded when stored in a double. Let me show you using python:

>>> 0.1
0.10000000000000001
This itself is not dramatic, but the consequences are. Lets say you have a race-car that has a speed of 0.001 units per millisecond. After 10 seconds your race-car will have traveled a distance of 10.0. If you split this calculation up like a game would do, you have the following function using frames per second as input:

>>> def get_distance( fps ):
...     skip_ticks = 1000 / fps
...     total_ticks = 0
...     distance = 0.0
...     speed_per_tick = 0.001
...     while total_ticks < 10000:
...             distance += speed_per_tick * skip_ticks
...             total_ticks += skip_ticks
...     return distance
Now we can calculate the distance at 40 frames per second:

>>> get_distance( 40 )
10.000000000000075
Wait a minute this is not 10.0??? What happened? Well, because we split up the calculation in 400 additions, a rounding error got big. I wonder what will happen at 100 frames per second

>>> get_distance( 100 )
9.9999999999998312
What??? The error is even bigger!! Well, because we have more additions at 100 fps, the rounding error has more chance to get big. So the game will differ when running at 40 or 100 frames per second:

>>> get_distance( 40 ) - get_distance( 100 )
2.4336088699783431e-13
You might think that this difference is too small to be seen in the game itself. But the real problem will start when you use this incorrect value to do some more calculations. This way a small error can become big, and up your game at high frame rates. Chances of that happening? Big enough to consider it! I have seen a game that used this kind of game loop, and which indeed gave trouble at high frame rates. After the programmer found out that the problem was hiding in the core of the game, only a lot of code rewriting could fix it.
[/quote]

Anyone else?
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Dec 30, 2013 9:47 am

I'm sorry, I thought you wanted a frame rate independant game, so you could call actions in seconds (or parts of it) instead of per tick.

I must have misunderstood.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 30, 2013 10:07 am

Although This is not exactly what you are looking for it might give you some ideas, especially the capx Rojohound posted.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 30, 2013 12:23 pm

Lerp function! OK, @rojohound's solution is what I am looking for. I can extend from it. Thanks @LittleStain !
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 32 guests