My problem is that the Car(the object Im moving) goes through the map just a little bit, and then stops going. It looks as though a part of the car has vanished into the wall until I move backwards. This time I dont want code to help me but just some pointers. I tried increasing the radius at the SC_spherecast line but it made my car seem to float. There are some random rems in there, just ignore them.
Rem Project: Dark Basic Pro Project
Rem Created: Monday, October 11, 2010
rem randoooooooooooommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm or is it?
Rem ***** Main Source File *****
`%ProjectTitle%
`======================
`%Author%
`======================
`Source File Name
//autocam off
set display mode 1280, 800, 16 ` my display node
load object "F1Car.x", 1 ` load up the models
load object "Straight.x", 2
scale object 1, 1000, 1000, 1000
`set object 1,1,1, 0
set camera range 1, 13000 ` to see farther because the normal settings cant see the entire map
position object 1, -5160, -77, -626 ` position inside map
yrotate object 1, 270 ` rotate to face foward
sc_setupobject 1,0,0 `collision system setup
sc_setupobject 2,0,0
//set camera to follow object position x(1), object position y(1), object position z(1), 0, 10, 10, 10, 0
ang# = 90 ` make camera follow properly and because i rotated 90 degrees
type Moving
Fast# as float
Torque# as Float
endtype
Fast# = 0
do
oldx# = object position x(1) ` for the collision
oldy# = object position y(1)
oldz# = object position z(1)
if upkey() = 1 ` moving forward
if Fast# < 50 then Fast# = Fast# + .2 ` speed limit
Fast# = Fast# - Slow ` if collides with wall, it goes slower
Speed# = Fast#*10 ` just to make the car seem faster
move object 1, - Fast#/5` moving
else
if Fast# > 0 then Move object 1, - Fast#/15 ` after relesing key, goes foward a little
Fast# = Fast# - 0.4 ` goes slower
if Fast# <0 then Fast# = 0 ` no negatives
endif
Torque# = Fast#/ 10 ` how fast the car can turn
if leftkey() = 1
turn object left 1, Torque#
ang# = ang# - Torque# ` camera angle follow
endif
if rightkey() = 1
turn object right 1, Torque#
ang# = ang# + Torque#
endif
if downkey() = 1 then move object 1, 2
//sc_updateobject 1
//sc_updateobject 2
if keystate(30) = 1 then move object down 1 , 2
x# = object position x(1) `needed by collision system
y# = object position y(1)
z# = object position z(1)
`Slide(1,0,oldx#,oldy#,oldz#,x#,y#,z#,object size(1),1) `check for collision
collide = sc_spherecast(0,oldx#,oldy#,oldz#,x#,y#,z#,object size(1)+10,1) ` check if it collides
if collide>0 ` if it collides with something
xx# = sc_getcollisionslidex() ` new positions
yy# = sc_getcollisionslidey()
zz# = sc_getcollisionslidez()
position object 1, xx#, yy#, zz# `position it to the sliding positions
sc_updateobject 1 `updat the object
Slow = 1
else
Slow = 0
endif
//endif
set camera to follow object position x(1), object position y(1), object position z(1), ang#, 70, 50, 10, 0
//if sc_objectcollision(1,0) = 2 then position object 1, oldx#, oldy#, oldz#
//phy make rigid body static box 1
print z#
print Fast#
print str$(screen FPS())
print Torque#
print x#
print y#
Print Slow
loop
remstart
Function Slide(obj,checkobj,oldx#,oldy#,oldz#,x#,y#,z#,radius#,exlude)
collide = sc_spherecast(checkobj,oldx#,oldy#,oldz#,x#,y#,z#,radius#,exlude) ` check if it collides
if collide>0 ` if it collides with something
xx# = sc_getcollisionslidex() ` new positions
yy# = sc_getcollisionslidey()
zz# = sc_getcollisionslidez()
position object obj, xx#, yy#, zz# `position it to the sliding positions
sc_updateobject obj `updat the object
Slow = 1
else
Slow = 0
endif
endfunction
remend