Hi,
I'm trying to make an object fly around, as if it were subject to a planet's gravity. It works, until the ship reaches one of the poles. Anyone know what I'm doing wrong or how to fix it?
SetErrorMode(2)
// set window properties
SetWindowTitle( "Test" )
SetWindowSize(1280, 720, 0)
// set display properties
SetVirtualResolution(1280, 720)
SetOrientationAllowed( 1, 1, 1, 1 )
global ship
global sphere
sphere = CreateObjectSphere(190, 64, 64)
ship = CreateObjectBox(5, 5, 5)
SetObjectColor(ship, 255, 0, 0, 255)
SetObjectPosition(ship, 0, 0, -105)
SetObjectLookAt(ship, 0, 0, 0, 0)
RotateObjectLocalY(ship, 90)
RotateObjectLocalY(ship, 45)
SetCameraPosition(1, 0, 0, -300)
SetCameraLookAt(1, 0, 0, 0, 0)
do
UpdateShip()
Print( ScreenFPS() )
Sync()
loop
function UpdateShip()
MoveObjectLocalZ(ship, 1)
ray = ObjectRayCast(sphere, GetObjectX(ship), GetObjectY(ship), GetObjectZ(ship), 0, 0, 0)
if ray = 1
ray = GetObjectRayCastHitID(0)
nx# = GetObjectRayCastNormalX(0)
ny# = GetObjectRayCastNormalY(0)
nz# = GetObjectRayCastNormalZ(0)
StableZ(ship, nx#, ny#, nz#)
StableX(ship, nx#, ny#, nz#)
rx# = GetObjectRayCastX(0)
ry# = GetObjectRayCastY(0)
rz# = GetObjectRayCastZ(0)
SetObjectPosition(ship, rx# + (nx# * 5.0), ry# + (ny# * 5.0), rz# + (nz# * 5))
SetObjectLookAt(ship, rx#, ry#, rz#, 0)
RotateObjectLocalX(ship, -90.0)
RotateObjectLocalY(ship, 0)
endif
//SetCameraPosition(1, GetObjectX(ship), GetObjectY(ship), GetObjectZ(ship))
//SetCameraRotation(1, GetObjectAngleX(ship), GetObjectAngleY(ship), GetObjectAngleZ(ship))
endfunction
Thanks,
John
Hi. I am a real person (not a bot). I appreciate all replies and advice.