(AGK version: 108.24)
Submitted: 2014-12-14 09:17:04
// note: this demo should work in AGk V1 and V2

// press the space bar to have to camera look at the cone

// create a sphere and position it
CreateObjectSphere(1,50,16,16)
SetObjectPosition(1,-100,0,0)

// create a cone and position i
CreateObjectCone(2,50,50,16)
SetObjectPosition(2,100,0,0)

//create a directional light as this makes it easier to see the two objects
CreateLightDirectional(1,-1,-1,0,255,255,255)

SetCameraPosition(1,0,200,-500)

//loop
do

	if getButtonState(1) = 0
		// the camera looks at the sphere is the spacebar or on screen button is not pressed
		SetCameraLookAt(1,GetObjectX(1),GetObjectY(1),GetObjectZ(1),0)
	else
		// the camera look at the cone if the spacebar or on screen button is pressed
		SetCameraLookAt(1,GetObjectX(2),GetObjectY(2),GetObjectZ(2),0)
	endif

	sync()

loop
Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.