Entitycollided doesn't work!!!

Blitz3D Forums/Blitz3D Beginners Area/Entitycollided doesn't work!!!

Nate the Great(Posted 2008) [#1]
I'm trying to make my first game in Blitz3d. The entitycollided statement doesn't work for the dimonds. Here is the code. Its kinda long.



The update dimonds function spins the dimonds and is supposed to make them rise into the air and disappear when you hit them.

Does anyone have any suggestions?


Cp(Posted 2008) [#2]
you have to first declare collisions between the entity types. Otherwise, collisions won't work. Not regular types, either.


Nate the Great(Posted 2008) [#3]
I thought I did declare the collisions on the line after I declared all of the global variables. Did I declare the collisions right.


Cp(Posted 2008) [#4]
entitytype ball,col_type_ball

you have to apply the type to the entity before it will do anything.
Do the same sort of thing for each one.


Nate the Great(Posted 2008) [#5]
I used that command on the thirteenth line of text so i am still confused.



I also declared the dimond as



KillerX(Posted 2008) [#6]
Check CountCollisions()


Nate the Great(Posted 2008) [#7]
Good Idea


Charrua(Posted 2008) [#8]
Collisions col_type_ball,col_type_ground,2,2
Collisions col_type_dimond,col_type_ball,2,2

you assign 1 (col_type_ball) to a ball, ok!
you assign col_type_dimon to dimonds, ok!

what about : col_type_ground?

does the water act as ground?

check that

Juan


Nate the Great(Posted 2008) [#9]
The ground are the blocks that float on the water.
If you hit the water, then you die.
Sorry if it wasn't clear at first.


Nate the Great(Posted 2008) [#10]
I fixed the problem.

I'm not sure how. Just a little messing around with the programming. Thanks to everyone that helped me!


Nate the Great(Posted 2008) [#11]
My Problem is back.

I tried experimented a little and found out that the ball bounces off of the dimond if I switch the code around, but the dimond doesn't bounce off of the ball when I switch it back.

Collisions col_type_ball,col_type_dimond,2,2  ; makes the ball bounce off of the dimonds


Collisions col_type_dimond,col_type_ball,2,2  ; doesn't make the dimonds bounce off of the ball



KillerX(Posted 2008) [#12]
I don't think that polygon to sphere collision is possible, only sphere to polygon.


Stevie G(Posted 2008) [#13]
There is no such collision type as polygon to sphere. As you already set entityradius on both entitytypes you should be using Sphere to sphere collisions. The moving entity should be stated first in the collisions command.


Collisions col_type_ball,col_type_dimond,1,2 ; makes the ball bounce off of the dimonds




Nate the Great(Posted 2008) [#14]
How do I tell what dimond got hit?


Charrua(Posted 2008) [#15]
see the commands

CountCollisions
EntityCollides
CollisionEntity

probably you have to loop over the list of diamonds lookin for the one that has collided with the type you are interested in...

Juan


Stevie G(Posted 2008) [#16]
When creating the diamond store the type handle in the entities name ..

			If typ = 2 Then
				t.dimonds = New dimonds
				t\x# = b
				t\y# = -a
				t\z# = -3
				t\pic = CopyEntity(dimond)
				NameEntity t\pic, Handle(t)
				PositionEntity t\pic,t\x,t\z,t\y
			EndIf


Then when you are checking the ball collisions ...

for c = 1 to countcollisions( Ball )
     ThisEntity = CollisionEntity( Ball, c )
     d.dimond = object.dimond( entityname( ThisEntity ) )
     if d <> null
         freentity d\pic
         delete d
         Dimonds_Left = Dimonds_Left - 1
     endif
next



Nate the Great(Posted 2008) [#17]
Thanks for all of the help, but I gave up on the entity collided command and used the distance formula.

dist# = Sqr((x1-x2)^2+(y1-y2)^2+(z1-z2)^2)


The distance formula works fine for me.


Stevie G(Posted 2008) [#18]
Why re-invent the wheel, just use EntityDistance.


Nate the Great(Posted 2008) [#19]
I had never heard of the command entitydistance. I'll try it.

Thanks