ok, but how would I add the falling# and direction# to my code so it knows when to fall and stuff??
Test this code here, I replaced my object with simply make cube, the collision in here is way worse than before.
Rem Project: NoName
Rem Created: 17/07/2010 11:08:34 PM
Rem ***** Main Source File *****
rem setting, player, background, make camera
make matrix 1,1000,1000,1,1
position matrix 1,0,0,0
set global collision on
sync on
sync rate 40
autocam off
make object cube 1,20
rotate object 1,0,0,180
set object collision on 1
Position Object 1,0,0,0
make camera 1
backdrop on
color backdrop 1,RGB(0,0,255)
rem other objects
make object plane 4,300,300
position object 1,0,0,0
color object 1,rgb(0,100,0)
make object cube 2,20
position object 2,20,20,0
set object collision on 2
make object cube 3,20
position object 3,20,40,0
set object collision on 3
make object cube 5,100
position object 2,0,60,0
color object 2,rgb(255,0,0)
zrotate object 2,45
Do
rem remembers old co'ords
x# = OBJECT POSITION X(1)
y# = OBJECT POSITION Y(1)
z# = OBJECT POSITION Z(1)
rem camera follow player
position camera 1,OBJECT POSITION X(1),OBJECT POSITION Y(1)-30,OBJECT POSITION Z(1)-20
rotate camera 1,-50,0,0
rem movement
if upkey()=1 then move object down 1,1
if downkey()=1 then move object up 1,1
if rightkey()=1 then move object left 1,1
if leftkey()=1 then move object right 1,1
D#=INTERSECT OBJECT(3,x#,y#,z#,x#,y#-30,z#) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<15.0 and D#>0.0
position object 1,x#,y#+(15.0-D#),z#
Falling#=0
endif
D#=INTERSECT OBJECT(3,x#,y#,z#,x#,y#+30,z#) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<15.0 and D#>0.0
position object 1,x#,y#-(15.0-D#),z
Falling#=0
endif
D#=INTERSECT OBJECT(3,x#,y#,z#,x#-30,y#,z#) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<15.0 and D#>0.0
position object 1,x#+(15.0-D#),y#,z#
Falling#=0
endif
D#=INTERSECT OBJECT(3,x#,y#,z#,x#+30,y#,z#) `this tests the "Ground Mesh" for a collision (or ray intersection)
if D#<15.0 and D#>0.0
position object 1,x#-(15.0-D#),y#,z#
Falling#=0
endif
if object collision(1,5)=1
D#=INTERSECT OBJECT(5,x#,y#,z#,x#,y#-30,z#) `this tests the "Ramp Mesh" for a collision (or ray intersection)
if D#<20.0 and D#>0.0
position object 1,x#,y#+(20.0-D#),z#
Falling#=0
endif
endif
if object collision(1,5)=1
D#=INTERSECT OBJECT(5,x#,y#,z#,x#,y#+30,z#) `this tests the "Ramp Mesh" for a collision (or ray intersection)
if D#<20.0 and D#>0.0
position object 1,x#,y#-(20.0-D#),z#
Falling#=0
endif
endif
sync
loop
compared to (with this you need to replace my object with make cube)
Rem Project: NoName
Rem Created: 17/07/2010 11:08:34 PM
Rem ***** Main Source File *****
rem setting, player, background, make camera
set global collision on
sync on
sync rate 40
backdrop on
autocam off
load object "C:\Users\Dollie\Desktop\NoName\person.x",1
rotate object 1,180,0,0
set object collision on 1
Position Object 1,0,0,0
make camera 1
color backdrop 1,RGB(255,0,0)
rem other objects
make object cube 2,20
position object 2,20,20,0
set object collision on 2
make object cube 3,20
position object 3,20,40,0
set object collision on 3
Do
rem remembers old co'ords
oldx# = OBJECT POSITION X(1)
oldy# = OBJECT POSITION Y(1)
oldz# = OBJECT POSITION Z(1)
rem camera follow player
position camera 1,OBJECT POSITION X(1),OBJECT POSITION Y(1),OBJECT POSITION Z(1)
rotate camera 1,-90,0,0
rem movement
if upkey()=1 then move object down 1,1
if downkey()=1 then move object up 1,1
if rightkey()=1 then move object right 1,1
if leftkey()=1 then move object left 1,1
rem display co'ords
text 10,10,str$(OBJECT POSITION X(1))
text 10,20,str$(OBJECT POSITION Y(1))
text 10,30,str$(OBJECT POSITION Z(1))
rem collision
move object up 1,1 `yes again
IF OBJECT COLLISION(1,2) or OBJECT COLLISION(1,3)
POSITION OBJECT 1, oldx#,oldy#,oldz#
else
move object down 1,1
endif
sync
loop
why can't it all just be this easy?
if place_free(x,y+1){gravity = 0.7}
else
{gravity = 0}
gravity_direction = 270
if vspeed > 10 {vspeed = 10}
if keyboard_check(vk_right) && place_free(x+4,y){x+=4}
if keyboard_check(vk_left) && place_free(x-4,y){x-=4}
if keyboard_check_pressed(vk_up) && !place_free(x,y+1){vspeed= -10}
I want coke, not Pepsi!