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:
... and here's my initialization for the collisions:
.. My PowerUp creation code:
... and here's my implementation:
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?
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?