Code snippet slightly inaccurate

The following code snippet is slightly inaccurate… It has you “lookAt” the node before you attach the camera to it, if you have your target at anywhere but the point of orgin, this won’t make it look in the correct spot… really you should set “lookAt” after you attach the camera?

[java]// Disable the default flyby cam


//create the camera Node

camNode = new CameraNode(“Camera Node”, cam);

//This mode means that camera copies the movements of the target:


//Move camNode, e.g. behind and above the target:

camNode.setLocalTranslation(new Vector3f(0, 5, -5));

//Rotate the camNode to look at the target:

camNode.lookAt(target.getLocalTranslation(), Vector3f.UNIT_Y);

//Attach the camNode to the target:


it is obvious. it is not a controller. it is just a method making actually camera looking at target from actual position in actual Node(when you attach standard location is 0,0,0) :wink:

it just seem it need a node

what is trouble in that? just make it after attach.

if you want you can write controller making lookAt each frame :wink:

ohh i was so stupid and thinked you use Camera without CameraNode. So i thinked it dont follow target object. sorry it was 2:00 am for me when i was writing it.

Usually we start at 000 and position things that need to rotate around 000, otherwise the rotation is crooked. And later you move the target… I don’t recall the context in this case.

Is that from the camera wiki page? I’ll add a clarification later today (typing from phone) :wink:

Actually the test case does it your way.

Where is that code snippet from?

The code i copied is the code that is IMHO doing it wrong, its from this page here[]=chase&s[]=camera

1 Like

@nehon i just looked at the test case, the way it does it was indeed the way i was suggesting…

I fixed the wiki. Thanks for reporting this.