Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2015-08-04 10:56:39

MirceaKitsune
Member
From: Romania, Bucharest
Registered: 2015-08-03
Posts: 25

Inactive characters following the active character

I was wondering whether it's possible to have characters not controlled by the player follow the active character automatically. You know... like the way Tails follows Sonic around by himself. I know this is probably difficult, since an AI that can navigate the world like a player would be a lot of work, yet I'm wondering if this might be doable in some way that's easy and doesn't look bad. Any thoughts?

I think it gets a bit tedious to go through the same area 3 times for everyone to arrive at the same point. I also get the impression the other two characters are never active enough, like unless the level requires them they're sometimes just left at spawn.

Another idea is that if a character dies, you can continue with those left alive, and only lose and restart once all 3 are dead.

Offline

#2 2015-08-04 14:45:05

TheSeventhEmerald
Member
From: Spain
Registered: 2010-04-19
Posts: 302

Re: Inactive characters following the active character

Yay, looks like everybody is on holiday here. Meanwhile I'll answer some of your posts tongue

Well, nope, it's not possible to make the characters follow you. Take in account that, in a level, you can add the number of characters you want (one, two, three or even more). An efficient AI would be difficult to make. And take in account that you may customize the character with scripted moves and skills.

You don't need to navigate the area three times. There's an item which moves the characters to a certain location pressing a button. If in your level design you need a puzzle, put one of that teletransportators to move all the characters to that zone. And voila, you don't need to navigate the same zone three times.

And if you don't need the other two characters, simply configure the level to have the character you want. As easy as that.

The option you mention could be a problem since the level designer may have done the level with puzzle for a certain number of characters. If the player has less, the level may be unsolvable.


Piece of cake...!

Offline

#3 2015-08-04 19:50:40

MirceaKitsune
Member
From: Romania, Bucharest
Registered: 2015-08-03
Posts: 25

Re: Inactive characters following the active character

Like I said, I can imagine it would be difficult to do this properly. And in a sense, it's perhaps not needed so much anyway. I see that some levels use teleporters to bring your whole team to a given position, so that removes some of the monotony involving multiple characters.

Additionally: Is there a script function to automatically switch to a given character? Also one to disable the player switching characters?

Last edited by MirceaKitsune (2015-08-04 19:50:58)

Offline

#4 2015-08-10 04:05:57

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: Inactive characters following the active character

Some time ago we have designed an AI to make the inactive characters follow the player. See Follow the Leader.

As far as I remember, that script has broken once we redesigned the physics engine. Still, I believe it is possible to make it work again with some trial and error.

Offline

#5 2015-08-10 17:18:16

CarlosTheHedgehog
Member
From: Entre Rios, Argentina
Registered: 2015-08-10
Posts: 30

Re: Inactive characters following the active character

I have what you're looking for MirceaKitsune, if you want to pass an entire file, I did that served me well for my game

Last edited by CarlosTheHedgehog (2015-08-10 17:18:44)

Offline

#6 2015-08-11 17:03:22

MirceaKitsune
Member
From: Romania, Bucharest
Registered: 2015-08-03
Posts: 25

Re: Inactive characters following the active character

Thanks, that's good to know. Maybe the original AI script will be rewritten someday. If there is another one too I wouldn't mind knowing.

Offline

#7 2015-08-11 22:04:23

CarlosTheHedgehog
Member
From: Entre Rios, Argentina
Registered: 2015-08-10
Posts: 30

Re: Inactive characters following the active character

neglected, here's the script


object ".carlos_ai"
{
always_active
state "main"
{
hide
create_child ".carlos_ai_controller"
change_state "track"
}
state "track"
{
observe_player "Carlos"
let "$ _PLYPOS_carlosx = player_xpos ()"
let "$ _PLYPOS_carlosy = player_ypos ()"
}
}

object ".carlos_ai_controller"
{
always_active
state "main"
{
hide
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
on_timeout 0.1 "follow"
}
state "wait"
{
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
}
state "follow"
{
observe_active_player
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
on_timeout 0.1 "follow"
on_observed_player "Carlos" "main"
let "$ distance_x = player_xpos () - xpos ()"
let "$ distance_y = player_ypos () - ypos ()"
if "($ distance_x> 80) and ($ distance_y <-48)" "jump_right"
if "($ distance_x <-80) and ($ distance_y <-48)" "jump_left"
if "$ distance_x <-64" "follow_left"
if "$ distance_x> 64" "follow_right"
}
state "follow_left"
{
observe_player "Carlos"
simulate_button_down "left"
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
on_timeout .25 "follow"
}
state "follow_right"
{
observe_player "Carlos"
simulate_button_down "right"
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
on_timeout .25 "follow"
}
state "jump_left"
{
observe_player "Carlos"
simulate_button_down "left"
simulate_button_down "fire1"
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
on_timeout .5 "follow"
}
state "jump_right"
{
observe_player "Carlos"
simulate_button_down "right"
simulate_button_down "fire1"
set_absolute_position $ _PLYPOS_carlosx $ _PLYPOS_carlosy
on_timeout .5 "follow"
}
}

saw where it says the names "Carlos" in the script? Well, there you can change the character you want

example:

object ".sonic_ai"
{
always_active
state "main"
{
hide
create_child ".sonic_ai_controller"
change_state "track"
}
state "track"
{
observe_player "Sonic"
let "$ _PLYPOS_sonicx = player_xpos ()"
let "$ _PLYPOS_sonicy = player_ypos ()"
}
}

but if you use or have also command you, if you only use the ".sonic_ai_controller" will cause the character go right only

Last edited by CarlosTheHedgehog (2015-08-12 16:12:47)

Offline

#8 2015-08-13 21:11:03

aronthehedgehog
Member
From: Lincoln, NE
Registered: 2013-04-05
Posts: 390

Re: Inactive characters following the active character

Hmm... That is pretty cool.
---
I'd give credit to you for figuring something cool out like this, i'll also test with it.
(Compared to most people, i'd be considered a novice still.)

Last edited by aronthehedgehog (2015-09-24 14:25:24)


Not active much anymore.
The only things I do now is just let inspiration come to me when it's needed.
Also bad profile pic because I don't have anything else in mind.

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org