collision

Blitz3D Forums/Blitz3D Beginners Area/collision

Gord(Posted 2005) [#1]
I have a character in my game who is knocked over when the camera collides with it ( using Entitydistance. The character must only fall the third time it collides. I have tried several ways to do this but without succes. Anyone got a code fragment that works? I can get the character to fall the first time it is hit but not after 3 hits.


Crazy4Code(Posted 2005) [#2]
Make a variable that goes up one each time the camera collides with the character:

Global hits = 0

If EntityDistance(camera,character) < hitdistance
hits = hits + 1
If hits = 3
;The code to knock over the character goes here, animate or whatever you do
hits = 0 ;So the count restarts
End If
End If


jfk EO-11110(Posted 2005) [#3]
But you also need to reposition the character away from the camera if they "collide".

Alternatively you can use a flipflop variable, so the hits counter will be frozen after a collision until they don't "collide" any longer.

The first approach is more proof


Gord(Posted 2005) [#4]
Thaks, I tried the hit routine st first but the hits reached 3 before I could withdraw the camera the first time in order to strike again.


Crazy4Code(Posted 2005) [#5]
Oh yea, I didn't think about moving the character away.