Sprite collisions
Blitz3D Forums/Blitz3D Beginners Area/Sprite collisions
| ||
Is it possible to do collision detection with sprites? I've set-up entity collisions with EntityType and EntityRadius but EntityCollided doesn't seem to be working at all. Some help would be greatly appreciated. Thanks. |
| ||
Try putting an invisible sphere/object around it and use that for collisions. If it works you know sprites don't, otherwise there must be something wrong with your use of collision commands. |
| ||
You can do collision detection with sprites. If would have to be sphere or box collision (which it sounds like you are doing so maybe it is just an ooops in the code). Have any code you can post? |
| ||
Graphics3D 1024,768,32,1 SetBuffer BackBuffer() Global v_cam = CreateCamera() MoveEntity v_cam,0,0,-7.5 Global v_sprite1 = LoadSprite("sprite1.png",2) Global z1# = 0 Global x1# = 0 Global y1# = -4.5 EntityType v_sprite1,1 EntityRadius v_sprite1,2.0 PositionEntity v_sprite1,x1#,y1#,z1# Global v_sprite2 = LoadSprite("sprite2.png",2) Global z2# = 0 Global x2# = 0 Global y2# = 4.5 EntityType v_sprite2,2 EntityRadius v_sprite2,2.0 PositionEntity v_sprite2,x2#,y2#,z2# Collisions 1,2,1,1 While Not KeyDown(1) MoveEntity v_sprite1,x1#,0.02,z1# MoveEntity v_sprite2,x2#,-0.02,z2# RenderWorld Flip 1 Wend The two sprite just cross each other without a hint of collision. Shouldn't the two sprite stop on collision? Thanks. |
| ||
Try changing the code at collsions 1,2,1,1 to collisions 1,2,1,1 collisions 2,1,1,1 While Not KeyDown(1) MoveEntity v_sprite1,x1#,0.02,z1# updateworld MoveEntity v_sprite2,x2#,-0.02,z2# updateworld RenderWorld Flip 1 Wend |
| ||
I was missing the "UpdateWorld" keyword! Now it's working fine. I see you have to specify two "Collisions" statements to make two-way collisions between objects as well. Thanks a lot! |
| ||
Your welcome. Feels good to be able to help someone (I just dable in blitz most of the time). |