First time to start making a forum topic here but I’m not sure which categories I should going into but I was still working on my Sonic-inspired platformer game here and got a little question.
I really want to try to implement with sidekick character similar to having Tails in Sonic 2 game, but can it be possible to adding this in Godot? How will I implement a sidekick character for my platformer game project and is there any proper code to it that will work? Does it also works on both Godot 3 or 4 versions? Apologize for some of my grammar issue while making this topic.
Theres a Sonic godot project somewhere if you google it. I might be wrong but there should be a Tails AI in it. Pretty sure they do the same thing in that. Then I assume there’s just a different state for Tails to fly and follow you if he’s respawned and trying to relocate to your position.
You can make your NPC use the same code / component that your player used for movement, but instead of controlling the NPC directly with keyboard or controller inputs, you listen to those inputs, store them, and with a small delay, you “play” those inputs back and translate them to movement, jumps, actions etc.
Having played Sonic 2, I don’t think they do just replay input. Tails does seem to have some sort of AI to allow it to “follow” Sonic but also keep a distance. Moreover, pretty often Tails would get stuck and would respawn and fly to Sonic. I suspect they have some basic pathfinding there and when out of screen, if it cannot find a path, it will give up and respawn.
FYI, I’ve had something in mind for a while and I did a few tests to different levels of success by combining raycasts and the navigation server.
If you just want to record/replay, that should be relatively easy. I explored a very simple solution in my jam project here: The Last Turtle by Josep Valls, Candlehearth Productions
The “friend” (you need to rescue it by chewing on the cable), will record the position of the player at certain intervals and when the distance goes above some threshold starts following the waypoints. In this case its pretty easy since they are “floating” so there is no jumping needed and there is no real pathfinding.