Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Knox on Sat 22/01/2011 18:54:31

Title: Module that permits swapping heads/clothes in animations?
Post by: Knox on Sat 22/01/2011 18:54:31
I was wondering if there was some sort of module (or if its even possible) to have layers on characters so an endless amount of variation is possible for faces, hair, clothes, etc...

With some help, Ive already got a nice system that already does that for my speech portraits ( which is pretty cool :) ), but Im realizing I would need this for the character's walking/running, picking up anims aswell (and any other anims of course).

Also, is this kind of thing "heavy", as in storing the variables, playing various animations at the same time, etc...is there a way to do it so that its 1 character for 3 layers: head, clothes and "props" (hat, glasses, facial hair)...
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: monkey0506 on Sat 22/01/2011 23:15:28
As I advised someone recently in a similar thread, you should be able to use Character.FollowCharacter with the FOLLOW_EXACTLY option. They said that function is not instant but I think they probably just had too low of an eagerness.

If you're going to have a lot of different customizable pieces probably the easiest thing to do then would be to make generic Characters for each piece..like cEgoHead, cEgoBody, etc. and then you can use cEgoHead.ChangeView(VEGOHAT) for example. It would save you having to track it all manually by just using what's already there.

Edit: Actually I was just double-checking the manual and the eagerness parameter gets treated more like a drawing z-order for the two Characters. So, this should work out nicely for you. I forgot to mention, though I did bring it up in the other thread, for this piecewise character building, you should have all of the sprites set to the same width and height as the maximum width and height of the largest possible combination, drawn relative to the same base. This means most of your sprites will have large transparent borders, but it makes alignment of the pieces much, much simpler. Theoretically anyway, since I haven't tested any of this yet. ;)
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: Knox on Sat 22/01/2011 23:29:28
Hmm, didnt think of that one! Ill try fiddling around with that then...Ill let you know of my progress!

thnxc :)
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: monkey0506 on Sat 22/01/2011 23:35:49
When I can get my hands on a copy of AGS I'd like to try and whip up a tech demo coz I think it wouldn't be difficult to pull this off..and definitely more practical for AGS 3.0+ due to no set limitations on Characters or loops per view.
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: Calin Leafshade on Sat 22/01/2011 23:49:48
I'd argue that a better system (and more easily portable between games) is to dynamically draw the character sprites at runtime on a single character.

Title: Re: Module that permits swapping heads/clothes in animations?
Post by: Ryan Timothy B on Sun 23/01/2011 00:07:56
I'm in the process of making my own character layering system. I'm using 2 characters per character only because I can't merge alpha channels without using Calin's plugin. And I don't really want a possibly commercial game to be using a possibly buggy plugin that I didn't write (no offense Calin :P).

What I'm basically doing is I have a dummy room and GUI for the setting up of the characters and their views, loops and frame. The dummy GUI has sliders for each View, Loop and Frame and I can select which one I want for the body or the head. I can then move the head around based on how it should be with each head and body frame.

Then it outputs it all into one big text file with numbers telling which View, Loop, Frame and character it was and the placement of the head. That script is mostly for backup since it's easily readable and can be appended to at any time.

Then it will create another text file (which I haven't done yet - but soon I hope) that will be in a readable form of AGS language that will be copied into a module's rep ex always.
Sure there may be a lot of script, but I'm really not sure which is a faster action to be done every cycle.
AGS reading through a bunch of script, AGS reading through an array, or worse AGS reading through an entire text file.

I could possibly unload it into an array at the start of the game, but then you have to worry about that text file being tampered with and the placement of the head being on the crotch of the body. lol Meh, I'll stick with the script way. I 'just' need to write it to output into a text file in the style of AGS code.
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: Calin Leafshade on Sun 23/01/2011 00:18:06
The plugin is open-source Ryan if you fancy dealing with any bugs that may exist.

The blending function of AGSBlend is like 20 lines.. There's not much there to bugbust.

Title: Re: Module that permits swapping heads/clothes in animations?
Post by: Knox on Sun 23/01/2011 00:28:21
 I personally have no problems with Calin's plugin...it works great so far!

I dont think Id be using the swapping much other then for background characters and the main player. Since the main player can be off-duty, and different stages of his life (teen, mid, and old), Id have way too many anims to do!

I think using like 2 characters (one for head, one for the clothes) is a good idea,but also Calin's suggestion to draw it on directly is also cool...too bad we cant put buttons on characters, that way I could just update the button's view + loop!

Maybe a stupid question: Is this something that we can do, add "buttons" to characters in the editor?
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: monkey0506 on Sun 23/01/2011 04:07:42
Regarding your suggestion Calin, are you referring to the DynamicSprite/DrawingSurface functions, or a runtime plugin? Coz the built-in functions are actually rather slow for things like that..so using multiple characters in that case would seem to me the better option.
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: Calin Leafshade on Sun 23/01/2011 14:23:54
Yes ~I'm referring to those functions and they arent really as slow as everyone says. They are perfectly acceptable for simple character manipulation. Especially at low res.
Title: Re: Module that permits swapping heads/clothes in animations?
Post by: monkey0506 on Sun 23/01/2011 15:43:47
Depending on the implementation it would probably be fine for one or two characters..on my system. Most modern systems probably wouldn't have any issues with it, but my personal system is quite slow. That's what you when you're reliant on a computer that your roommate gave you for free though. :P

I've used the DrawingSurface functions for things like the SparkleMotion module and a tech demo I did of dynamic rain droplets at varying transparencies..

The entire thing would probably be somewhat expedited if the sprites were cached. Something to keep in mind with that though would be that the loops in the player character's view would have to have exactly the same number of frames as the most frames required by any of the individual pieces since loops can't be dynamically modified by adding or removing frames.

Then you could create an array out of the DynamicSprites and assign the sprites to the appropriate ViewFrames..you'd just have to rebuild the cache of sprites any time any of the costume pieces were changed.