class CameraLogic : ZilchComponent { var TargetObject : Cog = null; function Initialize(init : CogInitializer) { this.TargetObject = this.Space.FindObjectByName("Player"); Zero.Connect(this.Space, Events.LogicUpdate, this.OnLogicUpdate); } function OnLogicUpdate(event : UpdateEvent) { // create a new variable to hold the player's position var newCameraPos = this.TargetObject.Transform.LocalTranslation; // save the camera's z value newCameraPos.Z = this.Owner.Transform.LocalTranslation.Z; // set the camera's new position to newCameraPos this.Owner.Transform.LocalTranslation = newCameraPos; } }