/// <summary> /// Create Camera /// </summary> /// <param name="car"></param> private void MakeCamera(GameObject car) { /// Remove Existing cameras if (Camera.allCameras.Length > 0) { for (int i = 0; i < Camera.allCameras.Length; i++) { DestroyImmediate(Camera.allCameras[i].gameObject); } } ///create camera GameObject GameObject newCamera = new GameObject(); newCamera.name = "CarMakerCamera"; ///add scripts to GameObject newCamera.AddComponent <Camera>(); newCamera.AddComponent <AudioListener>(); ///add CarCamera script CarCamera carCamera = newCamera.AddComponent <CarCamera>(); ///asign default camera settings carCamera.carCameraSettingsList = new List <CarCameraSettings>(); carCamera.carCameraSettingsList.Add(CarCameraSettings.GetDefaultSettings0()); carCamera.carCameraSettingsList.Add(CarCameraSettings.GetDefaultSettings1()); carCamera.carCameraSettingsList.Add(CarCameraSettings.GetDefaultSettings2()); ///set camera target to follow carCamera.target = car.transform; }
public void StartTraining() { last_q_values = new float[actions.Length]; abort_learning = false; current_step = 0; current_reward = 0; particle_step = 0; //Setup car components car_camera = GetComponent <CarCamera>(); car_controller = GetComponent <CarController>(); car_body = transform.GetChild(0).GetComponent <Rigidbody>(); //Setup PSO working_particle = 0; particles = new MFNN[max_particles]; for (int i = 0; i < particles.Length; i++) { particles[i] = CreateMFNN(); } particle_swarm = new PSO(particles); network_target = CreateMFNN(); StartCoroutine(TakeStep()); }
void Update() { if (CarActive == true) { PlayerTransform.position = CarTransform.position; } if (Input.GetButtonDown("Vehicle") && CarActive == false) { CarActive = true; CarTransform.position = PlayerTransform.position; car.SetActive(true); CarCamera.SetActive(true); PlayerCamera.SetActive(false); player.SetActive(false); } else if (Input.GetButtonDown("Vehicle") && CarActive == true) { CarActive = false; PlayerTransform.position = CarTransform.position; car.SetActive(false); CarCamera.SetActive(false); PlayerCamera.SetActive(true); player.SetActive(true); } }
public void Start() { network = new MFNN(new int[] { 5, 20, actions.Length }, new ActivationType[] { ActivationType.NONE, ActivationType.ReLU, ActivationType.ReLU }); controller = GetComponent <CarController>(); car_camera = GetComponent <CarCamera>(); }
public void StartTraining() { //Setup action_index = 0; current_step = 0; learn_step = 0; is_activated = true; load_weights = false; log = new List <string>(); last_q_values = new float[actions.Length]; //Setup memory memory_index = 0; network_memory = new MemoryStructure[memory_size]; //Setup networks network_eval = new MFNN( new int[] { 5, 20, actions.Length }, new ActivationType[] { ActivationType.NONE, ActivationType.ReLU, ActivationType.ReLU }); network_target = new MFNN( new int[] { 5, 20, actions.Length }, new ActivationType[] { ActivationType.NONE, ActivationType.ReLU, ActivationType.ReLU }); //Setup epsilon max_epsilon = 0.9f; epsilon = 0.0f; //Setup car components car_camera = GetComponent <CarCamera>(); car_controller = GetComponent <CarController>(); car_body = gameObject.transform.GetChild(0).gameObject.GetComponent <Rigidbody>(); //Reset Car car_body.transform.position = car_spawner.transform.position; car_body.transform.rotation = car_spawner.transform.rotation; car_body.velocity = Vector3.zero; car_body.angularVelocity = Vector3.zero; action_index = 0; reset_step = current_step; current_reward = 0; //Start loop StartCoroutine(DQNStep()); log.Add("Training Started"); }
public OrbitCamera(CarCamera outerObject) { m_outerClassObject = outerObject; m_camLocation = new Vector3(m_outerClassObject.fOriginalDistance, 0.0f, 0.0f); m_targetRotation.y = m_outerClassObject.transform.eulerAngles.y; //Setting target location m_targetLocation = m_outerClassObject.target.position + m_outerClassObject.target.up * m_outerClassObject.fTargetHeight; m_prevTargetLocation = m_targetLocation; //TestKalmanFilter(); TargetDirQueue = new Queue <Vector3>(); }
// private SceneView sceneView; public override void OnInspectorGUI() { base.OnInspectorGUI(); if (GUILayout.Button("Use current viev")) { CarCamera _target = target as CarCamera; //sceneViews = SceneView.sceneViews; if (_target.follow) { // sceneView = (SceneView)sceneViews[0]; // _target.sceneViewFollowers[0].positionOffset = sceneView.camera.transform.position - _target.follow.transform.position; // _target.sceneViewFollowers[0].fixedRotation = sceneView.rotation.eulerAngles; } } }
private void SpawnPlayer() { GameObject camera = GameObject.Find("Main_Camera"); CarCamera cameraScript = camera.GetComponent <CarCamera>(); Sp1 = GameObject.Find("Sp1").transform; if (!isWhite) { car = Network.Instantiate(playerPrefab, Sp1.position, Sp1.rotation, 0) as GameObject; target2 = car.transform; cameraScript.target = target2; } else { car = Network.Instantiate(playerPrefab2, Sp1.position, Sp1.rotation, 0) as GameObject; target2 = car.transform; cameraScript.target = target2; } }
// ------------------------------------------------------------------------ // // Use this for initialization void Start() { this.tool_gui = this.GetComponent <ToolGUI>(); // カメラのインスタンスを探しておく. this.main_camera = GameObject.FindGameObjectWithTag("MainCamera"); this.tool_camera = this.main_camera.GetComponent <ToolCameraControl>(); this.game_camera = this.main_camera.GetComponent <GameCameraControl>(); this.car_camera = this.main_camera.GetComponent <CarCamera>(); this.tool_camera.enabled = true; this.game_camera.enabled = false; this.car_camera.enabled = false; this.game_control = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControl>(); this.game_control.tool_control = this; // this.line_drawer = (Instantiate(this.LineDrawerPrefab) as GameObject).GetComponent <LineDrawerControl>(); this.line_drawer.root = this; this.waku_object = GameObject.Find("waku"); // this.road_creator = new RoadCreator(); this.tunnel_creator = new TunnelCreator(); this.forest_creator = new ForestCreator(); this.buil_arranger = new BuildingArranger(); this.jump_slope_creator = new JumpSlopeCreator(); this.junction_finder = new JunctionFinder(); this.tunnel_creator.TunnelPrefab = this.TunnelPrefab; this.tunnel_creator.road_creator = this.road_creator; this.tunnel_creator.main_camera = this.main_camera; this.tunnel_creator.tool_gui = this.tool_gui; this.tunnel_creator.create(); this.forest_creator.TreePrefab = this.TreePrefab; this.forest_creator.road_creator = this.road_creator; this.forest_creator.main_camera = this.main_camera; this.forest_creator.tool_gui = this.tool_gui; this.forest_creator.create(); this.buil_arranger.BuildingPrefabs = this.BuildingPrefabs; this.buil_arranger.road_creator = this.road_creator; this.buil_arranger.main_camera = this.main_camera; this.buil_arranger.tool_gui = this.tool_gui; this.buil_arranger.create(); this.jump_slope_creator.JumpSlopePrefab = this.JumpSlopePrefab; this.jump_slope_creator.road_creator = this.road_creator; this.jump_slope_creator.main_camera = this.main_camera; this.jump_slope_creator.tool_gui = this.tool_gui; this.jump_slope_creator.create(); this.junction_finder.create(); // this.game_camera.road_creator = this.road_creator; this.step = STEP.EDIT; }
void Awake() { instance = this; camUpdateListener = new List <ICameraUpdateListener>(); }
void Start() { carCamera = gameObject.GetComponent<CarCamera>(); switchCamera(); }
void Start() { carCamera = gameObject.GetComponent <CarCamera>(); switchCamera(); }
public FixateCamera(CarCamera outerObject) { m_outerClassObject = outerObject; }