Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to test a level halfway without completing the first half?

Discussion in 'Scripting' started by Jip1912, Jul 13, 2017.

  1. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    Hi,

    When I want to test something of my level (which I have to do non-stop because everything has to be timed perfectly), I first have to complete everything that comes before that part. Let's say I want to test the level when being at 75% of the level. Then I first have to complete (play) everything that comes before that. Also I can't just place my player halfway the level because everything is synchronised with the music, which starts at the beginning of the level. So what can I do to do quick tests, to see if the blocks are well timed with the music?
    This is, without the scenery, how my game looks like so you can imagine what I mean:

    As you can see, on the last part it isn't synchronised. If I want to change this and test it, I first have to do the whole level again (and this is only 1/5 of the level).
    So how do I test it immediately halfway?
     
  2. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    So... there isn't really a 'simple' way to accomplish what you want.

    And how you do it is highly dependent on your game's structure.

    For instance, the game we're currently on is a survival horror, which is basically a full map where regions are locked off and you go through branching sequences of events. To test out halfway through, we basically structure our events as GameObjects that are ticked off as you complete them one by one. So if we want to go to 50% in, we just disable the GOs that represent the first 50% of the map, and teleport the player to that position.

    But your game on the other hand is so specific to what occurs before it. I don't know what I'd do structurally to make it work. Maybe insert checkpoints along the way (dev checkpoints)...

    Basically you test the game, you get 6 or 10 blocks in or whatever, and you know those are all timed just right, so you drop a GameObject there with a dev script that denotes what time you 'should' be at when you get to that point. Then in the Start of that script you teleport the player to that location, faster forward the music to that point, and do maybe any other stateful stuff that you might need.

    Now disable that script and press play to start from the beginning, enable it and press play to start from that point.
     
    Kiwasi likes this.
  3. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Alternatively, speeding up time by changing the time scale might be an option?
     
  4. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Maybe a good project to try 2017.1 timeline features with?
     
  5. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    Thanks for the reply. I was also think about dev checkpoints. The only hard thing is the music. Is it possible to have a checkpoint which als sets a checkpoint on the soundtrack?
     
  6. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    But then it's really hard to complete the level because it's going so fast and besides that, the soundtrack doesn't speed up.
     
  7. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    Didn't know about that yet. Do you think it can work for this? If so, I could try it out tommorow. Isn't it only for cutscenes?
     
  8. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    Wow... A bit offtopic but I literally just got a copyright claim on that video because of the music.... does this mean I can't publish it on google play...
     
  9. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Can only go off what I've seen in videos, but I'm pretty sure you can put audio on the timeline, so synchronising could be done by eye on the timeline to waveform peaks.
     
  10. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    If you don't own or have appropriate licenses to the music, yes it means you shouldn't use it.
     
    TaleOf4Gamers and Kiwasi like this.
  11. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    Yep, if it does belong to someone, then you can't use it (not a legal battle you want to fight I'm sure). But it depends on the license behind the music. If you found it on a site that provided it for free use, then you might investigate the claim, but that might not be worth the trouble.
     
  12. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    Well it said I got a claim, but it doesn't have any effect, it will only cause some ads on the video which will go to the company. I will contact them.
     
  13. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    If your game is going to support a saving system, now is as good a time as any to implement it.
     
  14. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    My game will save the highest score (most percent of level finished) but you won't be able to play starting from that score.
     
  15. Jip1912

    Jip1912

    Joined:
    Mar 13, 2015
    Posts:
    314
    Anyone an idea?
     
  16. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Well, it really sounds like you're going to have to force your music to skip ahead to some point, and you need to find ways to make that happen.

    Try changing the audio position using AudioSource.time (may or may not be accurate, may need fudging for debugging purposes).

    Or do it manually if you have to with extra music clips for debugging purposes (i.e. take the entire music track and trim the first part to correspond to where you want to place yourself at).

    If you're looking for an elegant or simple solution, I'm not sure one exists.