yh a lerp would be nice but this might work... looks ok in a quick test - hard to tell from a flat perspective but i did add a nose just to see which way he's facing
cube = CreateObjectBox(1.5,2,1)
SetObjectPosition(cube,-2,0,10)
nose = CreateObjectCone(0.5,0.5,0.5)
SetObjectRotation(nose,90,0,0)
SetObjectPosition(nose,0,0,0.5)
FixObjectToObject(nose,cube)
SetObjectColor(nose,255,0,0,255)
capsule = CreateObjectCapsule(1,1,1)
lookSpeed = 1
do
curx = GetObjectAngleX(cube)
cury = GetObjectAngleY(cube)
curz = GetObjectAngleZ(cube)
Print(desiredangx)
Print(desiredangy)
Print(desiredangz)
Print(curx)
Print(cury)
Print(curz)
if GetRawKeyReleased(27) then end
if GetPointerPressed()
mousex# = GetPointerX()
mousey# = GetPointerY()
// Get 3D vector of where we clicked
dist = Random2(20,50)
VecX# = Get3DVectorXFromScreen( mousex#, mousey# ) *dist
VecY# = Get3DVectorYFromScreen( mousex#, mousey# ) *dist
VecZ# = Get3DVectorZFromScreen( mousex#, mousey# ) *dist
CamX# = GetCameraX(1)
CamY# = GetCameraY(1)
CamZ# = GetCameraZ(1)
SetObjectPosition(capsule,CamX#+VecX#,CamY#+VecY#,CamZ#+VecZ#)
SetObjectLookAt(cube,getobjectx(capsule),getobjecty(capsule),getobjectz(capsule),0)
desiredangx = GetObjectAngleX(cube)
desiredangy = GetObjectAngleY(cube)
desiredangz = GetObjectAngleZ(cube)
SetObjectRotation(cube,curx,cury,curz)
endif
frameTime# = GetFrameTime()
RotateObjectLocalX(cube,(desiredangx-curx)*frameTime#*lookSpeed)
RotateObjectLocalY(cube,(desiredangy-cury)*frameTime#*lookSpeed)
RotateObjectLocalZ(cube,(desiredangz-curz)*frameTime#*lookSpeed)
sync()
loop
life's one big game
spec= i5 4ghz, 16gb ram, Nvidia 1070ti gpu