find colliding slice (parent, slice, number, check descendants)
Parent is a slice. Preferably a slice with a lot of children. FindColliding Slice is going to go through all those children and see if any of the slices are colliding with Slice which is naturally also a slice.
Number is an optional argument, meaning you don't have to put it in if you don't want. It's possible that multiple slices are colliding with slice, and that you might want to specify which one. According to the dictionary, FindCollidingSlice will return 0 (or false) of Number is higher than the actual number of children who Slice is colliding with. You can also put GetCount for number, and it will tell you how many children of Parent are collidng with Slice.
CheckDescendants is also an optional argument. It tells whether or not the script should check only Parent's immediate children, or if it should check the children of those children too. Its default value is true, so it will check the Children, Grand-Children, Great-Grandchildren etc. of Parent. If it's false, it will only check the direct children of Parent.
So how does it work?
Let's say I'm making a shooting game. I've got a container slice of enemies and a bullet.
Code: Select all
Enemies 01
Dog 02
Dog 03
Dog 04
Hydra 05
Head 06
Head 07
Head 08
Dog 09
Bullet 10
I could do...
Code: Select all
variable (SomebodyShot?)
setvariable (SomebodyShot?,FindCollidingSlice (Enemies,Bullet,0,False))
ShowValue (SomebodyShot?)
Note that it would never display 06, 07, or 08 because those slices are *NOT* direct descendants of Enemy: They're children of Hydra. To be able to target the heads, you'd switch False to True. You might still hit the body of the Hydra first, which is why you'd want GetCount and changing the 0 to different values to choose which colliding slice to deal with. There's clever ways to cycle through that and hit ALL of the slices you're colliding with.