Author Topic: Set transform for camera so it aims at a given position  (Read 1195 times)

Hey,

Let's say we've got our %cam = %client.player.camera;
How do we set the rotation of the camera so it aims at our %pos?

You can only rotate it horizontally. Not vertically.


are you talking about making a player look at something, or giving them a camera view of something

you can take a peek into the default camera control events, or my camera control advanced version.

if you want to give the camera free roam ability you can set its control object to itself; otherwise set the camera control object to %client.dummycamera. This makes the camera position and orientation fixed.

This is where the camera is placed. I don't understand.

Code: [Select]
%player = %client.player;
%raycast = containerRaycast(%player.getEyePoint(), VectorAdd(%player.getEyePoint(),VectorScale(%player.getForwardVector(),5)),$Typemasks::All);
if(%raycast !$= "")
%pos = getWords(%raycast,1,3);
else
%pos = VectorAdd(%player.getEyePoint(),VectorScale(%player.getForwardVector(),5));
  %delta = vectorSub(%player.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);
%cam=%client.camera;
%cam.setTransform(%pos SPC %aa);
%cam.setFlyMode();
%cam.mode = "Observer";
%client.setControlObject(%cam);
%cam.setControlObject(%player);
« Last Edit: June 04, 2016, 06:04:49 PM by Quartz »

you should shrink that picture (use width=900 in the image tag like [img width=900]), take another picture of the setup and the direction your player is facing before doing the camera, and explain what we should actually be looking at

you should shrink that picture (use width=900 in the image tag like [img width=900]), take another picture of the setup and the direction your player is facing before doing the camera, and explain what we should actually be looking at
Before the camera the player was 50% vertical. The camera is aiming straight down from the players eyePoint.