How to create a playing session of your game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By genete
:warning: Old Version Published before Godot 3 was released.

I have one in progress arcade style game. The game starts with a main screen that shows the game name etc. After a while changes the scene to a how to play screen. Later it shows a playing session (a playing session is exactly the same like if one player were playing one actual game but there is not a human interacting). Then after a while returns to the main screen and repeat in loop the three screens. Only when player press the start button the game commences.

My problem is that don’t know how to board the playing session. I could imagine some alternatives:

  1. Create one animation with the objects. It should be one animation per playing session and I want to have at last 5.
  2. Record one playing session in a video and simply show the video.
  3. Create one AI for the player and try to survive the level for a few seconds. This would allow to show different playing sessions each time.

Do you have any other way to perform a playing session of your finished game?

:bust_in_silhouette: Reply From: Warlaan

I would recommend using animations, but you don’t need to animate the position, rotation etc. of the characters. Instead you can create an animation track with function calls (“Add Call Func Track”).
So you just need to call the right functions on your character at the right time. In order to find out what to call when I would simply add logging to the functions that move the player that write to the log when which method was called with which parameters.

Of course that only works when your player code is written so cleanly that you have just a few clean high-level functions like jump() or move() rather than an update-method that is called every frame, checks which button is pressed and directly applies changes to the character.

Basically that’s how replays or network code would work.

Great idea. I didn’t know that function calls could be included in animations. For those like me that didn’t know that. Here is a little how to:

  1. When editing the animation, press the white ‘+’ button it would offer “Add Normal Track”, “Add Transform Track” and “Add Call Func Trak”. Select the last one.
  2. It would insert a new (empty) track that has lemon color in the dot. Rename the track by double clicking it.
  3. To insert a key press the little green ‘+’ button of the track, on the right.
  4. Now you can edit individual key values by pressing the icon with a dot and a stylus pointing to it.

genete | 2016-06-22 16:29

Oh! Why don’t preserve the player movements in an animation resource directly instead of write it to a log?

I could modify the code to play in recording mode so each function call for movement could be stored directly in an animation resource.

Hmmm, unfortunately there is not a method_track_insert_key function member in the Animation Resource class.

genete | 2016-06-22 16:38

Great idea right back to you, I didn’t think that it would be so easy to use an animation resource for that.
It looks like you can use track_insert_key() for call func tracks, since you specify the type of track when you create it. Unfortunately there doesn’t seem to be a possibility to specify the arg count and the argument values.

Warlaan | 2016-06-22 17:18