Game Development Community

Cutting grass with a sword

by Dylan West · in Technical Issues · 08/11/2008 (9:57 am) · 7 replies

How do you make it so that swinging your sword into grass made by a foliageReplicator actually cuts the grass? Is there a way to specify two different image files in the replicator? One for the uncut version and one for the cut version? Or would I have to specify that via a datablock and associate the datablock with the replicator somehow?

Does anyone know?

Thanks.

#1
08/11/2008 (10:25 am)
For items like that, you would have to either create a new DTS object, or make some significany alterations to fxfoliagerplicator, or fxshape replicator. You might makea fxCuttingfoliagereplicator. Its a task for a programmer definitly.
#2
08/12/2008 (5:31 am)
I think I'll try to alter the foliage replicator because I'll pull my hair out if I have to manually plant every little grass billboard in my game by hand just to make it all cuttable!

Does anyone know if there is already some resource out there that takes care of this?


**Dylan flashes the Melv signal into the Gotham City night sky**
Melv, If you are reading this, since you understand the replicator code better than anyone else, could you lend me a hand with this new fxCuttingfoliagereplicator?
#3
08/12/2008 (2:46 pm)
Looking at the replicator code, it does have a bounding box. You could probably write a function in your sward script to check if what the sword hit was the fx replicator bounding box and replace the replicated texture to a cut grass texture.
#4
08/13/2008 (5:25 am)
You nailed the two issues I'm not sure how to approach yet.

1. I don't know how to tell one particular fxFoliageItem from among the entire set of fxFoliageItems how to swap textures. It seems to me that I'm stuck making all the items all one texture. (at least the way it is organized right now)

2. I'm not sure how to sense the collisions b/n the sword and the grass. Should I create an onCollision function in fxFoliageReplicator.cc for that?

I'm not even sure if I can do this in the fxFoliageReplicator class or if I really need to create a new class for the cut grass.

This is the first time I've ever tried to make my own custom changes to the game engine code beyond just implementing the resources other people have created, so I will take all the help I can get.
Thanks.
#5
08/13/2008 (4:10 pm)
Figureing out which foiliage you are chopping at is the easy part.
1. Place your grass and Name it in the inspector.
2. nameToId will transfer the Name you gave your grass to it's id for use.
You would have to make a function that runs thru all your grass names to find out which one you are chopping at, then, just make that replicator invisable and another one with cut grass visable. (make it using the tall grass block and set it as invisable)

For the second part, The actuall collisions, I don't know how to do that yet. It should work without changing the replicator code as there is already a bounding box that you could check thru script to see if the sword hit it.
Wish I could be more help, but I'm not that good at TS yet.
#6
08/13/2008 (7:23 pm)
Actually, I'm talking about cutting a small patch of grass from one very large foliage replicator. For that issue, I won't be able to use the method you mentioned because I want to cut away just a small part of one replicator, not an entire, small replicator.
#7
08/13/2008 (7:59 pm)
The replicator won't work then, as it just places "ghosts" of 1 patch. You would have to place your grass in individule clumps. Aside from that, ( a pita I know) I have no idea how you would do it.