I have gone to my last backup where everything worked fine except that I don't have the ability to look up and down with the mouse.
As I can only place one download per post thats the reason for the next.
sync on
sync rate 60
phy start
Autocam Off
color backdrop 0
#constant TRUE 1
#constant FALSE 0
global jumpGravAccel# = 10.0
global playerJumpVelocity# = 500.0
global terminalVelocity# = 750.0
global charDefaultGravity# = 1000.0
global minimumRayCastDistance# = 27.0 `18 jump on stairs (very short fall with regular physx), 27 jump on 45 degree angles (small fall with regular physx and can't just tap jump - hold for a small time)
global lastGroundObject = 0
global falling as boolean = FALSE
global jumped as boolean = FALSE
global initialJumpVelocity# = 0.0
global deltaVerticalVelocity# = 0.0
global jumpTimeElapsed# = 0
global preJumpYPos# = 0.0
Load Object "Areana1.x", 1
Load Image "Floor Concreate.png", 1
texture object 1,1
Position Object 1,0,0,0
phy make rigid body static mesh 1
Load object "First robo animated.X", 2
Position Object 2,0,0,0
Turn Object Left 2, 180 `my character is backwards
x# = Object Position X(2)
y# = Object Position Y(2)
z# = Object Position Z(2)
phy make box character controller 2, 0, 40, 0, 25, 1, 25, 1, 50, 45.0
`sharpness 0.1 to 1, makes small jumping delay
phy set character controller sharpness 2, 0.06
`camera follower object
make object sphere 4,10 : hide object 4
do
Camera()
Handleplayer()
checkJumpOrFall()
phy update
sync
loop
Function Handleplayer()
Phy Set Character Controller Displacement 2, 0.0, 0.0
if keystate(17)=1 then phy move character controller 2, -300.0 `w - since my character is backwards
if keystate(31)=1 then phy move character controller 2, 300.0 `s + since my character is backwards
if keystate(32)=1 `d
turn object left 2, 90
phy move character controller 2, 270
turn object right 2, 90
endif
if keystate(30)=1 `a
turn object right 2, 90
phy move character controller 2, 270
turn object left 2, 90
endif
if keystate(18)=1 then jump()`e
`jetpack code press and hold, have an int to decrease to set limit, rewrite with new jump code
`if keystate(18)=1 `e
`pitch object up 2, 90
`phy move character controller 2, 2000
`pitch object down 2, 90
`endif
if MouseClick() = 1
`to do shoot
endif
endfunction
function Camera()
`camera follow character
position object 4,object position x(2),object position y(2),object position z(2)
set object to object orientation 4,2
move object 4,-10
point object 4,object position x(2),object position y(2),object position z(2)
PlayerX = wrapvalue(PlayerX-MOUSEMOVEX()*.2) : turn object left 2, PlayerX
dist#=170 : hight#=90 : angle#=object angle y(4) +180
set camera to follow object position x(2), object position y(2), object position z(2), angle#, dist#, hight#, 3, 0
`PlayerY = wrapvalue(PlayerY-MOUSEMOVEY()*.2) : pitch camera up PlayerY
endfunction
function jump()
if not falling
falling = TRUE
jumped = TRUE
initialJumpVelocity# = playerJumpVelocity#
endif
endfunction
function checkJumpOrFall()
if falling = TRUE
deltaVerticalVelocity# = jumpTimeElapsed# * jumpGravAccel# - initialJumpVelocity#
if deltaVerticalVelocity# > terminalVelocity# then deltaVerticalVelocity# = terminalVelocity#
Phy Set Character Controller Displacement 2, 0.0, deltaVerticalVelocity#
Inc jumpTimeElapsed#, 1
endif
phy move character controller 2, 1.5 : phy move character controller 2, -1.5
x# = Object Position X(2)
y# = Object Position Y(2)
z# = Object Position Z(2)
hit = FALSE
hit = Phy Ray Cast All Shapes(x#, y#, z#, 0,-1,0)
dist# = Phy Get Ray Cast Distance()
zscl# = Object Size Z(2)
if dist# <> 0 and dist# < minimumRayCastDistance#
lastGroundObject = Phy Get Ray Cast Object()
stopfalling()
preJumpYPos# = y#
else
falling = TRUE
endif
if falling = TRUE
if jumped = TRUE
if y# = preJumpYPos#
stopfalling()
endif
endif
endif
endfunction
function stopfalling()
falling = FALSE
jumpTimeElapsed# = 0
deltaVerticalVelocity# = 0.0
initialJumpVelocity# = 0
jumped = FALSE
endfunction
`Credits
`BearCDP (The Game Creators forum, smooth jump code)