Hi all, I create a strategy and want to learn the best way how to implement switching RTS mode to FPS and back. For example: I choose my unit, pressed F button and now i can see control unit like FPS, pressed F again and go back to RTS mode. Thnx. P.S. Sorry for my english.
I would give every unit a disabled camera. When you press "f", you disable the rts-camera and enable the one with the unit.
Ok, but with this way u can only change camera view, but what about control system ? I mean in RTS ur mouse move camera, select units etc. but if i just change camera i can't shoot, move etc. in FPS mode, so i think i must disable RTS scripts that responsible for RTS action and enable FPS scripts, but how to do it right ?
You could use game states to trigger what runs what. Could get messy if you combine everything into one script (which is what I do but I manage them properly). If you need to disable a script, just set that script enabled to false. If you want to use the script, make sure the enabled is true.
You save the eye position(this should be standart for your units) and lerp the camera position according to the controlled unit and/or the top view. EDIT: You also indicate which character controller or transform(whatever your units use) to be controlled by the script.
Hi, Just an impro : Code (csharp): public class ModeSwitcherScript : MonoBehaviour { private int CurrentMode = 0; // 0 : rts ; 1 : fps // Other var // Use this for initialization void Start () { // Init } // Update is called once per frame void Update () { //1) Switch mode procedure // If a unit is selected and 'F' is pressed // Then invert CurrentMode if("If a unit is selected and 'F' is pressed") { CurrentMode = CurrentMode == 0 ? 1 : 0; switch(CurrentMode) { case 1: // RTS -> FPS // Disable RTS scripts // Enabled FPS scripts (FPS controller...) // Move camera to unit's head pos/ori using interpolation break; case 0: // FPS -> RTS // Disabled FPS scripts (FPS controller...) // Enable RTS scripts // Move camera on top of unit adn adjust rotation as you prefer break; } } //2) CurrentMode ? switch(CurrentMode) { case 0: // RTS RunRTSstuff(); break; case 1: // FPS RunFPDstuff(); break; } } }