2
$\begingroup$

I want to create the following effect:

When a keyboard control is pressed the main camera will be switched to another camera that already exists in the scene. At that time till the camera is switched back, everything at the scene where both cameras exist must remain as is with no change, except a few things of my choosing.

How can I achieve this? I thought of suspending the scene but I want to be able to move the new camera.

My 2nd thought was changing all objects to different states when I set the new camera so they won't move at all, but that will mess with scripts and it is confusing.

My 3rd thought was a bit more complicated but till a point I think correct. It was the following idea: What if I add the new camera in the original scene and create a new overlay scene with one new camera there also. Now everytime I switch to the new camera in the original scene, I'll suspend the original scene and add the overlay scene with a small delay so that it will seem that it is the same "new" camera. But there is a problem. How can I save any motion done with the camera in the overlay scene to be copied to the "new" camera in the original scene?

I hope I did not make this too complicated. Any ideas?

$\endgroup$

1 Answer 1

1
$\begingroup$

Switching a camera is pretty easy with the Scene Actuator in "Set Camera" mode.

Switching controls/behavior is independent from the camera, as it has no relation to what is rendered. Typically you "enable" a set of controls while you "disable" another set of controls.

There are many ways to achieve this effect. The basic idea is that each entity remembers if it is enabled or disabled (= state) and acts accordingly.

Additionally you need a way to request one or multiple state changes e.g. via property change, message listening or other events.

Example: When receiving message "enable security camera", you

  • let the camera switch to the security camera,
  • disable the current controls on the player's avatar
  • enable the controls on the security camera
  • ...

When receiving message "enable security camera", you

  • let the camera switch to the player's camera,
  • disable the controls on the security camera
  • enable the controls on the player's avatar
  • ...

if you have a lot of such objects and possible toggles, you might want do this is two steps:

  • disable all
  • enable what was requested

This way you do not care the previous state.

$\endgroup$
2
  • $\begingroup$ By disabling all you mean adding another state to every object that I want to remember its state and stay still during the switch? Is there a faster way? Also, what if an object has 2 states already and this "idle" state is the 3rd? How will it remember to come back to state 1 or state 2? Properties again? $\endgroup$
    – Lev
    Commented Oct 21, 2015 at 13:54
  • $\begingroup$ Yes, as each object has it's own operations it needs its own state handling too. An alternative would be to dynamical create and remove objects, which is also a sort of state (existence). In a state system it is no problem to add further states as long as the value range allows more states (e.g. a boolean property can only have two states). I recommend to use the build-in state system. $\endgroup$
    – Monster
    Commented Oct 22, 2015 at 5:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .