[SOLVED] Switch camera and controls with key press

I’m designing it so that when the pop-up message appears you have the option of pressing x, which if true leads to the user input controls switching over to the dronecar, as well as the camera angle to inside the dronecar.

I want it to have a pop-up message at the bottom left corner while inside the dronecar that says Press Y to switch camera angles to “third person birds eye view”. User input of dronecar controls don’t switch here.

Pressing X again will exit you out of the dronecar and the dronecar will fall to the ground.

I’m laying out everything now because it might be better to do certain things before others, but also want you to have foresight.

This simulation is to demonstrate the emergency action plan of the parachutes releasing over the ocean that I have a level designer working on.

Sorry for the long thread, but at the same time I just want to make incremental progress towards the end goal. I don’t care if it has to take two years lol I need this to show investors how the dronecar works, so if you have the physics background to be able to make a dronecar hover and whatever else to make the old iteration better https://www.lorenzmotors.com/dronecar (scroll to bottom of the page), please help and I will compensate you.

Hi @Lorenzmotors,

One way to approach this is to have two cameras, each with its own player controller script.

To switch between the two, disable the active camera, and enable the other one.

The sensitive part on the process is in your script you need to pause/disable any input receivers for the disabled camera. That won’t happen automatically if you are using event input handlers (e.g. for keyboard, mouse), you will have to detect inside those methods if the entity is disabled, and exit the method.

2 Likes

So, I want to incrementally progress with your guidance, because everything you said makes sense, I just need to practically integrate your logic. Am I doing this right? I made two entities which contains the camera property for inside the dronecar camera perspectives.

Is this the best approach given that I’ll also want to switch to the dronecar controls (from first person walking controls) upon disabling the first camera/controls.

I know this is a bit complex explaining everything in english, but if you show me where to put things with the relevant code I should be able to understand/fix it up.

Hi @Lorenzmotors!

One is the current Player entity. This is already working as far I have seen. The other will be your Dronecar entity. Add a camera to your Dronecar entity and set the correct view. Add a script to your Dronecar entity that can control your dronecar.

When you are inside the dronecar you disable the script and camera of the Player entity and enable the script and camera of the Dronecar entity. When you are outside the dronecar you disable the script and camera of the Dronecar entity and enable the script and camera of the Player entity.

When you’re done with the setup, I can help you to make the switch work.

1 Like

Thank you, you answered that very clearly.
I applied the first person pov and third person pov cameras as child entities to the dronecar parent entity. Is this okay?

I then wrote out the pseudocode for the dronecar controls.

I’ve applied all of the above in the project below.

https://playcanvas.com/project/918532/overview/dronecarsimulatorfork

I need one camera to be first person POV, and then if you press P it switches to third person.


First person

Third person

If this is just a static camera, it’s easy to add. I will update the forked project later today.

Yes static camera. Thank you!

Done.

Thank you, I forked off your project; no need to reinvent the wheel, so to speak, I hope that’s okay. Do you know how to disable the ‘press x…’ message and enable a ‘press p… to change pov’ message?

Since your current setup isn’t practical for just changing the text, I won’t get into that.

I did it anyway and updated the forked project. :upside_down_face:

1 Like