-
Notifications
You must be signed in to change notification settings - Fork 269
Closed
Description
(Cf., http://away3d.com/forum/viewthread/2961/)
FollowController does not follow the "lookAtObject" when the object is not in the same container as the camera.
I am using this type of thing:
In initEngine() I have:
...
camera = view.camera;
cameraController = new FollowController(camera, null, 45,20);
var _loader:Loader3D = new Loader3D();
_loader.addEventListener(AssetEvent.ASSET_COMPLETE, assetCompleteHnd, false, 0, true);
_loader.loadData(new MeshModel(), assetLoaderContext);
view.scene.addChild(_loader);
...
in assetCompleteHnd(), when it loads the mesh I want to follow, I have:
...
var theMesh:Mesh = e.asset as Mesh;
cameraController.lookAtObject = theMesh;
...
and in the frameHnd(), I have:
...
if (theMesh)
{
theMesh.rotationY += currentRotationInc;
}
cameraController.update();
view.render();
...
That seems to work -- the camera tracks the rotations. However, in updateMovement() I have:
...
theMesh.z += dir * FLY_SPEED;
cameraController.update();
view.render();
...
and the camera does not follow theMesh off into the distance.
After testing a suggestion to put the mesh in the same container as the camera, the FollowController does actually follow correctly:
// does not use: view.scene.addChild(_loader);
// instead, once the mesh is loaded, it is added to the scene
...
var theMesh:Mesh = e.asset as Mesh;
cameraController.lookAtObject = theMesh;
view.scene.addChild(theMesh);
...
Reactions are currently unavailable