Search Unity

Switch level & save at new loaded scene BOLT - Looking for Magic!

Discussion in '2D' started by AlleJong, Jan 14, 2020.

  1. AlleJong

    AlleJong

    Joined:
    Jan 7, 2016
    Posts:
    13
    Dear Minds of the Unity Universe,

    Visual Studio does not recognize any of My written code as copied after tutorials, every script I wrote - Always broken. I have an new laptop, everything fresh installed since a few weeks. I worked intense with UE4 before and understand concepts of game design. I have the plan to keep things extremly simple. I thought about setting an fence around some basic technical elements of unity before start building the game itself. Then I want to fully be able to concentrate on My creativity only. To keep full control and concentrate on the most important aspect, imagination.
    My game setup has no player character, only one main camera for panning and zoom, and some clickable and animated sprites of which some hide other sprites that when clicked open new scenes or elements of the story. That is the whole setup, simple gameplay elements, but, when used properly can create an meaningfull experience.
    My game will become some kind of interactive ''Novel/open world exploration journey'', with specific tasks and thoughtfull placed animated interactions with the environments hinting where to look, or speak to people to understand how to develop Your way troughout the story. With limited gameplay mechanics I think something special can be accomplished, But still an save system is important at some spots, and an level switching setup needs to be working.

    I need to overcome the following:

    - Switch from one level/scene to another (I have BOLT, need an trigger by raycasting from the an player? Have only an Camera, Have no character I did read about Player files, controllers? )
    - AutoSave function for camera only from some new loaded scenes? This is only important for if someone closes the game and does not have to replay the whole game.


    Thanks for everyone who has tips or trics, Bolt works quite consistent, If I could only change the Playerprefs camera position on new scene load, or switching levels with Bolt, that would solve everything I need, those two technical elements. I almost mastered everything I need to start building an actual videogame.



    for My art go to: www.allejong.com
     
    Last edited: Jan 14, 2020
  2. AlleJong

    AlleJong

    Joined:
    Jan 7, 2016
    Posts:
    13
    Solved the level switching on mouse click on object by succesfull writing an code file myself. For everyone who has never scripted before and is totally lost, Here is How I did this:

    > I started to understand You can check errors by double click on these red warnings shown in the Unity editor, if You have Visual Studio installed on windows it will automatically start Your created script script in that programm and show You at which line something is mysterious wrong, because it will not give You the exact answer, you will have to play a bit.
    > It seems an Bracket the { and } symbols are very sensitive how thery are placed. I got errors like ''cs1514'' which ment the Bracket for ending an line where somehow located wrong. In my case I did not place one of these Brackets ….. }{{}}{}{}{ }….. (these ara a bunch of those bloody sensitive brackets) correctly around line 13? One } solved somehow the problem.
    > Copying and paste errors directly by CRTL+C from unity in google is also an good way to start searching for answers.
    > Also important for the script below! Do not forget to add Your levels to the Build settings, otherwise You still get an error about that after that. Go to File > Build Settings, and add levels.

    The whole script for changing an level on mouse click on object (Drag this script onto any Object, make also sure it has an collider attached:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class scene1 : MonoBehaviour
    7. {
    8.      private void OnMouseDown()
    9.     {
    10.         SceneManager.LoadScene("Scene2");
    11.     }
    12.  
    13. }
     
    Last edited: Jan 14, 2020
    sinjinn likes this.