edited September 18 in ORK Scripting
Hi guys!

I have been having a tough time to figure out how to connect two scenes together via script. I'm using a 3rd party level selection system from the asset store called 2D level selection and it's open for me to connect a scene loading line of code in the script. The whole reason for that is to create a world map, like in super mario RPG, and select levels via a node based navigation system that progresses through the game. Since there are more than 1 level, how can I implement ORK into it so it can be triggered via script and let ORK know that the player is traveling between scenes?

Note: This is part of an exercise I'm doing for educational purposes

Any help would be very appreciated.

image

Cheers!

- Gerardo-
Post edited by gamingislove on
  • Well, you don't really have to hook ORK into that at all. You'd just have to e.g. use an Autostart event interaction in the loaded scene to spawn the player at a spawn point.

    Or, if you want to integrate the system with ORK, you'd have to use SceneChanger components to do the scene loading for you.
  • I was just about to add GetComponent to turn on SceneChanger within the script itself when colliding with the level panel as the script's input code triggers it when player clicks on the hero.

    I'll let you know if it works...
  • edited September 19
    Okay, I tried and I couldn't figured it out. Some folks have it easy to understand, that's not me. It literally took me 4 days trying before I came to post here, and an extra day trying to see if I could, but sadly I failed.

    So this is the setup. The person who wrote the package told me that within the space he left in the script to add the code to change scenes, which is in the screenshot, was the way he set it up. What I was trying to do was to enable ORKframework.Behaviours.SceneChanger script from the GameObject Level to autostart after the player clicks on the Hero (will add a button press later).

    I see though that SceneChanger isn't a normal script to call about. I tried to enable it through GetComponent and I couldn't. Why this has to be so hard to do for me is because of lack of understanding. I really want to understand it though, that's why I'm here posting this.

    So here is the screenshot-
    image

    The setup is basic as basic can be. I just need instruction on how to go about doing this using ORK. Please explain it to me as like you are showing it to a 10 year old (even though they are much more intelligent that I am at this point)

    Please help me in detail how to connect the worlds together in this fashion?

    -Gerardo-
    Post edited by Glegend on
  • Ok I think I know how you want this set up, and correct me if I'm wrong.

    Those red and yellow dots are Level Icons correct?

    If the player clicks on a Level Icon that is available/unlocked.
    Move the player to that clicked Level Icon.

    If the player is on a Level Icon and Accept button is pressed.
    Spawn a button or a choice dialogue to allow the player to chose to enter that level or return to Level Picking Map.

    Does this sound right?
    Are you trying to achieve something similar to Super Mario World or Donkey Kong Country?
    Awesome Website - Portfolio
    Support me on Patreon - Support site
  • Yup! exactly!

    image

    I'm trying to mimic mostly Super Mario RPG and Final Fantasy Mystic Quest/Mystic Quest Legend, but you got what I'm saying here. Is just trying to link up two different systems to perform this is what got my head scratching. I'm not that good yet in Unity C# to really understand stuff.
    image
    image

    I have a working model of the world selection map, I just need to link stuff up and I've been having so much trouble with that using ORK, since it needs to know where the hero is going so it can spawn correctly in the scenes that the player will play in and another package has me to go into the script to modify it for that action to happen.

    This has taken me already way too much time. I need at least get a prototype out before Sept 23rd or I'm toast. Since primarily I'm more a technical artist than anything else, is hard for me to match up with programming, especially with so much life stresses.

    So yeah, how can I go about doing this? You want to see the code?

  • I have done something like that in my project in which you can see it in action at the beginning of the video, right here on my wip thread. It's similar to SNES Final Fantasy: Mystic Quest.

    http://forum.orkframework.com/discussion/3719/wip-the-distance-of-our-hearts#latest

    In the end of the video, after I beat the level, you can also see that when I went out to the world map again, a new road is now revealed to me, to go into a new level.

    All using ork and makinom. So if this is what you are looking for, if one day you decide to use makinom with ork instead, and you need help doing the same thing, I can lend you a hand :)

    In the meantime, it's always nice to see a fellow ork developer doing the same thing as me :) I hope you can bulldoze through this before the due date!
  • Pretty awesome stuff Shadow_Fire!

    And yes! I got Makinom installed in the project. I bought both to get the maximum potential from GIL. Feel free to hit me up, I'm mostly a graphics man than coding. Went to school and spend some heavy cash that I now owe back just for game art and design classes, as well I always teach myself new tricks too. So feel free to send a message, I can do some stuff for you in exchange for some ORK & Makinom help (because I have no clue as of now lol)

    btw, I managed to figure out the scene changing problem!

    So what I did was super simple after watching some Unity vids on the official site. (I'm so spoiled with videos) I couldn't understand it first when I was getting the classic Object reference error but it was because I had the GameObject defined stupidly before the action happened, and I just KO that and it works when clicking on the hero now on top of the level panel as you expect it.

    The process was that I created a Public GameObject slot thingy to place the prefab that has ORK SceneChanger script in it to put into the LevelManager component/script to call it when you click the player. The settings for the ORK SceneChanger is set to Autostart, so the object is deactivated until you click on the hero. I also set another condition that it must be from a tag I set up for it to go through. Bam! I got it going on! (jiggle dance)

    Now the problem is loading the Hero after the scene change into the level, again lol (I'm always having this issue)

    I'll see if I can fix that.... brb lol
  • edited September 20
    HOLY MOTHER OF BATMAN!

    It works now! Everything has finally got all synced up! WOOHOO!!

    image

    I just... wow.... Finally!
    Post edited by Glegend on
  • Ah!

    lol I hit another wall. This time it's having a persistent scene. This time because the node based script I'm using is basically dependent on having the scenes as additive, it breaks everything else lol

    So now I'm trying to figure out how to advance when I go back to the worldmap. Is there a way I can use ORK to create a consistent scene between the worldmap and the levels? I have Makinom as well but I don't know how to plug that into ORK yet. Can Makinom help make things consistent?
  • edited September 21
    For Makinom:

    You could use an empty GameObject (name it something like GameRememberer or something lol) and attach an Object Variable component and a Tick Machine to it.

    Then when you have certain levels unlocked or other variables needed like items obtained, skills learned, etc you add them on this Object Variable component. For example to track levels unlocked use an int variable and call it something like lvlsOpen and set it at 0. This will represent (in its current form) no levels unlocked.

    Now the Schematic making part.
    1. Make a Schematic and Save it as GameMemory right away.

    2. Add a Don't Destroy On Load node in it, this will keep the GameObject we drop this Schematic on stay loaded when new scenes are loaded.

    3. Add a Check Variable node and click Add Variable to check the variable key lvlsOpen from the variable origin Object and object as Machine Object. (because remember we made that GameRememberer object with an object variable component) Now at the bottom of change type to Int, check type as Is Equals, and leave Value/Value 0. (ahh exciting stuff, I know!!!!)

    4. Add a Unity Console node to the Success slot and have the text say something like No Levels Unlocked. (This is just like in code writing Debug.Log(No Levels Unlocked) so it'll print this message in the Console.

    5. Save the schematic drag this GameMemory schematic to your tick machine on the GameRemember object and press play. You should see No Levels Unlocked in the console being repeated. (if that worked perfect, move to next steps....if not somethings not right)

    Since this really isn't doing much now we need to check for levels actually unlocked.

    6. Reopen the GameMemory schematic Shift click both Check Variables and Unity Console nodes and right click copy, then drag those directly below in a neat organized way. (side note, shift clicking and dragging the first parent Node in a sequence of nodes also move the child Nodes)

    7. Connect the original Check Variables node failed slot to the copied Check Variables.

    8. Click the copied Check Variable node and just change the check value to 1.

    9. Click the copied Unity Console node and change the text to Level 1 Unlocked

    10. Save the schematic press play. You should see No Levels Unlocked in the console being repeated. (good ok I know you think that this sucks we already did this, well guess again, this time it's different)

    11. While still in play mode click the GameRememberer object and in the inspector scroll down to object variables (it'll have a list of variable types that only appears while in play mode) so when you open Int Variables tab you should see lvlsOpen at 0. (so far so good, good)


    12. Click the edit button on the right of lvlsOpen 0 and change it to 1 and look at the console, it should say Level 1 Unlocked repeated.

    At this point you should get the idea that this GameRememberer with this GameMemory schematic will keep track of level progression.
    If you want to learn more on how to change the lvlsOpen object variable when a level is complete or just more in general ask away!

    Here's pics of the GameMemory schematic and GameRememberer at this point.
    Game_Memory
    Game_Rememberer
    Object_Variables_Component
    Tick_Machine_Component

    Never Stop Creating,
    Nate =]
    Post edited by relenting_1 on
    Awesome Website - Portfolio
    Support me on Patreon - Support site
  • Actually, you can just use a scene changer set to Interact to start it by clicking on it. Just needs a collider attached and (depending on if there's a player or you need a certain distance to it) a correctly set up click distance (e.g. -1 for not using distance at all).

    Starting an already set up scene changer component just requires calling the StartEvent function:
    sceneChanger.StartEvent(null);
  • Ohh! Thank you relenting_1!

    Excellent GIL! I'll keep that in my notes. I was thinking of how to make things consistent in a scene and relenting_1's Makinom solution seem to be easy enough to do. I'm going to try that out.

    brb!
Sign In or Register to comment.