Game Development Community

Destructable Tress, how should i do it?

by Jordan Fye · in Torque 3D Professional · 02/09/2012 (9:43 pm) · 8 replies

Hey guys,
Its been about a year or so since I've used torque.

Anyway, I'm prototyping a new game and I need destructable trees.
There will be tons of destructables actually. Im just focusing on the trees first.
So im trying to get it where you can cut down a tree with an axe. Different speeds for different axes. Then i want the tree to actually fall, maybe physx? The thing i was wondering, I want to be able to pick up the tree afterwards. Maybe create a trigger that destroys mesh and adds it to the inventory? Think harvest moon or something.
So would I be better off going with physx or just 2 or 3 step destructables? I want to have it where you can build stuff with the logs. I think physx is a little too much for my game.I really dont know where to start, so i figured I would ask.
So im looking for,
Inventory,
Destructables,
Placing objects in game.

I dont want to start with something and then realize it wont work, so i figured i would ask the pros for advice before i waste precious time haha,
Thanks

About the author

Today ill work on the art portion of my game... Well what about this script... Oh this youtube video is hilarious... todays progress 0%


#1
02/09/2012 (10:09 pm)
Depending on how realistic the destruction needs to be, I'd probably go with a combination of things:

- For the trees I'd model them with multiple "phases" to represent how much they've been chopped. Each tree.dts (or tree.dae) file would contain several versions of the tree at different stages of "death". Then I'd use the setMeshHidden() method to show/hide each submesh accordingly.

I'd animate one of the stages (the last one, I suppose) showing the tree falling down.

Also, I'd setup a few particle emitters to spawn appropriate debris while the player is hacking away at my poor foliage.

- For carrying the logs, I'd create a ShapeBaseImage with an appropriate log mesh and mount that to the player when they want to pick up the bloodied remains of Mr. Tree. Picking up a log would also call a function that hides the actual tree mesh in order to give the illusion that the player has really picked it up.
#2
02/09/2012 (10:16 pm)
that is awesome, thank you. Great ideas!
makes it easier for me. I i was thinking physx, just wasnt sure, because i dont know about picking up physx objects.
but you really canged my mind, your way sounds way better.
Is there any good tutorials on showing the stages of the tree in game?
Im an artist, not a programmer. After multiple years of torque i am still a newb hah.

What im doing is making a low poly game. Say like old n64 cartoony style. and im going to have a game where you can gather stuff and build houses, kind of like the sims but with an rpg setting.
Its not going to really be a game. Just implement a whole bunch of stuff for a good portfolio demo.
Im really looking at short range invisible projectiles for the axe. MAYBE raycasting. but i tried raycasting a few years back and could never get it to work.

#3
02/09/2012 (10:49 pm)
For hiding/showing the tree "submeshes" you'd use setMeshHidden().

Let's say you have a tree.dts (or tree.dae) file with five "submeshes" in it named:
"Tree_100" - represents the tree at 100%
"Tree_75" - represents the tree at 75%
"Tree_50" - represents the tree at 50% (maybe a big gap in the tree trunk)
"Tree_25" - represents the tree at 25% (nearly there, probably leaning a bit or something)
"Tree_0" - represent the tree at 0% (felled, also has an animation to show it falling)

To show, say, the tree at 50%, you'd call <SomeTreeId>.setMeshHidden("Tree_50", false);

You'd also want to hide the other submeshes and you'd use setMeshHidden() for that as well.
#4
02/09/2012 (10:54 pm)
great starting point! thanks for the help!
#5
02/10/2012 (3:48 am)
All Shapebase objects have the following DamageStates by default: Enabled, Disabled, and Destroyed. These can be transitioned with animations (if you use the appropriately named visibility animations or sequences) during an onDamage() callback. Adding particle effects for wood chips, etc, is easily done when applying damage. Using mesh-hiding during these states is extra icing on the cake. Once fully damaged you can use a debrisObject to simulate the fall of the chopped tree and an Explosion object for the burst of leaves, birds, small animals, etc. Once the DebrisObject comes to rest you can replace it with a PhysicsShape or RigidShape object to be your usable and movable log. Simple scripting will allow you to pull or push, or even roll the logs when a player walks into them.
#6
02/10/2012 (6:16 am)
Hell ... I was even planning on doing anything like this and now I have learnt something on this thread now as well. 8-}

"Simple scripting will allow you to pull or push, or even roll the logs when a player walks into them." <-- Can you imagine the poor RTS style players ... my PEON keeps kicking the logs around and not picking them up ... lolz.
#7
02/10/2012 (7:06 am)
As long as he can kick them back town and into the mill so we can use the wood....
#8
02/10/2012 (8:07 am)
The 'simple scripting' that I had in mind works for RigidShapes so I assume that something similar would work for the PhysicsShapes as well -- I never actually played around with the physX demos much -- yet I've never actually tried rolling a log (cylinder) in Torque, only spheres and cubes. Probably be my luck it rolled end over end...