construct 2 can't do this ?

Discussion and feedback on Construct 2

Post » Thu Jul 21, 2016 8:09 pm

hi,
i want to make a replay system for an rts game
game use bullet behavior for all movement
i can not record every unit x and y and then replay it becuase there is diffrent type of units and they creating in realtime
so i have to save only user input and then do the exact same things
i did that but when i replay the game in different framerate or different timescale , the replay changes and its not exact same thing
so how can i do that ?
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Thu Jul 21, 2016 8:38 pm

Hmmmm a bit tricky i guess, but I think I would try to use an array to record all the unit positions and commmands, for the last few seconds. (depending on how long playback do you need) if only a few seconds i think array would be fine, but if you want to record the whole game you probably have to output to a log file or something, then replay the log in some way. I'm pretty sure it can be done.
Follow my progress on Twitter
or in this thread Archer Devlog
B
41
S
18
G
18
Posts: 1,024
Reputation: 13,345

Post » Thu Jul 21, 2016 9:07 pm

tunepunk wrote:Hmmmm a bit tricky i guess, but I think I would try to use an array to record all the unit positions and commmands, for the last few seconds. (depending on how long playback do you need) if only a few seconds i think array would be fine, but if you want to record the whole game you probably have to output to a log file or something, then replay the log in some way. I'm pretty sure it can be done.

hi
i just said it can not be done by recording every tick every position
there is alot of units (30 unit ) and with diffrent variables like health - type - attack{ower - attackSpeed - ...
so it can not be done with that.
the exact game must be replay with just recording inputs
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Thu Jul 21, 2016 9:11 pm

You wouldn't record every xy. That's useless information.
You would record the angle, and when it changed.
Array as a stack in a container for each object.
Along with the Timer behavior.
Image ImageImage
B
170
S
50
G
179
Posts: 8,378
Reputation: 113,425

Post » Thu Jul 21, 2016 9:21 pm

you dont neeed to record xy positions every tick. Maybe just once every 5 seconds for the last 30 seconds so you have a starting point for the playback every 5 seconds. From that startingpoint as @newt said you only raplay the commands. Mouse clicks, buttons presssed etc etc..
Follow my progress on Twitter
or in this thread Archer Devlog
B
41
S
18
G
18
Posts: 1,024
Reputation: 13,345

Post » Thu Jul 21, 2016 9:23 pm

Rex has a plugin that can help.

viewtopic.php?t=79821&start=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jul 21, 2016 9:26 pm

Every time you ask your units to do something. Record the action and what time that action happened. If the opponent is AI, u can record the AI commmands also. Something like that I would go about.
Follow my progress on Twitter
or in this thread Archer Devlog
B
41
S
18
G
18
Posts: 1,024
Reputation: 13,345

Post » Thu Jul 21, 2016 9:46 pm

tunepunk wrote:Every time you ask your units to do something. Record the action and what time that action happened. If the opponent is AI, u can record the AI commmands also. Something like that I would go about.

i have some actions wich do happens in every sec or less then that like every 0.1 (like shooting)
by time you mean tick or a custom every x secound time ?
i want my game do exact same thing and no matter what is timescale or framerate and i want to replay the game in the different speed and still exact same thing happens
B
16
S
6
Posts: 243
Reputation: 1,755

Post » Thu Jul 21, 2016 11:44 pm

Sorry, I can't give you a complete solution for your replay feature as it sound very complex, and I don't know how your game is built. Just gave you some ideas how I would try to do it. I'm sure you'll find a way, or Try the plugin that @99Instances2Go mentioned, maybe it can do the things you requested.
Follow my progress on Twitter
or in this thread Archer Devlog
B
41
S
18
G
18
Posts: 1,024
Reputation: 13,345

Post » Fri Jul 22, 2016 3:10 am

Replaying input would be hard to get exact. I mean you could save the time with the input used but as you said, a variable framerate would through it off.

You could change your logic to run a fixed number of times per second so input would only be handled at those times. Then to keep things smooth you'd interpolate object positions between logic steps. The pro is replays will be practically exactly the same, but the con is a huge invasive rewrite of your game. Probably too tedious to do since you also wouldn't be able to use behaviors since we can't control when they update.

The first idea you said won't work sounds better. It can be made to work with different types as well as with objects getting created and destroyed. The simplest way to save a frame would be to take an empty array and the for each of each object type, push it's name, its position and any other info. When that's do you can store it in another array by using array.asJson of the first array.

Loading a frame is then just a matter of taking one of those json strings, loading it into an array and looping over it and creating objects based on the saved name. Basically just recreating everything every frame.

To have it work with varying framerate or a different playback speed you'll need to save the time with the json of the frame, and then interpolate between the two closest frames.
An example is needed here to fully illustrate it. There are probably a few nuances I'm not thinking of.
B
94
S
33
G
113
Posts: 5,354
Reputation: 73,269

Next

Return to Construct 2 General

Who is online

Users browsing this forum: R0J0hound and 11 guests