Collisions.. again :(

Blitz3D Forums/Blitz3D Programming/Collisions.. again :(

NTense(Posted 2003) [#1]
hmm.. It seems there are a lot of collision questions on the board. I thought that I was doing well with them until just recently, I've hit a stumbling block (heh.. surprise). Here's what's going on. My 'Terrain to Bullet' collisions work great, my 'Bullet to Player' Collisions work fine, my 'Player to Player' collisions are fine. BUT.... I tried to put powerups in my game (simple rotating textured cubes that the player can run into to get health/armor/goodies etc..), and it's not running my collision code. I'm getting the sliding effect, but if you look at my implementation code at the bottom, it's not hitting the stop I put in place, nor is it hiding the power-up after the collision. My player just slides around the powerup, with no action happening in the code.

Here's what I've got:

Here's my initial declarations:
; Collision Types
Const Terrain_Col 	= 1
Const Bullet_Col 	= 2
Const Rider_Col		= 3
Const Ostrich_Col	= 4
Const PowerUP_Col	= 5


... and here's my initialization for the collisions:
Collisions Bullet_Col, Terrain_Col, 2, 1
Collisions Bullet_Col, Rider_Col, 2, 1
Collisions Bullet_Col, Ostrich_Col, 1, 1
Collisions Ostrich_Col, Ostrich_Col, 1, 2
Collisions Ostrich_Col, PowerUP_Col, 1, 2


.. My PowerUp creation code:
Function SpawnPowerUp(PType,x#=0,y#=0,z#=0, rp = 20000)
	PowerUp.T_PowerUp = New T_Powerup
	Powerup\xPos# = x#
	Powerup\yPos# = y#
	Powerup\zPos# = z#
	
	PowerUp\Respawn = TimeKeeper + rp
	PowerUp\Active = 1
	
	If PowerUP\yPos# = 0 Then PowerUp\yPos# = TerrainY(Terrain\ObjectHandle, x#, y#, z#)
	
	Select PType
		Case HEALTH
			PowerUP\ObjectHandle = CopyMesh(HealthCrate)
			EntityType PowerUP\ObjectHandle, PowerUP_COL
			ShowEntity PowerUp\ObjectHandle
	End Select
	size# = 1.2
	modelheight# = MeshHeight(PowerUP\ObjectHandle)
	ScaleEntity PowerUP\ObjectHandle, (1.0/modelheight#) * size#, (1.0/modelheight#) * size#, (1.0/modelheight#) * size#
	;EntityBox PowerUP\ObjectHandle, PowerUp\xPos#, PowerUp\yPos#, PowerUp\zPos#, 1.2, 1.2, 1.2
	EntityRadius PowerUP\ObjectHandle, 1.0
	PositionEntity PowerUP\ObjectHandle, PowerUp\xPos#, PowerUp\yPos#, PowerUp\zPos#
	
End Function


... and here's my implementation:
; _Update Powerups
		For PowerUP.T_PowerUP = Each T_powerup
			TurnEntity PowerUp\ObjectHandle, 0,0.7,0
			
			If EntityCollided(PowerUp\ObjectHandle, Ostrich_COL) Then
				Stop
				HideEntity PowerUp\ObjectHandle
			EndIf
		Next


Bother the Player and the PowerUP have their entity radius set. I've tried EntityBox and Polygon Collisions, and nothing is working. I at least get the stop/sliding effect with Sphere2Sphere collision, but it still won't trigger my code. After looking at this for a week, I think I'm probably overlooking something simple and obvious, but can't for the life of me find it. Any thoughts?


Ross C(Posted 2003) [#2]
You need to check if the player is colliding against the powerup. It's always the moving enetity that is checked. Your check to see if the power up is colliding with player, which won't work because the powerup isn't moving. It's the nature of all blitz 3d collisions.


NTense(Posted 2003) [#3]
Ahhhhhh... See, I knew it was something insanely simple! << bangs head against keyboard>> Thanks joker.


Ruz(Posted 2003) [#4]
can't you use entity distance for the powerup instead of collisions. just a thought.


Ross C(Posted 2003) [#5]
Yeah, ruz has a point. Due to the way to collisions work, your main character will have to respond to the collision first, before it is deleted. So he will say stop or slide for a split second.


_PJ_(Posted 2003) [#6]
!!!!

You mean collisions between non-moving entities won't work?

I gave up on an earlier problem where I PositionEntity'ed a mesh relative to another mesh, and then wanted to check if it collided with stationary objects...Maybe that's why it didn't work!


WolRon(Posted 2003) [#7]
You mean collisions between non-moving entities won't work?


Thats funny.


(tu) sinu(Posted 2003) [#8]
if i wanted to check a collision between my player and another entity when not moving was to create a sphere around my player which was slightly larger(with a larger radius) and always position it at my players location(not parent it to the player), so if the player was against a wall and still that would mean the sphere had been pushed back slightly and would be trying to move to the players location thus registering a collision value.


NTense(Posted 2003) [#9]

Yeah, ruz has a point. Due to the way to collisions work, your main character will have to respond to the collision first, before it is deleted. So he will say stop or slide for a split second.



Actually, the current collision system works fine. It doesn't stop or slide now, because I Hide the entity as soon as the collision occurs. Detecting collisions for all of the players/bots in the game. I may try entity distance and see if there's any framerate change though!


Ross C(Posted 2003) [#10]
Best try to elminate as many unnessary collision from your game as possible. Entity distance is a super quick supstitute (Bad spelling :) )