Game Development Community

Animated Building Construction?

by Scott Johnson · in Torque Game Engine · 10/11/2007 (5:09 pm) · 8 replies

I'm having a hard time figuring out how to describe this...

To be implemented in TGE 1.5.2

How might one go about creating a building that constructs over time...
This would be similar to what RTS games do once a building is placed, and it starts construction.
It goes through several phases (animations) of building before being "complete"

The general idea would be to have the player "place" a new building, and overtime it would construct.

I had some ideas, but not sure how to best approach this.

The buildings would not be "enterable" in the sense that difs wouldn't be necessary.
(Although it would be pretty cool)

Therefore I figure using .dts would be the way to go.

I know how to create .dts files, but just static ones atm.

Sorry for the poor description, but hopefully this will elicit some ideas!

Thanks for any input.

#1
10/11/2007 (7:13 pm)
Well, for starters, you would need to have code in TGE, to do what your asking , and probably would be as simple as transfering the RTS code into the TGE code and then debugging it for your specific uses. As far as animated DTS you should be able to follow the art links and create something similar to a player model. as for the growing over time, there is a code for it. just not sure were.
#2
10/11/2007 (8:09 pm)
Hmm.. I didn't realize the RTS Pack (I assume that's your reference) contains this type of construction animation.

I'm certainly not against coding, however, as I searched through the forums, I didn't see anything that I could adapt to the idea.

A thought came to mind though, with the ability to animate dts shapes, can portions of the dts animation be invisible until a certain point?

For example:

First animation sequence shows a foundation being built.
Second sequence the walls (having the walls fade in smoothly)..
Last sequence is the roof fading in, and the complete building as the last and final frame.

Thanks for the feedback Edward!
#3
10/11/2007 (8:15 pm)
@Scott--absolutely (it's called visibility animation), and in fact the "World Domination through Collaboration" mod on TDN (requires the RTS-SK to run) does this on a couple of the buildings--reaching way deep back in my memory, the "factory" building has a single stage animation that plays after the building has been placed.

You could have multiple animations, including certain portions kept invisible until the sequence is triggered, to simulate the "over time" aspect you are describing.

It's important to stress however that this is a simulation of the concept--the building itself is a single dts. You could also of course rather easily just have multiple dts's of a single building in various stages of construction, and replace them in sequence over time, to give a true set of time based "upgrades" to the building as it constructs.
#4
10/11/2007 (8:19 pm)
It sounds like you want the player to be able to do something like in the old SimCity games: click on the city block where the player wants to build a school or an airport, and then watch (if he/she wants) as the school or airport gets constructed in stages.

Since you're not planning to have the player interact with the building once it's completed, you have made the problem much simpler.

What you want to do is create all the construction stages of the building in Max or Maya or MilkShape. (That may be harder than writing the TorqueScript to make it work in game.) Make sure they're all the same scale and have the same footprint. Then, when the player chooses where to "place" the building, your game will spawn all the construction stages there at once, right on top of (er, in the middle of) each other. The trick is that you make all of the stages except the first one invisible (using something like house1.setVisible(false) ), and then use schedule to fade out house1 and fade in house2 at some time in the future. Then house2 fades into house3, and so on.

To fully duplicate the SimCity feel, after the building is completed, you can use schedule to cycle through 2 or 3 subtly different frames, like a radio tower with a blinking red light on top, to give the impression of an "animated" building.

p.s. Actually, to fully duplicate the SimCity feel, you can have the airport spawn an airplane, which then crashes into the arcology your player foolishly placed right next to the airport.

p.p.s. Did I actually call SimCity "old"? Wow.

EDIT: In the time it took for me to compose that reply, Stephen Zepp said the same thing. Cosmic.
#5
10/11/2007 (8:30 pm)
@Ray: hehe..I have to admit, I had an advantage: I did exactly what he described, in script, with the RTS-SK several years ago (before I was an employee).

I had my artist provide 4 versions of a building, showing different stages of construction, and simply set up a server side schedule to replace each version with the next "upgrade" until the sequence was complete. I then had a fully functional RTS building (buy units, collect resources, etc.) to operate with.
#6
10/11/2007 (9:22 pm)
This is exactly what I was interested in!

@Stephen, thanks for the "visibility animation" hint, I'll be pluggin that into the search box! I'll be looking up that mod as well. Thanks for taking the time to post about this!

@Ray, I agree that modelling the buildings will take much longer than the coding, especially since I'm much more of a programmer than artist, however I'm expanding my horizons of late. I'll be starting off with some very simplistic .dts's to explore this idea more.

I think that using some sort of simple state machine would be a good way to track the different "build states", which would allow for transitions to be more flexible, in case say a building was damaged during construction.

Interestingly, after the mentions of schedule, I had just (yesterday) implemented the "Ice Man's" MessageRouting system, this would be a good way to pulse the state mechanisms to do the transitions.

I believe that I have a good basis to start the experimenting...

Thanks to Both of you for some great advice!

And just for the record I played SimCity on the Commodore 64... and I still don't feel OLD...
#7
10/11/2007 (10:16 pm)
Instead of 'n' different meshes, 1 with hidden mesh parts (mesh substitution) could do the trick as well I guess.
#8
10/12/2007 (3:47 am)
To see how to do visibility animation like what Stephen Zepp is describing look here

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=6750

It's not a building shape, but the visibility animation bit would be the same.

Robert