Help with Camera

Hey guys, have a problem that i have been trying to solve on my own for quite some time now, still can’t do it : /

i need to add a camera that can track my car as you drive it around… hope you can help me add one.

I just need help adding it properly , i can work out the tracking myself, if you don’t have some spaced out way to do it…

i know there are some minor glitches, or maybe some bigger ones, i’ll work it out later, the modeling isn’t all done yet either, so no need to tell me^^

the file is far too big to add the source… so i’ll post the code right here. Let me know if you want the source, i can mail it to you.

k, here goes.


import flash.display.*;
import flash.net.URLRequest;

import flash.events.;
import flash.ui.
;
import sandy.core.Scene3D;
import sandy.core.data.;
import sandy.core.scenegraph.
;
import sandy.materials.;
import sandy.materials.attributes.
;
import sandy.primitive.;
import sandy.util.
;
import sandy.events.*;

import flash.events.Event;

import org.papervision3d.core.math.Number3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;

import caurina.transitions.*;

var speed:Number = new Number
speed = 2;
var speed2:Number = new Number
speed2 = 1;

stage.scaleMode = StageScaleMode.NO_SCALE;
var keyPressed:Array = [];

var SR:sideright = new sideright();
var SL:sideleft = new sideleft();
var BB:back = new back();
var WB:windshieldback = new windshieldback();
var WBB:windback = new windback();
var T:top = new top();
var WF:windshieldfront = new windshieldfront();
var H:hood = new hood();
var FF:front = new front();

var ValueX:Number = new Number();
ValueX = -100;
var ValueY:Number = new Number();
ValueY = 0;
var ValueZ:Number = new Number();
ValueZ = -350;
var BackValue:Number = new Number();
BackValue = 0

var container:Sprite = new Sprite();
addChild(container);
container.x = 512
container.y = 600
container.z = 0
container.rotationY = 0

var wheel:tire = new tire();
container.addChild(wheel);
wheel.x = 0 - 50
wheel.y = 0
wheel.z = 0 + 50
wheel.rotationX = 90

var wheel2:tire = new tire();
container.addChild(wheel2);
wheel2.x = 0 + 50
wheel2.y = 0
wheel2.z = 0 + 50
wheel2.rotationX = 90

var wheel3:tire = new tire();
container.addChild(wheel3);
wheel3.x = 0 - 50
wheel3.y = 0
wheel3.z = 0 - 50
wheel3.rotationX = 90

var wheel4:tire = new tire();
container.addChild(wheel4);
wheel4.x = 0 + 50
wheel4.y = 0
wheel4.z = 0 - 50
wheel4.rotationX = 90

SR.x = ValueX + 220;
SR.y = ValueY + 0;
SR.z = 602 + ValueZ;
SR.rotationY = 90

SL.x = ValueX + 0;
SL.y = ValueY + 0;
SL.z = 602 + ValueZ;
SL.rotationY = 90

BB.x = ValueX + 0;
BB.y = ValueY + 80;
BB.z = 0 + ValueZ;
BB.rotationX = 10;
BB.rotationY = 0;
BB.rotationZ = 0;

WB.x = ValueX + 0;
WB.y = ValueY + 70;
WB.z = 110 + ValueZ;
WB.rotationX = 276;
WB.rotationY = 0;
WB.rotationZ = 0;

WBB.x = ValueX + 0;
WBB.y = ValueY + 5;
WBB.z = 148 + ValueZ;
WBB.rotationX = -30;
WBB.rotationY = 0;
WBB.rotationZ = 0;

FF.x = ValueX + 0;
FF.y = ValueY + 85;
FF.z = 601 + ValueZ;
FF.rotationX = -10;
FF.rotationY = 0;
FF.rotationZ = 0;

H.x = ValueX + 0;
H.y = ValueY + 85;
H.z = 602 + ValueZ;
H.rotationX = 267;
H.rotationY = 0;
H.rotationZ = 0;

T.x = ValueX + 0;
T.y = ValueY + 3;
T.z = 390 + ValueZ;
T.rotationX = 269;
T.rotationY = 0;
T.rotationZ = 0;

WF.x = ValueX + 0;
WF.y = ValueY + 5;
WF.z = 383 + ValueZ;
WF.rotationX = 33;
WF.rotationY = 0;
WF.rotationZ = 0;

container.addChild(FF); //9
container.addChild(H); //8
container.addChild(WF); //7
container.addChild(T); //4
container.addChild(BB); //3
container.addChild(WBB); //2
container.addChild(WB); //1
container.addChild(SL); //5
container.addChild(SR); //6

stage.addEventListener ( Event.ENTER_FRAME, enterFrameHandler );
stage.addEventListener (KeyboardEvent.KEY_DOWN, _onKeyDown);
stage.addEventListener (KeyboardEvent.KEY_UP, _onKeyUp);

function _onKeyDown (e:KeyboardEvent):void
{
keyPressed[e.keyCode] = true;
}

function _onKeyUp (e:KeyboardEvent):void
{
keyPressed[e.keyCode] = false;
}
function enterFrameHandler ( event : Event ):void
{
if ((keyPressed[Keyboard.RIGHT]) && (wheel.rotationY < 34))
{
wheel.rotationY += 15/((speed+speed2)/5);
wheel2.rotationY += 15/((speed+speed2)/5);
}
if ((keyPressed[Keyboard.LEFT]) && (wheel.rotationY > -34))
{
wheel.rotationY -= 15/((speed+speed2)/5);
wheel2.rotationY -= 15/((speed+speed2)/5);
}
if (keyPressed[Keyboard.UP])
{
container.rotationY += (wheel.rotationY/(speed/10))
container.z += Math.cos(container.rotationY*(Math.PI/180))speed;
container.x += Math.sin(container.rotationY
(Math.PI/180))speed;
//trace(“up”)
}
if ((keyPressed[Keyboard.UP]) && (speed < 50))
{
speed += 4;
}
if (keyPressed[Keyboard.DOWN])
{
container.rotationY -= (wheel.rotationY/7)
container.z -= Math.cos(container.rotationY
(Math.PI/180))speed2;
container.x -= Math.sin(container.rotationY
(Math.PI/180))speed2;
//trace(“down”)
}
if ((keyPressed[Keyboard.DOWN]) && (speed2 < 20))
{
speed2 += 2;
}
if ((keyPressed[Keyboard.UP] == false) && (speed > 0))
{
speed -= speed/speed
container.rotationY += (wheel.rotationY
(speed/350))
container.z += Math.cos(container.rotationY*(Math.PI/180))speed;
container.x += Math.sin(container.rotationY
(Math.PI/180))speed;
}
if ((keyPressed[Keyboard.DOWN] == false) && (speed2 > 0))
{
speed2 -= speed2/speed2
container.rotationY -= (wheel.rotationY
(speed2/100))
container.z -= Math.cos(container.rotationY*(Math.PI/180))speed2;
container.x -= Math.sin(container.rotationY
(Math.PI/180))*speed2;
}
if (container.rotationY > 360)
{
container.rotationY == 2
}
if (container.rotationY < 0)
{
container.rotationY == 356
}

}


peace