edited August 2014 in ORK Support
I've been wrestling with an event for a while now. What I'm trying to do is have an event
object spawn a random prefab, the first time its run. Then any time it runs after that (Such as when re-loading the scene) spawn the same prefab. I did this by setting two object variables, one to choose what to spawn and one to tell it that the choice has been made. Then any time it's run after the first time it skips the step where it chooses what to spawn and goes directly to spawning what was chosen the first time it was run. Sorry if it's confusing, here's a break down of the event steps:

I have a random step that sets a object variable to 1-4, I call it ObGen.

Then I set another object variable to let it know the random choice has been made, I call it ObGenFin.

Then I spawn a different object based on what the number ObGen has been set to. For example if it's a 1 I spawn a crate, if it's a 2 I spawn a column ect.

Before the random step I have a step that checks if ObGenFin has been set. If it is then I skip changing ObGen, so that way it stays the same as the first time I ran it, and spawns the same object.

The problem I ran into is that it wont spawn different prefabs. I have several different objects in the scene with the event on them and they all spawn the same prefab (prefab 0) every time. I haven't worked with object variables before, so I'm not really sure whats going wrong. Any help would be appreciated.
Post edited by gamingislove on
  • I could have misunderstood, but why don't you use an object spawner instead of an object?
    I'm sorry if your goal is different, but from what i got i think you could do:
    1) prefabs in event start: 4 different spawners properly set to your 4 different objects
    2) check variable event. check spawnerchosen variable fork;
    if spawnerchosen = none, random event 1-4, if 1 set spawnerchosen = one and spawn prefab 1, if 2 set spawnerchosen = two and spawn prefab 2... and so on...
    if spawnerchosen = one/two/three/four, link it to relative spawner skipping set variable and random event links.
    Thinking a bit more, i suppose you can use objects instad of spawner, the workflow its the same and i hope could work. :)
  • Object game variables require an already existing object with an Object Variables component attached, unless you set the event steps to use the Object ID directly.
    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!
  • Awesome, once I added an object variable component it worked, thanks! Also thanks for the help Kaemalux.
  • "Object game variables require an already existing object with an Object Variables component attached, unless you set the event steps to use the Object ID directly. "

    This information should be added to http://orkframework.com/howto/2013/08/20/game-variables/
  • edited August 2014
    Probably, but Object game variables aren't the same as the Global game variables (what's mostly talked about in this how-to).
    I guess the description of the object variables isn't clear enough at the beginning of it.
    Post edited by gamingislove on
    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!
Sign In or Register to comment.