Hello all,
I seem to remember having this issue before... but I can't remember what I did to fix it.
I have a cube as a character (sad, I know), and it rotates fine. It's when I move that I get a large problem. Either the camera is causing the glitch or the object is jumping back and forth rapidly, I can't quite tell.
Below is my code:
// Project: Unnamed Game
// Started: 1:11 AM January 23, 2008
// Finished: N/A
// Description: N/A
type gamedat
integer terrainobj
integer skyboxobj
integer waterobj
integer playerobj
float playerposx
float playerposy
float playerposz
float playerrotx
float playerroty
float playerrotz
endtype
global dim gamedata#(1) as gamedat
dim framex#(0)
dim framelast(0)
phy start
gamedata#(1).playerobj=b3d make object cube(10);
phy make box character controller gamedata#(1).playerobj,5,0,5,11,11,11,1,2.5,45//Object Number,x,y,z,zsize,ysize,zsize,up,step,slope
null=b3d make object plain(100,100)
xrotate object null,90
position object null,0,-20,0
phy make rigid body static box null
autocam off
sync on:sync rate 60
do
frame_timer()
control_player()
phy update
sync
loop
Below are my functions:
Function Compiler_Includes()
NULL = EXT Initialized()
EndFunction
function control_player()
gamedata#(1).playerposx=object position x(gamedata#(1).playerobj)
gamedata#(1).playerposy=object position y(gamedata#(1).playerobj)
gamedata#(1).playerposz=object position z(gamedata#(1).playerobj)
gamedata#(1).playerrotx=object angle x(gamedata#(1).playerobj)
gamedata#(1).playerroty=object angle y(gamedata#(1).playerobj)
gamedata#(1).playerrotz=object angle z(gamedata#(1).playerobj)
if upkey()=1 or keystate(17)=1
phy move character controller gamedata#(1).playerobj,20*framex#(0)
else
if downkey()=1 or keystate(31)=1
phy move character controller gamedata#(1).playerobj,-20*framex#(0)
else
phy move character controller gamedata#(1).playerobj,0
endif
endif
if leftkey()=1 or keystate(30)=1
dec gamedata#(1).playerroty,2.5*framex#(0)
else
if rightkey()=1 or keystate(32)=1
inc gamedata#(1).playerroty,2.5*framex#(0)
endif
endif
if spacekey()=1
null=b3d make object cube(10)
position object null,gamedata#(1).playerposx,gamedata#(1).playerposy+20,gamedata#(1).playerposz
phy make rigid body dynamic box null
endif
yrotate object gamedata#(1).playerobj,gamedata#(1).playerroty
set camera to follow gamedata#(1).playerposx,gamedata#(1).playerposy,gamedata#(1).playerposz, gamedata#(1).playerroty,30,15,1,0
endfunction
Function frame_timer()
diff#=(timer()-framelast(0))
ideal#=1000.0/60.0
framex#(0)=diff#/ideal#
if diff#>1000 then framex#(0)=0
framelast(0)=timer()
EndFunction
Function frame_timer_reset()
framelast(0)=timer()
EndFunction
Thanks in advance
-Jim
[EDIT] It's definately the camera... still can't figure it out though x.x
Intel Pentium 4 3.40 Ghz HT, 1.5 GB RAM, Nvidia Geforce 6800, 19" Dell CRT Monitor ... I need to upgrade ^-^