I've searched and read for hours, and haven't seen this problem, so here goes.
My character walks along just fine on flat ground. I've set it up to print the normal of the spot the character is moving to, and as I watch that and move towards a slope, suddenly it slows down when the normals change from 1 to between 0.9999 and 0.9980. Once the normals either return to 1 or go below 0.998 everything moves at regular speed again. Any ideas what might be causing this slow down? It seems like just the slightest little bit of an angle on the ground causes it to slow..
I'm using Extended TerrainXYZ which is loaded as several objects. They're set for collision with sc_SetupComplexObject(x, 2). Buildings and such are also in group 2. The player is in group 1.
The code I'm using is from the Sliding Demo included with the DLL.
gravity# is currently set at -0.05
slope# is currently set at 0.93
while not escapekey()
oldx# = object position x(pObj)
oldy# = object position y(pObj)
oldz# = object position z(pObj)
if keystate(17) = 1 then move object pObj, 0.2
if keystate(31) = 1 then move object pObj, -0.2
if keystate(30) = 1 then turn object left pObj, 0.3
if keystate(32) = 1 then turn object right pObj, 0.3
x# = object position x(pObj)
y# = object position y(pObj)
z# = object position z(pObj)
if vy# = 0
vy# = vy# + 10 * gravity#
else
vy# = vy# + gravity#
endif
` Check ground collision and apply gravity
collide = sc_SphereCastGroup(2,oldx#,oldy#,oldz#,x#,y#+vy#,z#,radius#,0)
if collide > 0
ny# = sc_getCollisionNormalY()
if abs(ny#) > slope#
y# = sc_getStaticCollisionY()
else
x# = sc_getCollisionSlideX()
y# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
endif
if ny# > slope#
ground = 1
vy# = 0
else
ground = 0
if ny# < -slope# then vy# = gravity#
endif
else
y# = y# + vy#
ground = 0
endif
collide = sc_SphereSlideGroup(2,oldx#,oldy#,oldz#,x#,y#+vy#,z#,radius#,0)
if collide > 0
x# = sc_getCollisionSlideX()
y# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
endif
position object pObj, x#, y#, z#
position camera 0, object position x(pObj), object position y(pObj)+20, object position z(pObj)
set camera to object orientation 0, pObj
move camera 0, -50
sc_updateobject pObj
sync
endwhile