collision with array

Blitz3D Forums/Blitz3D Beginners Area/collision with array

Braden(Posted 2009) [#1]
how would I create a collision between an array and the camera that when they collide the camera changes position?


Matty(Posted 2009) [#2]
An array of what?
Changes position how?
An array is a data structure, a camera is an entity - they cannot collide.
If you mean you want to define regions of space x/y/z with an array as to their 'passability' by the camera then this is possible, but you need to explain a little more what you mean.


Braden(Posted 2009) [#3]
oh sorry, it's an array of doors (.3DS model) set to random positions, i just wanted to make it so that when the camera hits any of the doors the camera's position would change, like to different cordinates...


Matty(Posted 2009) [#4]
Check the collision commands.
Set up collision checking between the doors and the camera by assigning a collision type to the camera and another collision type (only 1 needed) to the doors.
Each frame, after updateworld, iterate through the collisions the camera has made - check out collisioncount, entitycollided and collisionentity - these are relevant, and if there is a collision recorded between the camera and a 'door type', use the position entity command to change the camera's position to somewhere else in the world. Note that collisions will still be active so to avoid having the camera get stuck set the collision type of the camera to zero temporarily then reset it back to its usual collision type once it has moved.


Braden(Posted 2009) [#5]
ok i'll try that thanks!


Braden(Posted 2009) [#6]
haha! it worked! Thank you very much! I used entitycollided