# Camera pivot in Papervision, and Overiding

**URL:** https://forum.kirupa.com/t/camera-pivot-in-papervision-and-overiding/279060
**Category:** flash
**Created:** [January 8, 2009, 11:47pm UTC](https://forum.kirupa.com/t/camera-pivot-in-papervision-and-overiding/279060 "2009-01-08T23:47:44Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Myung](https://avatars.discourse-cdn.com/v4/letter/m/ee59a6/32.png) [@Myung](https://forum.kirupa.com/u/Myung)
#### Post date: [January 8, 2009, 11:47pm UTC](https://forum.kirupa.com/t/camera-pivot-in-papervision-and-overiding/279060/1 "2009-01-08T23:47:44Z")

</div>

Hi.

I’m trying to set a DisplayObject3D as a parent to a Camera3D.  
the addChild(Camera) won’t work…

So I tried to make a new class: cCameraPivot that is inherited from DisplayObject3D, but there seems to be a problem with the overriding of the properties (x, y, z, rotationX, etc. etc…)

In the overiding setter I have no access to the defined camera of the pivot.

Here is the code:

```auto
 
package  
{
 import org.papervision3d.cameras.Camera3D;
 import org.papervision3d.objects.DisplayObject3D;
 import org.papervision3d.core.proto.GeometryObject3D;
 
 
 public class cCameraPivot extends DisplayObject3D
 {
  public var Cam :Camera3D;
  private var camPos :DisplayObject3D;
 
  public function cCameraPivot(camera:Camera3D, name:String = "pivot", geometry: GeometryObject3D = null)
  {
   super(name, geometry);
   Cam = camera;
   camPos = new DisplayObject3D();
   camPos.copyTransform(Cam);
   this.addChild(camPos);
 
  }
 
  public override function set x(value:Number):void {
   camPos.copyTransform(Camera);
   super.x = value;
   Camera.copyTransform(camPos);
  }
 
 }
 
}
 

```

I get this message on running:

[COLOR=red]TypeError: Error #1009: Cannot access a property or method of a null object reference.[/COLOR]  
[COLOR=red]at cCameraPivot/set x()[C:\Data\Projects\Treepodia\PV Test 3\src\cCameraPivot.as:27][/COLOR]

whice is the first line in the setter of X.

What can be done???

TNX
