Damage to Objects in Torque 3D
by Max vE · in Torque 3D Professional · 03/22/2014 (4:39 pm) · 5 replies
Ok so I have a question about doing damage to objects and such in Torque 3d. I've been trying for weeks to get stuff to work in my game but it just won't, and can't seem to find the answers online.
Let's say I have an object, like a tree, in my scene. I make that tree a StaticShape so that I can interact with it. How exactly would I go about doing damage to the tree with projectiles, and after it reaches max damage, it deletes? I can't find any info on giving an object health and then doing damage to it anywhere. I made a StaticShapeData Datablock with things such as the filepath to the object, the max damage and so forth. I then created a script in the scripts/server location. I'm not sure what callbacks and such would be needed in this script file in order to have projectiles damage the tree, and eventually have it reach max damage and delete., so any help would be greatly appreciated. Also, if you can, please don't restrict your answer to just a situation about a tree. I'd like to be able to fully understand what's involved. Basically just how does damage in Torque 3D work overall.
Bonus question: How would I get the tree to be damaged by a certain projectile only? I'm not really sure what I'm doing, but let's say I want the tree to be cut down. How would I get the tree to be damaged only when a player is wielding an axe? I'm not sure how do do melee so the axe will just fire a custom projectile a very short distance.
Thanks.
Let's say I have an object, like a tree, in my scene. I make that tree a StaticShape so that I can interact with it. How exactly would I go about doing damage to the tree with projectiles, and after it reaches max damage, it deletes? I can't find any info on giving an object health and then doing damage to it anywhere. I made a StaticShapeData Datablock with things such as the filepath to the object, the max damage and so forth. I then created a script in the scripts/server location. I'm not sure what callbacks and such would be needed in this script file in order to have projectiles damage the tree, and eventually have it reach max damage and delete., so any help would be greatly appreciated. Also, if you can, please don't restrict your answer to just a situation about a tree. I'd like to be able to fully understand what's involved. Basically just how does damage in Torque 3D work overall.
Bonus question: How would I get the tree to be damaged by a certain projectile only? I'm not really sure what I'm doing, but let's say I want the tree to be cut down. How would I get the tree to be damaged only when a player is wielding an axe? I'm not sure how do do melee so the axe will just fire a custom projectile a very short distance.
Thanks.
About the author
#2
there are a couple of resources that will just give you what you need.
Damage and Destruction by Michael hall
www.garagegames.com/community/resources/view/20937
and if you should plan to use physX
www.garagegames.com/products/torque-3d/documentation
Now there is no way around reading and trying stuff on your own,
if you should have problems getting things done, am sure someone will have a answer.
03/22/2014 (7:10 pm)
Wellthere are a couple of resources that will just give you what you need.
Damage and Destruction by Michael hall
www.garagegames.com/community/resources/view/20937
and if you should plan to use physX
www.garagegames.com/products/torque-3d/documentation
Now there is no way around reading and trying stuff on your own,
if you should have problems getting things done, am sure someone will have a answer.
#3
docs.garagegames.com/torque-3d/official/content/documentation/Artist%20Guide/Tut...
03/23/2014 (7:44 am)
and of course... the docs will always help too...docs.garagegames.com/torque-3d/official/content/documentation/Artist%20Guide/Tut...
#4
@J0linar Thanks for those links. I think I must've just skim read over that first one by Michael Hall when I first started, and assumed that because I had already gone through it before, that it wouldn't have answers to my current problem. No idea what I was thinking there.
@Ron Thanks for that link also. I've already read through that one, but that goes for a slightly different effect. I'll probably re-read it to see if I can get parts of it to apply to me. (Also, big fan of your art packs haha)
So yeah, thanks everyone. If I came off as someone who hadn't done any research, sorry about that. I thought I had looked through most stuff, turns out I just needed to do some re-reading.
03/23/2014 (11:34 pm)
@Tim Yeah that's basically what I've been doing, but I guess I must've messed up somewhere along the line haha.@J0linar Thanks for those links. I think I must've just skim read over that first one by Michael Hall when I first started, and assumed that because I had already gone through it before, that it wouldn't have answers to my current problem. No idea what I was thinking there.
@Ron Thanks for that link also. I've already read through that one, but that goes for a slightly different effect. I'll probably re-read it to see if I can get parts of it to apply to me. (Also, big fan of your art packs haha)
So yeah, thanks everyone. If I came off as someone who hadn't done any research, sorry about that. I thought I had looked through most stuff, turns out I just needed to do some re-reading.
#5
03/30/2014 (9:17 pm)
Are you using the Full script template? It should already have functions for damaging objects. Though I think running through Mike Hall's tutorials is probably the best idea, they give you a great overview of how to do interesting stuff with scripts. Learning!
Associate Tim Newell
Max Gaming Technologies