Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Icey on Thu 17/03/2011 01:05:41

Title: control 2 characters with one mouse?[S]
Post by: Icey on Thu 17/03/2011 01:05:41
Is it possible to control 2 characters with one mouse?
Title: Re: control 2 characters with one mouse?
Post by: Eggie on Thu 17/03/2011 01:10:46
Yes.

There are plenty of different things that your question could mean but I am 100% sure that they are all possible.
Title: Re: control 2 characters with one mouse?
Post by: Icey on Thu 17/03/2011 01:30:55
So does anyone have any idea on how to do this?
Title: Re: control 2 characters with one mouse?
Post by: on Thu 17/03/2011 01:46:26
If you want to have two characters on the screen, and a mouse click on some location must move both of them, the simplest way is to make one character follow the other. There's a command for that.

And that answer actually was more precise than your question. What exactly do you want to do?
Title: Re: control 2 characters with one mouse?
Post by: Icey on Thu 17/03/2011 02:04:22
Well I didn't really want to say the main reason cause I thought no one would help me. However I will tell you.

I might be planing to make a stereoscopic 3d game again. I want to have one chr on one side of the screen mean while I want a different character on the other side of the screen with the same view. If I can figure out that I can start the game but until then I dont think so.
Title: Re: control 2 characters with one mouse?
Post by: on Thu 17/03/2011 02:16:07
Ah, okay then. One way (of many) would be to have a second character and change his position in repeatedly_execute, using the main character's position as
a reference:

cPlayer2.X = player.X+100;
cPlayer2.Y = player.Y;

That would "sync" the two characters, always keeping cPlayer2 100 pixels RIGHT of the player. If that is a solution you can use?
Title: Re: control 2 characters with one mouse?
Post by: Icey on Thu 17/03/2011 02:38:19
Thanks. Now when I start the game it should be real easy now that thats out of the way. :)
Title: Re: control 2 characters with one mouse?[S]
Post by: on Thu 17/03/2011 03:00:09
Always welcome!
Title: Re: control 2 characters with one mouse?[S]
Post by: zabnat on Thu 17/03/2011 20:49:37
Just a note, if your characters walk, you probably also want to "sync" the animation frames. You can do this by having identical loops on each character and then setting the frame and loop of the second character in the repeatedly_execute to match the first character.
Title: Re: control 2 characters with one mouse?[S]
Post by: Icey on Thu 17/03/2011 22:04:30
Ok, but how do I do that?
Title: Re: control 2 characters with one mouse?[S]
Post by: mode7 on Thu 17/03/2011 23:06:25
Well i could post that - but can't you look it up in the help file, like i have to do?

Frame property (character)
(Formerly known as character[].frame, which is now obsolete)

int Character.Frame

Gets/sets the character's current frame number. Usually you won't change this directly, but will use the Animate command to play an animation.
Example:

Display("EGO currently using frame %d.", cEgo.Frame);

displays EGO's current frame number within his view.

You'd have to make sure - both have the same loop and view
You can do that automatically with some coding

However...
You could just run all you normal animate and lock view functions twice for both characters and make the first one non blocking . could work too.