Another collision query
Blitz3D Forums/Blitz3D Programming/Another collision query
| ||
Hey folks, I've put together a little loader program for testing objects, textures. What I'd like to do is add collisions for the camera and the object that has been loaded (in my tests, a room modelled in 3DS)... Here's the code I've used: Const ROOM=1,CAM=2 Collisions CAM,ROOM,2,2 Global font=LoadFont("Arial",20,False,False,False):SetFont font Global file$=Input$("Enter model filename (with path if not in current folder): ") Global figure=LoadAnimMesh(file$) EntityType figure,ROOM Global camera_p=CreatePivot() EntityType camera_p,CAM EntityRadius camera_p,2 Global camera=CreateCamera(camera_p) Problem is - it doesn't work. The camera passes straight through the object. I've looked at a tutorial by Rob Hutchinson in which he's doing something similar... works for him... not for me! :( Another quick one - are collisions one-way? That is if you have a collision set up for ball,box does it also trigger if box hits ball? I did a demo in which the collisions only seemed to work one way, but it didn't help to declare ball,box and also box,ball... |
| ||
Yeah collisions only work one way so you'd also have to include the line :- Collisions ROOM,CAM,2,2 Also the object you are checking for collisions must be moving. If it is stationary and something moves into it then a collision will not be registered. |
| ||
That code looks fine such as it is; I assume the room is stationary so it doesn't matter if you setup room->camera collision detection. However, you don't show your game's loop. In particular, are you using UpdateWorld every frame? Collision detection only happens at UpdateWorld. |
| ||
Sorry, the rest of the code was just for camera movement. I'm definitely executing an UpdateWorld... I was starting to wonder if it might be some sort of Blitz weirdness with 3DS models(?) I've done collisions before between objects created within Blitz. This is my first attempt with an imported object and I'm suddenly having problems... Thanks for that other info too Flynn. I had exactly that problem with a moving object hitting a stationary object and just passing straight through it. Least that's one mystery resolved :) |
| ||
This is just a guess but maybe you need to apply entitytype to all the children of the model as well. Loadanimmesh may mean you have a hierarchy and I'm not sure that entitytype is recursive. |
| ||
EntityType has an additional parameter to select recursive or not. |
| ||
Egads, so it has! Well there you go then, try the recursive option. |
| ||
I wouldn't have thought to do that in a million years. What's more embarrassing is that I poured over all those commands for ages before creating this post! I never saw the recurse option... I'm in the painful process of reloading my machine at the moment. I'll give this a try as soon as it's up again... Thanks for the tip. Sounds very promising... |
| ||
don't worry, i used to use it without thiniking it was recursive either, setting up all children manually :P |
| ||
Well at least I'm not the only one :) I don't like to think of myself as stupid... just as possessing an infinity capacity for improvement... |