Hello Guys,
This is a new one to ask for help.
Im trying to move an object from the bottom left corner to the centre of the screen - I understand that Get3DVector<>fromscreen commands will convert 2D X,Y
so if I set X=-50 and Y=screenheight-50 - this in theory would like the object to be not displayed until i change the X to increase and Y to decrease.
I may be doing something silly
Here is an example code with X and Y set to be off screen to start with
// Project: CarVUPHeli
// Created: 2019-03-15
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
// set window properties
SetWindowTitle( "CarVUPHeli" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
car = createcar()
body = CreateObjectSphere(3,20,20)
SetObjectColor(body,255,0,0,200)
SetObjectTransparency(body,1)
hat = CreateObjectBox(1,1,1)
SetObjectColor(hat,0,0,200,255)
SetObjectPosition(hat,0,1.5,0)
FixObjectToObject(hat,body)
hat = CreateObjectBox(3,.1,3)
SetObjectColor(hat,0,0,200,255)
SetObjectPosition(hat,0,1.9,0)
FixObjectToObject(hat,body)
eye = CreateObjectSphere(1,20,20)
SetObjectPosition(eye,-.5,.5,-1)
FixObjectToObject(eye,body)
eye = CreateObjectSphere(.3,20,20)
SetObjectPosition(eye,-.6,.6,-1.5)
SetObjectColor(eye,0,0,0,255)
FixObjectToObject(eye,body)
eye = CreateObjectSphere(1,20,20)
SetObjectPosition(eye,.5,.5,-1)
FixObjectToObject(eye,body)
eye = CreateObjectSphere(.3,20,20)
SetObjectPosition(eye,.6,.6,-1.5)
SetObjectColor(eye,0,0,0,255)
FixObjectToObject(eye,body)
nose = CreateObjectSphere(.4,20,20)
SetObjectPosition(nose,0,0,-2)
FixObjectToObject(nose,body)
arm = CreateObjectCylinder(3,.5,10)
SetObjectPosition(arm,0,-20,0)
FixObjectToObject(arm,body)
blades=CreateObjectBox(10,.1,.1)
SetObjectColor(blades,200,200,200,255)
SetObjectPosition(blades,0,2,0)
FixObjectToObject(blades,body)
RotateObjectLocalX(body,20)
RotateObjectLocalZ(car,20)
RotateObjectLocalY(car,270)
SetObjectPosition(car,0,-2,0)
FixObjectToObject(car,arm)
helicopterx#=-100
helicoptery#=screenheight+100
army#=-3
armup=0
do
print(army#)
RotateObjectLocalY(blades,1)
SetObjectPosition(arm,0,army#,0)
if armup=1 then dec army#,.001
if armup=0 then inc army#,.001
if army#>-1
army#=-1
print("DOWN")
armup=1
endif
if army#<-3
army#=-3
FixObjectToObject(car,0)
print("UP")
armup=0
endif
helix# = Get3DVectorXFromScreen(helicopterx#,helicoptery#)*2
heliy# = Get3DVectorYFromScreen(helicopterx#,helicoptery#)*2
inc helicopterx#
dec helicoptery#
SetObjectPosition(body,helix#,heliy#,0)
Print( ScreenFPS() )
Sync()
loop
function createcar()
body = CreateObjectBox(4,5.5,5)
SetObjectScale(body,1.5,.8,1)
SetObjectRotation(body,0,90,0)
SetObjectColor(body,0,0,0,200)
SetObjectTransparency(body,1)
front = CreateObjectSphere(6.7,4,20)
SetObjectScale(front,1.5,.8,1)
SetObjectRotation(front,0,0,0)
SetObjectColor(front,200,0,0,255)
FixObjectToObject(front,body)
wheel = CreateObjectCylinder(7,2,20)
SetObjectPosition(wheel,3,-2,0)
SetObjectRotation(wheel,90,0,0)
FixObjectToObject(wheel,body)
wheelinner = CreateObjectCylinder(7.5,1,20)
SetObjectPosition(wheelinner,3,-2,0)
SetObjectRotation(wheelinner,90,0,0)
SetObjectColor(wheelinner,0,0,0,255)
FixObjectToObject(wheelinner,body)
wheel = CreateObjectCylinder(7,2,20)
SetObjectPosition(wheel,-3,-2,0)
SetObjectRotation(wheel,90,0,0)
FixObjectToObject(wheel,body)
wheelinner = CreateObjectCylinder(7.5,1,20)
SetObjectPosition(wheelinner,-3,-2,0)
SetObjectRotation(wheelinner,90,0,0)
SetObjectColor(wheelinner,0,0,0,255)
FixObjectToObject(wheelinner,body)
eye = CreateObjectCylinder(1,1,20)
SetObjectPosition(eye,4,2,-1)
SetObjectRotation(eye,90,90,0)
FixObjectToObject(eye,body)
eyeball = CreateObjectCylinder(.5,.5,20)
SetObjectPosition(eyeball,4.2,2,-1)
SetObjectRotation(eyeball,90,90,0)
SetObjectColor(eyeball,0,0,0,255)
FixObjectToObject(eyeball,body)
eye = CreateObjectCylinder(1,1,20)
SetObjectPosition(eye,4,2,1)
SetObjectRotation(eye,90,90,0)
FixObjectToObject(eye,body)
eyeball = CreateObjectCylinder(.5,.5,20)
SetObjectPosition(eyeball,4.2,2,1)
SetObjectRotation(eyeball,90,90,0)
SetObjectColor(eyeball,0,0,0,255)
FixObjectToObject(eyeball,body)
radiator = CreateObjectbox(3,2,.1)
SetObjectPosition(radiator,4.9,0,0)
SetObjectRotation(radiator,0,90,0)
SetObjectColor(radiator,0,0,255,100)
SetObjectTransparency(radiator,1)
FixObjectToObject(radiator,body)
bonet = CreateObjectbox(3,3,.1)
SetObjectPosition(bonet,2,3,0)
SetObjectRotation(bonet,-20,90,0)
SetObjectColor(bonet,255,255,255,100)
SetObjectTransparency(bonet,1)
FixObjectToObject(bonet,body)
bonetinner = CreateObjectbox(2.5,2.5,.1)
SetObjectPosition(bonetinner,2.01,3,0)
SetObjectRotation(bonetinner,-20,90,0)
SetObjectColor(bonetinner,100,100,100,100)
SetObjectTransparency(bonetinner,1)
FixObjectToObject(bonetinner,body)
/*car.collidercentre = CreateObjectSphere(1,20,20)
car.colliderleft = CreateObjectSphere(1,20,20)
car.colliderright = CreateObjectSphere(1,20,20)
car.colliderbottom = CreateObjectSphere(1,20,20)
car.collidertop = CreateObjectSphere(1,20,20)
SetObjectVisible(car.colliderbottom,0)
SetObjectVisible(car.collidertop,0)
SetObjectVisible(car.colliderleft,0)
SetObjectVisible(car.colliderright,0)
SetObjectVisible(car.collidercentre,0)
*/
SetObjectScale(body,.3,.3,.3)
endfunction body
Thanks for any assistance
Tier 1 Developer