Thanks lbfn

Here is the function I use, most of it is from the original function in sparkys sliding demo.

I would write my own variable but am confused what to use as it is not my own function. Thank you for any help with this.

function movePlayer()
`--------------------------------------------------------------------------------------------
`Now I just use some math and basic commands to manipulate input values
`I do this to make everything much simpler for you to handle with your controller
LeftStickX = JoyStick X()*.01
LeftStickY = -JoyStick Y()*.01
LeftStickPress = JoyStick Fire X(8)
If JoyStick Z()>0 : LeftTrigger = abs(JoyStick Z())*.01 : ELSE : LeftTrigger = 0 : EndIf
LeftShoulderPress = JoyStick Fire X(4)
RightStickX = ((0-1000)+((JoyStick Twist X()/65.535)*2))*.01
RightStickY = (1000-((JoyStick Twist Y()/65.535)*2))*.01
RightStickPress = JoyStick Fire X(9)
If JoyStick Z()<0 : RightTrigger = abs(JoyStick Z())*.01 : ELSE : RightTrigger = 0 : EndIf
RightShoulderPress = JoyStick Fire X(5)
BackButton = JoyStick Fire X(6)
AButton = JoyStick Fire A()
XButton = JoyStick Fire C()
YButton = JoyStick Fire D()
BButton = JoyStick Fire B()
For x = 1 to 9
If JoyStick Hat Angle(0) = DPad(x).State : DPadPressed = x : EndIf
Next x
rem controller animations
`--------------------------------------------------------------------------------------------
rem rotate player with mouse
rem xrotate object 2,object angle x(2)+mousemovey()/3.0
oldx# = object position x(2)
oldy# = object position y(2)
oldz# = object position z(2)
rem apply gravity, and user changes to movement
angy# = object angle y(2)
vx# = 0
vz# = 0
rem if player is jumping or falling then apply 'normal' gravity
rem if not attempt to keep the player stuck to the floor
if vy#=0 and jumptimer=0 then vy# = vy# + 10*gravity# else vy# = vy# + gravity#
if keystate(32)=1 then vx# = vx# + cos(angy#) : vz# = vz# - sin(angy#)
if keystate(30)=1 then vx# = vx# - cos(angy#) : vz# = vz# + sin(angy#)
if keystate(17)=1 then vx# = vx# - sin(angy#) : vz# = vz# - cos(angy#)
if keystate(31)=1 then vx# = vx# + sin(angy#) : vz# = vz# + cos(angy#)
rem if upkey()=1 then vx# = vx# - sin(angy#) : vz# = vz# - cos(angy#)
if downkey()=1 then vx# = vx# + sin(angy#) : vz# = vz# + cos(angy#)
if JoyStick Y()=0 then vx# = vx# + sin(angy#) : vz# = vz# + cos(angy#)
if LeftStickx =>1 and RightTrigger=<1 then vx# = vx# +1 * sin(angy#) : vz# = vz# + 1 * cos(angy#)
if LeftStickx =>1 and RightTrigger=>1 then vx# = vx# +2 * sin(angy#) : vz# = vz# + 2 * cos(angy#)
if LeftStickx =<-1 and RightTrigger=<1 then vx# = vx# -1 * sin(angy#) : vz# = vz# - 1 * cos(angy#)
if LeftStickx =<-1 and RightTrigger=>1 then vx# = vx# -2 * sin(angy#) : vz# = vz# - 2 * cos(angy#)
if upkey()=1 and keystate(157)=0 then vx# = vx# - 1 * sin(angy#) : vz# = vz# - 1 * cos(angy#)
if upkey()=1 and keystate(157)=1 then vx# = vx# - 2 * sin(angy#) : vz# = vz# - 2 * cos(angy#)
rem only jump if on ground, and a certain time after last jump
if ground=1
if spacekey()=1 and jumptimer=0 then vy# = vy# + 3.0 : jumptimer = 20
endif
if ground=1
if AButton=1 and jumptimer=0 then vy# = vy# + 4.0 : jumptimer = 10
endif
rem this would be the player's final position without collision
x# = oldx#+vx#
y# = oldy#+vy#
z# = oldz#+vz#
rem first handle gravity - seperated from horizontal movement
rem to achieve a more realistic effect
rem Method: simple - cast a sphere vertically down, if it hits the level then
rem position the object there (sticky collision) then move
rem on to horizontal movement
rem more complex - if we were to only use the simple method the player would be
rem allowed to climb almost vertical slopes. Alternative is to
rem get the normalY direction to work out how flat the gorund
rem below the player is, 0-slope# is flatter, slope#-1 is steeper.
rem if it's flat, use sticky collision, if it's steep slide the
rem player down the slope. Changing slope# determines how steep the
rem player can climb. NOTE: this also effects stairs.
collide = sc_SphereCastGroup(1,oldx#,oldy#,oldz#,oldx#,oldy#+vy#,oldz#,radius#,0)
if collide>0
rem how flat is this ground
ny# = sc_getCollisionNormalY()
if abs(ny#)>slope#
rem FLAT, stick
oldy# = sc_getStaticCollisionY()
else
rem STEEP, slide
x# = x# - oldx# : z# = z# - oldz#
oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()
x# = x# + oldx# : z# = z# + oldz#
endif
rem ny#<0 means the player has hit a ceiling rather than a floor
if ny#>slope#
rem only on ground if standing on flat ground
ground = 1
vy# = 0
else
ground = 0
rem if player has hit a flat ceiling then stop vy# movement
if ny#<-slope# then vy# = gravity#
endif
else
rem nothing below player, not on ground, add vertical speed to player
gravity# = -0.10
oldy# = oldy# + vy#
ground = 0
endif
rem jumptimer will decrease only when player is back on ground
rem creates a pause between two successive jumps
if ground = 1 and jumptimer>0 then dec jumptimer
rem handle horizontal movement as sliding
rem player only collides with group 1 (level) objs and moves freely through others
collide = sc_SphereSlideGroup(1,oldx#,oldy#,oldz#,x#,oldy#,z#,radius#,0)
if collide>0
rem if hit, reposition player, halt movement vector
x# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
vx# = 0
vz# = 0
rem possible code for giving the player a jumping help up stairs...
rem might be useful if slope# is set very high but stairs are still required
`dy# = oldy#-sc_getStaticCollisionY()
`if dy#<slope# and dy#>0 and ground=1 then vy# = 0.5
endif
rem position the player
position object 2,x#,oldy#,z#
sc_updateObject 2
endfunction