Sorry to ask, but can you tell an easy way to make collision detection of 3D objects? I was thinking I could do this by not enabling the object to walk when colliding, and then position it to a previous position to let pass the object, but not overlap with it. The problem is, do you know how to store data of the object previous positions just before the collision? If you don't understand I mean that for example the object collides with another, and then when that happens I want the object to return to its previous position; something similar to what happens in the
automatic object collision comand, but using boxes or polygons for the collision checking.
Here is my first attemp, working for the vertical movements:
load object "\City object\city.x",2
set object cull 2,0
make object cube 1,1
set object collision to polygons 2
set object collision to polygons 1
position object 1,x,-30,-30
mvup=0
mvdown=0
do
set camera to follow object position x(1),object position y(1),object position z(1),object angle y(1),10,3,10,1
if object collision(2,1)=0
if upkey()=1
move object up 1,1
mvup=1
else
mvup=0
endif
if downkey()=1
move object down 1,1
mvdown=1
else
mvdown=0
endif
if leftkey()=1 then yrotate object 1,object angle y(1)-1
if rightkey()=1 then yrotate object 1,object angle y(1)+1
if controlkey()=1
move object 1,1
mvw=1
else
mvw=0
endif
if spacekey()=1
move object 1,-1
mvc=1
else
mvc=0
endif
endif
if keystate(30)=1 then position object 1,x,y,z
if object collision(2,1)=1
if mvup=1 then position object 1,object position x(1),object position y(1)-1,object position z(1)
if mvdown=1 then position object 1,object position x(1),object position y(1)+1,object position z(1)
endif
print "FPS: "+str$(screen fps())
loop
The other object you can download it in the attached media. Thanks for your help.
Carlos
Have a nice day
May GOD be with you +
Have a nice day