A Flash Developer Resource Site

# Thread: Help with 3D camera motion

1. ## Help with 3D camera motion

Hi,

I'm building a primative pseudo-3D engine and it's almost working. It can handle movement along any axis and rotation around the z axis. My problem is that something is throwing the calculations off if the camera movement includes rotation. My code is below and I have attached a swf (Click to activate the camera motion) The camera should end up centered on the large target, but misses it and I can't work out why.

Really need some help on this. Thanks.

Code:
```private function manageMove():Void{
for(var i:String in item_ob){
var myOb:MovieClip = item_ob[i];
//Modify coordinates
myOb.x += velX;
myOb.y += velY;
myOb.z += velZ;
//Modify Zaxis rotation
var cosZ:Number = Math.cos(velR);
var sinZ:Number = Math.sin(velR);
var x1:Number = myOb.x * cosZ - myOb.y * sinZ;
var y1:Number = myOb.y * cosZ + myOb.x * sinZ;
myOb.x = x1;
myOb.y = y1;
//Check legal and wrap
myOb._visible = (myOb.z <= -FL) ? false : true;
if(myOb.wrap){
if(myOb.z <= -FL){
myOb.z += maxZ;
}else if(myOb.z > maxZ - FL){
myOb.z -= maxZ;
}
}
//Scale Alpha and Depths
var scale:Number = FL / (FL + myOb.z);
myOb._xscale = myOb._yscale = scale * 100;
myOb._alpha = scale * 70 + 30;
myOb.swapDepths(-myOb.z);
//Move Object
myOb._x = myOb.x * scale;
myOb._y = myOb.y * scale;
}
}```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

 » Home » Movies » Tutorials » Submissions » Board » Links » Reviews » Feedback » Gallery » Fonts » The Lounge » Sound Loops » Sound FX » About FK » Sitemap