Author Topic: Camera aim at [Solved]  (Read 873 times)

I don't really know where to start, how would I make the camera object aim at a position

Solution:
Code: [Select]
%pos = %posBrick.getPosition();
   %delta = vectorSub(%targetBrick.getPosition(), %pos);
   %deltaX = getWord(%delta, 0);
   %deltaY = getWord(%delta, 1);
   %deltaZ = getWord(%delta, 2);
   %deltaXYHyp = vectorLen(%deltaX SPC %deltaY SPC 0);

   %rotZ = mAtan(%deltaX, %deltaY) * -1;
   %rotX = mAtan(%deltaZ, %deltaXYHyp);

   %aa = eulerRadToMatrix(%rotX SPC 0 SPC %rotZ); //this function should be called eulerToAngleAxis...

   %camera.setTransform(%pos SPC %aa);
« Last Edit: November 18, 2013, 06:03:49 PM by swollow »

Doesn't one of your add-ons have this option?

Doesn't one of your add-ons have this option?
no I wouldn't be asking then, its easy to get the rotation of the camera, what I'm trying to do is to aim the camera at an object, which involves some complex math I don't understand (yet)

Look at the default camera events.