Hey first off thanks for reading this post I have been having problems with some collision detection in a game i am attempting to make. I'll show the the code then try and explain the problem. What i'm trying to do is make a model I drew move back and forth between two cubes it seems simple until i tried to do it, heres what I tried(note alot of this isn't exactly like my program but it's close enough note i also did all the sync stuff but not in this small code here):
rem i loaded and made my objects and positioned them
rem and put collision detection on
load object "whatever.x",1
position object 1,0,0,0
set object collision on 1
make object cube 2,10
position object 2,10,0,0
set object collision on 2
make object cube 3,10
position object 3,-10,0,0
set object collision on 3
rem i then made a variable which use i will explain later
patrol = 1
rem i then started the loop
do
rem
got positions of all the models
sqoX# = object position X(2)
sqoY# = object position Y(2)
sqoZ# = object position Z(2)
sqtX# = object position X(3)
sqtY# = object position Y(3)
sqtZ# = object position Z(3)
rem now i use the 'patrol' variable to know which square to rem move it to
if patrol = 1
point object 1,sqoX#,sqoY#,sqoZ#
move object 1,5
endif
if patrol = 2
point object 1,sqtX#,sqtY#,sqtZ#
move object 1,5
endif
rem now i do collision detection to change the
rem variable 'patrol'
if object collision(1,2)>0
patrol = 2
endif
if object collision(1,3)>0
patrol = 1
endif
loop
and their is my code and what i thought this would simply do was move my model from one square to the next in a continuous loop (in my game this is going to be a badguy patrolling from one point to another) but what happens is my models moves to the first square and the detects the collision when it hits and moves towards the other square but then when it hits that one it just stops, i've also noticed that the collision detection i put first is the only one it detects, and the second one nothing happens. I was wondering if anyone could help me with this, or have any better way to do the same thing. Thanks!