Collision Bug?

Blitz3D Forums/Blitz3D Programming/Collision Bug?

NTense(Posted 2003) [#1]
I have encountered the bug from hell...... or at least, the bug that's driving me nuts today. I'm getting a "Memory Access Violation" with my debug turned on :/ (screenie)... It seems to occur on a collision check between a player and a powerUp. The thing is, it seems to be consistently random (if that makes any sense). Meaning that sometimes it occurs within the first 30 seconds of the game and other times it occurs after playing for 15 minutes.. Regardless, I'm not quite sure what's causing it. The game is deathmatch style, so the players and the powerups respawn. Could a player respawning ontop of a powerup cause this? I would have assumed the program would just run the code asif the player picked up the powerup. Anyway, I'm a little stumped, and wondered if anyone else has experienced anything similar (possibly with a solution?).


skidracer(Posted 2003) [#2]
If PowerUp_Col is a constant (and in the range 0..999) then it is most likely Player\Ostrich\ObjectHandle is an illegal handle and causing the exception.

I don't know what you mean by respawning but if it involves deleting and creating entities then you need to maybe explain what stages you go through in this logic. If you are deleting the entity then i advise setting Player\Ostrich\ObjectHandle to zero at this point and then just before you call EntityCollided do something like
If Player\Ostrich\ObjectHandle=0 RuntimeError("lost player ostrich error")

or some such which might help you to pinpoint problem further.


NTense(Posted 2003) [#3]
By Respawning, I'm Hiding the player(when they die) from the battle and/or Hiding the PowerUP when it is collided with. Then, after a given amount of time, the player is "respawned", ie placed in a random position on the game board, and Unhidden. In a like manner, the PowerUp is shown again after a given amount of time (though it stays in one position). I'm not deleting them and recreating them, just hiding and reshowing (though doing some repositioning)...

I just had a thought though. Should I be resetting the collisions everysingle time one occurs? If so, I don't think I'm doing that. Maybe there's a "value out of range" type of problem going on (with respect to collision counts)? I don't know. Just kinda thinking out loud now.


DH(Posted 2003) [#4]
Wow, i didnt know there were still people who used the Blitz IDE...


Bot Builder(Posted 2003) [#5]
huh? who doesn't use the blitz IDE? I know there's others, but Blitz has an integrated help system and it's stable, unlike some other editers. Perhaps I just missed a good editer everyones using?


Litobyte(Posted 2003) [#6]
UltraEdit 10.x


NTense(Posted 2003) [#7]
Hmm.. I am truly stumped.. I've made sure to reset all collisions once they occur, Made sure that there is no NULL Player\Object that it's checking collisions against, and I've made sure that none of the objects are respawning on top of one another. But still I get the Memory Access Violation Error. It's just so inconsistent (from a timing stand point) because you can play for a while and pick up the powerup with no problem, and My player is never the one triggering the error. It's always one of the bots. I'm not quite sure what to do.


NTense(Posted 2003) [#8]
OK, this is odd.. I took the PowerUps completely out of the game, and then after playing for about 15 minutes got the error again. ?!?! This doesn't make sense. There was nothing to collide to, and I've insured that Player\Ostrich\ObjectHandle does in fact exist, yet I got the Memory Access Violation on the Collision Check between the player and the PowerUps (which weren't even in the game). Could this be a bug internal to Blitz maybe?


John Blackledge(Posted 2003) [#9]
NTense, I got this one, and as you say, removed everything that I could to track it down.
In the end it turned out that I was using MoveEntity instead of TranslateEntity in order to implement gravity for my characters (didn't know there was a difference particularly) but Blitz just seemed to crash out after maybe 1 minute. I couldn't believe it when I tracked it down to that particular line of code, then changed it, and now no problem.
This may not be your problem, but worth checking that all repetitive collisions, like gravity, use TranslateEntity.


NTense(Posted 2003) [#10]
Hmm.. I am using MoveEntity on almost all of the moving objects in the game.. I'll play with it and see what comes of it.


NTense(Posted 2003) [#11]
Nope, that is not it. In fact, I got the collision error within the first ten seconds of running the test. :-(

Man, this sucks.. I had my hopes up a bit John ;-) .

This is a real stumper.. (is that a word??)


John Blackledge(Posted 2003) [#12]
Just to be clear about this, my problem was continuous collisions of my characters with the terrain using MoveEntity, which seemed to produce a cumulative build up of collisions which were not cleared until it crashed. When I changed all continuous collisions with the terrain to be handled by TranslateEntity (as per Mark's Castle Demo) then everything was fine. Otherwise, for forward movement I use MoveEntity or PositionEntity as usual.


NTense(Posted 2003) [#13]
Well, I've abandoned all hope on getting Blitz's collision to quit crashing, and wrote my own collision function which seems to work well. Back to work'n on the game dev! Thanks for your help guys.