Collision command doesn't actually collide

Blitz3D Forums/Blitz3D Programming/Collision command doesn't actually collide

WolRon(Posted 2003) [#1]
I seem to have a problem using the collisions command to stop projectiles when they collide with other objects. It appears that the projectiles don't stop AT the object but BEFORE the object less than X UNITS away. 'X UNITS' is whatever distance I tried to move the projectile during the last loop.

I am using the collisions command in this manner:
;entity types
;1 = Player
;2 = Walls
;3 = projectiles
;4 = targets

EntityType Player, 1
EntityType Wall, 2

Collisions 1, 2, 2, 2
Collisions 3, 4, 2, 1
Collisions 3, 2, 2, 1

later on...
EntityType bullet, 3

The bullet entities are created dynamically as they are fired. As you can see, I am using method 1 (stop) as the response when projectiles collide with the wall or targets.

Does anyone have any ideas why they would stop short? This isn't the impression that the docs gave me how it would work.


skidracer(Posted 2003) [#2]
Are you setting the EntityRadius of the bullet? This is the distance it should be stopping from the polygon it collides with.


Floyd(Posted 2003) [#3]
The EntityRadius command determines the size of the sphere, or ellipsoid, used for collisions.

Be sure to set this so that it is a good approximation to the actual size of the entity.


Jeremy Alessi(Posted 2003) [#4]
The collision detection will move the object back to it's last position before the collision occured so that it is not colliding. Collisions like this more or less stop things from going through one another. If the objects are moving slow enough the last position shouldn't be too far from the object it collided with.


skidracer(Posted 2003) [#5]
The collision detection will move the object back to it's last position before the collision occured so that it is not colliding.

This is not how the Stop behaviour should be working in Blitz.


WolRon(Posted 2003) [#6]
Well, I did forget to set the entityradius so I tried that but it doesn't seem to have changed anything. Any other ideas. I will continue messing with my code to see if I can figure it out.


WolRon(Posted 2003) [#7]
At the moment, I am just creating very low detailed spheres for the projectiles. Since they are created at a size of 1 unit, I am scaling them down to .1. Could this be a problem?


Jeremy Alessi(Posted 2003) [#8]
If you are using ScaleMesh() (try ScaleEntity) or if you are still using an EntityRadius() of 1 ... yes.


Uhfgood(Posted 2003) [#9]
This is the same problem I had with my 2d stuff... and the collisions are working correctly... You'll have to find a way to judge the distance between the two objects when the collision happens, and manually move it to sit "next to" the second object.

In my 2d stuff this involved me setting up dummy variables and testing a collision from the dummy variables before actually moving a sprite... then i would get the collision position and move it to there once it collided.


WolRon(Posted 2003) [#10]
I will post some images of the problem tonight when I get home from work.


Ross C(Posted 2003) [#11]
I agree with Ban. I've seen this type of behaviour with entity collisions.


WolRon(Posted 2003) [#12]
Here are 4 screenshots of the problem.
http://www.geocities.com/wolronweb/bullets.html?1065080474000

All of the shots were fired from the position I am standing in the first image. All of the projectiles are identical except that they are traveling at different velocities (There are several different kinds of shots that were fired, such as single shot or burst shots.)
The line of shots circled in red, blue, and yellow shows a line of rapid fire shots that were fired (at high velocity) from right to left in one continuous sweep. You can see that the part of the line that is circled in red is twice is far as the blue section and the blue section is that same distance from the one yellow bullet(which you can see stopped directly in front of me).
You can see from the third image that all of these shots stopped exactly the same distance from where I fired them (from the left in that image) instead of continuing into the wall.
You can also see in the second and third images that even the slower velocity shots still stop at incremental points.


Uhfgood(Posted 2003) [#13]
Interesting, it looks like you're doing bullet-to-bullet collisions... it looks like the "row" of bullets means that a bullet had collided with another one at the same position, and then of course it's set back to where it didn't collide...


skidracer(Posted 2003) [#14]
here's an example of how the stop collision should be working for you just to confirm behaviour is as documented:

Graphics3D 800,600

Collisions 2,1,2,1

light=CreateLight()
RotateEntity light,10,0,10

wall=CreateCube()
EntityType wall,1
PositionEntity wall,0,-2,0

ball=CreateSphere()
EntityType ball,2

cam=CreateCamera()
PositionEntity cam,0,1,-10

While Not KeyHit(1)
	t#=10-MouseY()/20.0
	PositionEntity ball,0,t,0
	UpdateWorld
	RenderWorld
	Flip
Wend

End



WolRon(Posted 2003) [#15]
Interesting note. I just added the 1.85 update and now the 'stop' collisions work perfectly as expected. Was this a 'bug' in 1.83?


skidracer(Posted 2003) [#16]
From versions.txt:

Fixed: a reasonably major collision bug that affected 'stop' response collisions.




WolRon(Posted 2003) [#17]
I tried your code skidracer and it works as expected, but this of course is after I just updated to 1.85 so I don't know what would have happened with 1.83.


WolRon(Posted 2003) [#18]
Quoted by Uhfgood:
Interesting, it looks like you're doing bullet-to-bullet collisions... it looks like the "row" of bullets means that a bullet had collided with another one at the same position, and then of course it's set back to where it didn't collide...
No, that's not at all what I was doing. I was firing the bullets at the wall while sweeping left. The bullets did not hit each other.


ChrML(Posted 2003) [#19]
UpdateWorld() updates the collisions, and should be done before RenderWorld() to keep it looks best for the camera.