void Update() { if (Input.GetKeyDown(KeyCode.Q)) { if (vehicleController.Armed) { vehicleController.Disarm(); } else { vehicleController.Arm(); } } if (Input.GetKeyDown(KeyCode.O)) { vehicleController.EnableOffboard(); } if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) // moves right { position.x += 0.3f; } if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) // left { position.x -= 0.3f; } if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) // forwards { position.z += 0.3f; } if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) // backwards { position.z -= 0.3f; } if (Input.GetKey(KeyCode.Space)) { position.y += 0.2f; } else { if (position.y - 0.1f > 0) { position.y -= 0.1f; } } vehicleController.PoseDesired.Position = position; vehicleController.Update(); }
void Update() { if (Input.GetKeyDown(KeyCode.Q)) { if (vehicle.Armed) { vehicle.Disarm(); } else { vehicle.Arm(); } } if (Input.GetKeyDown(KeyCode.O)) { vehicle.EnableOffboard(); } if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A)) { pos.x -= 0.5f; } if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D)) { pos.x += 0.5f; } if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W)) { pos.z += 0.5f; } if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S)) { pos.z -= 0.5f; } if (Input.GetKey(KeyCode.Space)) { pos.y += 0.5f; } else if (pos.y > 0) { pos.y -= 0.25f; } vehicle.PoseDesired.Position = pos; //vehicle.PoseDesired.Rotation = vehicle.PoseActual.Rotation; vehicle.Update(); drone.transform.position = vehicle.PoseActual.Position; //drone.transform.rotation = vehicle.PoseActual.Rotation; }