If collision

Blitz3D Forums/Blitz3D Beginners Area/If collision

mintybreath(Posted 2007) [#1]
I feel kind of like a newb asking this, but i have this collision problem. I've been away from 3d a few months, doing 2d projects, and am a bit rusty.

I was wondering, how do you make a certain thing happen when two objects collide, asside from the options it gives you. Such as, if i were to make a bullet hit someone, how would i make it hurt them, and disapear?

I was thinking something like this:
 If collisions Type_Player, Type_bullet,2,2 then
                       hideentity bullet
                       player\health = player\health - 1
          endif 

But when i do something along the lines of this, i get an Expecting End Of Line error.

How would i do something like this? An if statement with the condition being a collision.

Thanks alot everyone!

-Kevin


System4 Studios(Posted 2007) [#2]
Wouldn't it be...

If EntityCollided(Type_Player,type_bullet)=1
          blah blah...
Endif 



Mortiis(Posted 2007) [#3]
For p.Player = Each Player
    For b.Bullet = Each Bullet	
        If EntityCollided( b\bullet, Player_Collision_Type ) = p\bullet
            FreeEntity b\bullet
            Delete(b)
			
            p\health=p\health-1
        EndIf	
    Next
Next



Stevie G(Posted 2007) [#4]

Wouldn't it be...


If EntityCollided(Type_Player,type_bullet)=1
blah blah...
Endif



Nope.

If you've got more than one player .... store the players type handle in the name for quick access ...

p.player = new player
p\health = 100
p\mesh = createsphere()
entitytype p\mesh, type_player
nameentity p\mesh , handle( p )


To check which player is hit etc...

for b.type_bullet = each type_bullet

  Entity = entitycollided( b\Mesh ,  type_player )

  if Entity > 0
    p.type_player = Object.type_player( EntityName( entity ) )
    p\health = p\health - 1
    freeentity b\Mesh
    delete b
  endif

next




Stevie


System4 Studios(Posted 2007) [#5]
Yeah you are right Stevie G..


mintybreath(Posted 2007) [#6]
Thanks alot everyone, ill try that out! :)

-Kevin


Mortiis(Posted 2007) [#7]
Mine is working too! :D