Collision then position?

Blitz3D Forums/Blitz3D Beginners Area/Collision then position?

Braden(Posted 2008) [#1]
I'm trying to make it so my camera, when it hits a sprite, it moves to a new location.

Here is the code...

If CountCollisions (door)=True Then PositionEntity cam, -500,
-500,-500

door is the sprite, cam is the camera.

The code is above Updateworld but whenever the camera hits the sprite, it just goes right through it, I want the camera to move to the new location when it hits it.

Any suggestions?


Matty(Posted 2008) [#2]
Have you set the collision responses up and assigned a collision type to the entities?

graphics3d 800,600,0,2
camera=createcamera()
door=createcube() ;door could be anything you like, MoveEntity Door,0,0,10
I've just used a cube because I felt like it, a sprite would be done very similarly

CONST COLLISION_TYPE_DOORS = 1
CONST COLLISION_TYPE_CREATURES = 2
;above constants just used for easier reading of code below

COLLISIONS COLLISION_TYPE_CREATURES,COLLISION_TYPE_DOORS,2,2
;specifies responses between the different types.


EntityType camera,COLLISION_TYPE_CREATURES
EntityType door,COLLISION_TYPE_DOORS
EntityRadius Camera,1.0 ;Specify what you want for this, determines how big the collision radius is for the camera

repeat
turnentity door,1,2,3
moveentity camera,0,0,0.05

if countcollisions(camera) <> 0 then
;our camera has had 1 or more collisions with something
;do code here.
endif 

updateworld
renderworld
flip


until keydown(1)
freeentity door
freeentity camera
end



Haven't got access to blitz3d at present, but something like that should get you started..