Entitycollided doesn't work!!!
Blitz3D Forums/Blitz3D Beginners Area/Entitycollided doesn't work!!!
| ||
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? |
| ||
you have to first declare collisions between the entity types. Otherwise, collisions won't work. Not regular types, either. |
| ||
I thought I did declare the collisions on the line after I declared all of the global variables. Did I declare the collisions right. |
| ||
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. |
| ||
I used that command on the thirteenth line of text so i am still confused. I also declared the dimond as |
| ||
Check CountCollisions() |
| ||
Good Idea |
| ||
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 |
| ||
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. |
| ||
I fixed the problem. I'm not sure how. Just a little messing around with the programming. Thanks to everyone that helped me! |
| ||
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 |
| ||
I don't think that polygon to sphere collision is possible, only sphere to polygon. |
| ||
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 |
| ||
How do I tell what dimond got hit? |
| ||
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 |
| ||
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 |
| ||
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. |
| ||
Why re-invent the wheel, just use EntityDistance. |
| ||
I had never heard of the command entitydistance. I'll try it. Thanks |