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.
collision
Blitz3D Forums/Blitz3D Beginners Area/collision 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
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
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
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
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.
Oh yea, I didn't think about moving the character away.