Is the variable "limb" declared as global?
[edit] Here is a slightly modified version that works here.
sync on : sync rate 0
hide mouse
autocam off
position camera 0, 0, -15
global limb as integer
global yang# as float
global spd# as float
load_player()
load_world()
do
gosub stuff
sync
loop
end
stuff:
x# = object position x(1)
z# = object position z(1)
if intersect object(2 , x# , 0 , z# , limb position x(1 , limb) , 0 , limb position z(1 , limb)) > 1
spd# = 0.0
else
spd# = 0.1
endif
set camera to follow x# , object position y(1) , z# , yang# + 90 , 10 , 10 , 20 , 1
point camera x# , object position y(1) , z#
if upkey() = 1 then x# = newxvalue(x# , yang# + 90 , spd#) : z# = newzvalue(z# , yang# + 90 , spd#)
if leftkey() = 1 then yang# = wrapvalue(yang# - 0.25)
if rightkey() = 1 then yang# = wrapvalue(yang# + 0.25)
yrotate object 1 , yang#
position object 1 , x# , 0 , z#
return
function load_player()
`load object "media\models\char.x" , 1
make object cube 1, 1
position object 1 , 0 , 0 , 0
yang# = 0
spd# = 0.1
limb = 1
make object sphere 9999 , 1
make mesh from object 1 , 9999
delete object 9999
add limb 1 , limb , 1
offset limb 1 , limb , 3 , 2 , 0
endfunction
function load_world()
make object cube 2, 10
position object 2, 30, 0, 0
endfunction