I wrote up what I think to be a simple collision test to see if my slice collision works. It looks like so:
Code:
script, checkCollisions, begin
if (SliceCollide (sli:Hitbox1, sli: Bullet1)) then (
DestroyNPC (0)
)
end
script, checkCollisions, begin
if (SliceCollide (sli:Hitbox1, sli: Bullet1)) then (
DestroyNPC (0)
)
end
This script is called in my autorun script. When I try to run this in game it gives the error:
Invalid slice handle 261
These slices do exist in my slice collections, so why the error? They have also been exported to an HSI included in my script to clarify things.
EDIT:
I have just updated my script to this. It got rid of the error but still no collision is recognized since the NPC is not being destroyed... Any ideas why? I'm positive these slices are making contact.
Code:
script, checkCollisions, begin
if (slice is valid(sli:Hitbox1) && slice is valid(sli:Bullet1)) then(
if (slice collide (sli:Hitbox1, sli:Bullet1)) then(
free slice (sli:Hitbox1)
free slice (sli:Bullet1)
DestroyNPC (0)
)
)
end
if (slice is valid(sli:Hitbox1) && slice is valid(sli:Bullet1)) then(
if (slice collide (sli:Hitbox1, sli:Bullet1)) then(
free slice (sli:Hitbox1)
free slice (sli:Bullet1)
DestroyNPC (0)
)
)
end
EDIT #2:
After further realizing that Gizmog and Urkel were discussing something like this earlier I have further revised my code to use handles rather than slices as I made this similar mistake. Still though I am having trouble with getting the code to work. Here's the latest revision of the code:
Code:
script, checkCollisions, begin
if (slice is valid(sli:Hitbox1) && slice is valid(sli:Bullet1)) then(
if (slice collide (LookUpSlice (sli:Hitbox1), LookUpSlice (sli:Bullet1)) == true) then(
destroy NPC (0)
play sound (4, false, true)
)
)
end
if (slice is valid(sli:Hitbox1) && slice is valid(sli:Bullet1)) then(
if (slice collide (LookUpSlice (sli:Hitbox1), LookUpSlice (sli:Bullet1)) == true) then(
destroy NPC (0)
play sound (4, false, true)
)
)
end
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases



