Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Entering Battle transition

Discussion in 'Scripting' started by Brokencutlass, Oct 17, 2019.

  1. Brokencutlass

    Brokencutlass

    Joined:
    Mar 18, 2019
    Posts:
    110
    I have a basic scene with movement, combat, saving, stats, etc completed. However, I do not want combat to take place on the same scene as movement.
    Instead when you run into an enemy, I want to to "transition" you to a smaller combat area where the fight actually happens.

    How would one go about this? Anyone have advice or a good tutorial?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    Unity is perfectly set up for this with Scenes. The trick is maintaining all the persistent state you want, but NOT in the scene itself.

    Instead, maintain it in a GameManager marked as DontDestroyOnLoad that the scenes call in order to figure out how to set themselves up. There are tons of tutorials on GameManagers all over the interwebs.

    That way you do movement scene, then switch to combat scene, then switch back.

    If that is too intrusive to your flow, or would take too much refactoring, you might be able to get a list of all objects in the movement scene, set them all inactive (keep that list!), then load your combat scene additively, run it, and when it is over, unload the combat scene, and reactivate all the other objects from the movement scene.

    This may however have side effects when scripts and components on the movement screen are turned off and turned back on. It shouldn't, but sometimes it might, depending on your choice of Awake(), OnEnable(), OnDisable(), etc.
     
    AFineCuppaJoe likes this.
  3. Brokencutlass

    Brokencutlass

    Joined:
    Mar 18, 2019
    Posts:
    110
    Ok so took a shot at this with the code I already have. Figured loading a battlescene would be the same as loading any other scene upon running into a foe's collider.
    So far, it begins to load but won't take me to the other scene, and the enemy will not load with it lol.

    I've used my regular portal script on an enemy, linking to another scene but some reason it isn't working.
    Also...really inspiring to see a complete lack of willingness to help a beginner out.
     
    Last edited: Oct 17, 2019