1

for my university research, I am currently building a simulation environment via Unity (including a drone which has to fly through a factory).

What I have done:

  • created environment
  • implemented a drone (includes the controller-script and the engine-script, which were a template)
  • created a user-interface with "buttons" which are connected with the script-method "FlyToPosition"
  • by clicking the wanted button (landing station) the drone takes of, flies to aim and lands there.
  • the main camera via camera-script follows the drone the whole game-mode

What I want to edit additionally:

  • ability to change the camera-perspective by selecting a dropdown in the UI (for example the POV-Camera looking down)
  • ability to fly to the upper floor. The Controller-Script makes the drone first take off, which reveals a crash with the hall-ceiling. My idea: create a station outside hall, which will be flown first, then taking off to the right height of the landing position.

I need help by creating the required scripts. If you would contact me, I would be so glad working on my issue. I am around for teams, zoom etc. If you think you could help, I will send you my current C#-Scripts and the Unityproject-file.

Looking forward for you help. See you!

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • Welcome to Stack Overflow. Please read about [asking questions](https://stackoverflow.com/help/asking). Asking folks to contact you off Stack Overflow is inappropriate. – Jason Aller Oct 04 '21 at 16:06

1 Answers1

0

You could just attach more cameras to your drone, set them to your desired positions. And then in code just have references for them and based on some button set chosen camera to be active. Let's say you have 3 cameras:

public GameObject cam1;
public GameObject cam2;
public GameObject cam3;

Attach corresponding camera objects through the inspector, and then based on some input just use setActive respectively. I wrote a simple function for you, just call activateCam(nr); where nr is the number of your camera and it's done.

private void activateCam(int nr)
{ 
  switch (nr)
    {
    case 1:
      cam1.setActive(true);
      cam2.setActive(false);
      cam3.setActive(false);
        break;
    case 2:
      cam1.setActive(false);
      cam2.setActive(true);
      cam3.setActive(false);
        break;
    case 3:
      cam1.setActive(false);
      cam2.setActive(false);
      cam3.setActive(true);
        break;
    }
}

The only thing you need to figure out is how you want the user to be able to switch the cameras. Whether it's a button or a keyPress, it's up to you, just use this function. I hope it's helpful :)

mateuszK23
  • 61
  • 6