Game Development Community

Zoom help.

by Simon Carlsson · in Torque Game Builder · 05/24/2010 (5:23 am) · 4 replies

Is it posible to make the camera zoom in when two object comes closer and zoom out when they go apart from eachother.

edit. please tell me also were to write the script.

#1
05/24/2010 (7:02 am)
Anything is possible. There are an infinite number of solutions to this behavior. My approach would be to look for the range between objects in the scene onUpdate callback, then call your zoom-in function when the objects are within range and zoom-out when out of range.
#2
05/25/2010 (5:22 am)
im sorry but im a beginner at this so the easiest way is what i need.
#3
05/25/2010 (9:51 am)
just get the positions of each and measure the distance in an onUpdate().


so in onUpdate()
%this.object1Pos = %this.object1.getPosition();
%this.object2Pos = %this.object2.getPosition();
%distBetween = t2dVectorDistance(%this.object1Pos, %this.object2Pos);


then write an if statement.

if %distBetween > 1, set zoom to X
if %distBetween < 1, set Zoom to X3


etc etc.

#4
05/25/2010 (2:12 pm)
thank you^^