I'm currently working on a game, and in my player management function I want the player to be able to jump using the ctrl key.
The current function (might seem a bit messy) looks as follows:
function PlayerManagement()
if upkey()=0 and rightkey()=0 and leftkey()=0 and downkey()=0 then loop object player,0,60
if playing=0 then play sound 3 : playing=1 : playtime=0
x#=object position x(player)
y#=object position y(player)
z#=object position z(player)
set camera to follow x#,y#,z#,angle,200,40,5,1
if rightkey() then yrotate object player,360 : phy move character controller player,-50 : loop object player,61,120
if leftkey() then yrotate object player,180 : phy move character controller player,-50 : loop object player,61,120
if upkey() then yrotate object player,270 : phy move character controller player,-50 : loop object player,61,120
if downkey() then yrotate object player,90 : phy move character controller player,-50 : loop object player,61,120
if scancode()=211 then angle=angle-90
if scancode()=209 then angle=angle+90
if controlkey() and jumping=0
jumping=1
time=0
endif
if jumping
REM *** Jump ***
endif
if playing
inc playtime
if playtime>=30 then playing=0 : playtime=0
endif
if not jumping
phy move character controller player,1
phy move character controller player,-1
endif
endfunction
I've experimented with different methods, but I can't manage to make the player object jump at all.
If you need the object loading and creation code, here it is:
load object "System/Models/gamepot.x",player
position object player,-120,320,64 : yrotate object player,-25 : fix object pivot player
phy make box character controller player,-120,120,64,25,25,25,1,15,50
scale object player,35,35,35
Also note that the global integer variable 'player' is set to 9.
Any help on this?
Thanks in advance!