Hi guys,
I have a level/area map with icon buttons representing the different areas. I was able to use a simple "on click" script from the unity UI tutorials to achieve a scene change when the map button is pressed but of course this didn't bring the player group with it, just changed the camera to the new scene....

So I have created an event with a spawn player step (similar to that used in the tutorial for starting the game), and I thought I could just call that event when the map button is clicked to transport the player group to the desired scene.
Would this work? Is there a better way to do this?

Currently having issues because I am a 3d modeler not at all a programmer, so any assistance would be really appreciated, even providing cut past/example code. I pretty much have my game up and running and have avoided learning c#, I really don't want to learn it just for this one feature if I can help it. Also if there is a better way please let me know.

My c# knowledge is non existent - I tried to follow the "call event in C#" thread but got lost.

Thanks heaps guys
  • edited August 2016
    Since you said you don't know c#, got confused calling the event in C#, don't wanna learn, and want to avoid using it at all cost, I know of one way to do it. Why not use Makinom along with the ORK-Makinom Connection Plugin?

    For example, in Ork, you can create an event that will change scene and load your player group to the other scene
    Then in Makinom, you can create HUDS for your level/area map with icon buttons, and then create a new schematic. In the schematic, create a new node call Call Ork Event, and put in the Ork event that should do the spawning player to the other scene.

    Back in the Makinom's HUDS(your icon buttons), down below there's an option where if enabled, allow you to be able to click your icon buttons. Enabled that, and put in the schematic that you just created.

    To sum it up, by doing all that, if you click the icon buttons, the schematic should be activated, and it will call the Ork event that will change the scene and load your player.
    Post edited by Shadow_Fire on
  • You don't even need Makinom for that - you can use an Event Interaction with the start type UI for that, in case you're talking about new UI buttons. On your button, add an On Click () setting, select your game object and the function Event Interaction > UIStart.
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Hi Gil,
    Did as you suggested, created an empty object in the scene, attached my ORK 'map transitions event' asset to it. I then went to my UI canvas, created the button and in the on click settings I assigned the object and the script, making sure to select event interaction -> UIstart.

    1. Firstly have I done the correct thing with event interaction and object
    2. Is my event correct to transition scenes?
    (Will post pics, but I think its ok)

    3. Is this an error where the transition is trying to get the location of the camera I'm using but cant?

    When I pull up the map in game and click the button I get this error.

    transform.position assign attempt for 'Main Camera' is not valid. Input position is { NaN, NaN, NaN }.
    UnityEngine.Transform:set_position(Vector3)
    RPGCamera:LateUpdate() (at Assets/MMO RPG Camera & Controller/Scripts/RPGCamera.cs:299)

    error only appears after pressing map button in game

    Is this an integration issue with John Stairs RPGcamera scipt. I had some issues which required the camera to be a child of an object on the player (otherwise it would not be used when the player spawned).

    I tried it without the John stairs controller and reactivating the ORK camera controller but I get the same error (am I not disabling the script correctly?).

    Thanks for any help.
  • So I should add,
    1. Normal scene changes occur with no error, i.e. I can walk into a scene change object and everything works camera and all

    2. I changed the camera in the ORK event settings to look for the tag and name of my camera 'Test Camera'

    - Still nothing.

    3. I added a second object to the canvas with a separate button, again its onclick event gave the same error as the buttons on the panel (see image for settings).

    Again any help would be much appreciated - PLEASE forgive crappy place holder map that took me 20 mins to knock up, its just a place holder to get stuff working.


    Here are my Ork event settings and UI button settings.
    World map button settings 2 photo World map button settings 3_zpsrpjg8igm.png

    World map button settings photo World map button settings 2 - Copy_zpspa3gejae.png

    scene transition event settings 2 photo Scene Transition Event Settings - Copy_zpsumfeb9ud.png

    scene transition event settings photo Scene Transition Event Settings 2 - Copy_zpskzdt7spe.png
  • That event will just spawn the player at the spawn point with ID 2 - there's no scene changing involved. You need a Load Scene node for that (Add > Game > Scene).

    The error probably comes from spawning your player that also has a camera attached?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • I modified the event to include the Load Scene node and specified the correct scene and spawn ID. But I still get the error. (I removed my spawn node and replace with load scene).

    I get the error regardless of weather I am using ORK controls with Main Camera (so camera is not attached to the player - JohnStairs scripts disabled), OR, when using JS RPGcamera script with the camera attached to the player.

    The error is the same in each case, it just says 'Main Camera' instead of 'Test Camera' in the error text when I revert back to ORK.

    Thanks again for the help
  • The error is coming from your camera script, i.e. there must be a camera in the scene somewhere causing it :)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thanks, I'll take another look. Just wanted to check it wasn't my event and ui activation
  • I wonder why it only throws the error when I use the map/event scene change method and works fine when I use the in game run into scene change prefab
  • Hm, does your event block the camera controls?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • edited September 2016
    - Event does not block any controls at all, although the UI comes up - I have made it so none of the custom scripts are named in the ork settings so It can't disable them. Camera can move up and down but the player controls are blocked, also the game is paused during this time (could any of these settings be an issue - just thinking what is different with the scene transition prefab and why it is working).
    - I have tried with naming the camera in the event and without naming it, i.e. leaving it blank (and with tags)

    Now that the camera is not named in the event I get the error for both Main Camera and Test camera and then I get another one on the end "iterator==end"

    - Not sure if its related, but I can't make the map go back down once it's up, even though I have "close on second key press" selected in ORK. Is this because the game is paused?

    - Update: Ok just tried without the pause, and the camera position (Na Na Na) errors are now gone, all I get is a warning that there are two event systems in the scene and that this is not supported. I still get the "Iterator==end" error too. No scene transition either, map still does not close on 2nd key call - although this is what happened last time I had two events in the scene, now how to disable one but still keep the newUI button "on click" event? Is this causing issues again, going to go though the UI stuff and look for where there is a second event system? Is there an ORK event system that ORK adds to the scene that this is referring too.

    "Multiple EventSystems in scene... this is not supported
    UnityEngine.EventSystems.EventSystem:OnEnable()"

    Did a search in the scene and found and event system (must have been left over from UI creation), deleted it.
    - Still get the iterator==end error, but that is all, nothing else.
    - Still no transition
    - Map 2nd key call NOW CLOSES THE MAP yay.

    Thanks for any help
    Post edited by Phesant33 on
  • Video of my settings and what happens in game

  • When changing scenes with the scene changer, the controls will be blocked - if your event doesn't block the controls, that might be why you get the camera error message.

    In your video, your event interaction uses the spawn point 2 map event, but you show the spawn point 3 map event, so I can't tell if there's something wrong there.

    The 2 event system warning is coming from the new UI system. ORK will create canvas+event system automatically, if you have another canvas and event system somewhere, that's what causes this message.

    The iterator == end error could be coming from your scene being broken (according to this thread in the Unity forums). Might be that this is why your scene isn't loaded - have you tried loading a different scene?
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • - Blocking or not blocking controls did not affect the error message
    - My bad with spawn point 2, it was an old copy of the event, exactly the same content of the event, so again not to blame for the error. (I have now renamed and cleaned up since).
    - Yep deleted the extra event system so no more warning
    - Iterator == end error, it seems there is a lack of info on how to solve this, basically all I could find was that people suggested that you re import your scene and assets- it worked, No more error.

    ***- The scene change is still not working though.***

    So I decided to change the event with something I know would work. I removed scene change and tried various different things like game over node, a move node, and a save menue node.

    Whenever I chose "UI" for the event start type on the game object nothing happened on click (at least no error now, but still nothing changes).

    So I then changed the start type to auto start after 6 seconds, and sure enough it works (for scene change, save menu, end game they all work).

    So why is the on click button not liking me?

    Absolutely nothing is thrown error wise or warning wise when I click the button in game, just nothing happens, the event doesn't fire.

    Thanks so much for helping with this, would love to get it working.
    Should I just use a script that fires the event? I'll have a look.

  • - I realised the interaction type on the event interaction inspector window was set to "Events" This is correct? I tried scene change and nothing changed, so I changed it back to events.

    - I tried the event interaction.Startevent for the onclick function (rather than UIstart() and UIstart(gameObject) both of which did not work. When I tired the startevent function I got this error

    Coroutine couldn't be started because the the game object 'Map Transition Events' is inactive!
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    ORKFramework.Behaviours.EventInteraction:StartEvent(GameObject)
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    ORKFramework.Behaviours.ORKInputModule:ProcessMousePress(MouseButtonEventData)
    ORKFramework.Behaviours.ORKInputModule:ProcessMouseEvent()
    ORKFramework.Behaviours.ORKInputModule:Process()
    UnityEngine.EventSystems.EventSystem:Update()

    So I added another OnClick step first to set the object to active, to do this I selected GameObject.SetActive and selected my game object. I then added in the UI start function step below this step.

    I got the same error as above.

    The scene load event seems to be working fine, I just cant fire it from an onclick using the object with a eventinteraction component. So I tried a script, first attempt from what I could find on these forums and attached the script to the onclick button, however I didn't have a method to call when It came to select one on the onclick field in the inspector? so I left it with monoscript.name, could that be an issue?
    Ah well, had a go, it didn't work but hey, it compiled.

    using UnityEngine;
    using System.Collections;
    using ORKFramework;
    using ORKFramework.Events;
    using ORKFramework.Behaviours;

    public class MapTransitionButtonScript : MonoBehaviour {
    public GameObject MapTransitionEvents;//the game object the Event Interaction component is on
    // Use this for initialization
    void Start () {
    ORKFramework.Behaviours.EventInteraction callEvent = MapTransitionEvents.GetComponent<EventInteraction>();
    callEvent.StartEvent(MapTransitionEvents);
    }
    // Update is called once per frame
    void Update () {

    }
    }


    There is another example Gil gave so I can try that too unless somebody can point me in the right direction here. (using events and behaviors was from when I thought I needed to declare the event as a variable)

    Complete scripting n00b, I really just want to spend my time making a nice looking map.....
    :(
    Thanks again for the help.
Sign In or Register to comment.