edited May 2017 in ORK Support
the player in my current game can break into buildings. that bit's all working fine. however, i don't want him to be able to break into the same building over and over in the same scene and just keep on plundering loot (which gets regenerated every time he enters a building)

so, simples i thought, i'll add an object variable to each building, check to see if it's set, and if it is, then i won't let him into that particular building again

well, simples in my head, but i've not been able to get it to work

so, the problem reduced down to its basic elements:
> add a cube
> add a dummy interaction event to it
> tick "Check Object Variables" in "Variable Conditions"
> condition type = variable, value type = value, value = buildingEntered, type = bool, isValid = False
> also add "Set After Event" with buildingEntered = True, and "Set Object Variables" ticked

hit Play, and if "Auto Destroy" is selected then the cube immediately disappears before the player can even get to interact with it, presumably because Ork's evaluated the initial check to be true and then removed the object. if "Auto Destroy" isn't selected then the cube is there but can't be interacted with

now, if you DEselect "Check Object Variables" (and its corresponding "Set Object Variables"), to make it use Global Variables instead, then the thing runs as expected: the cube's there, the player can walk up to it, press Interact, and then the cube disappears

so, a bit stumped at present. any suggestions gratefully accepted
Post edited by HarryOminous on
  • ok. never mind. my bad, looks like the relevant gameobject needs an "Object Variables" component added into the mix

  • Yeah ... object variables need an Object Variables component to link the variables to the object :)

    Fun fact: You can share object variables with multiple game objects by using the same object ID. The object ID also allows you accessing the variables without an actual game object.
    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 May 2017
    interestingly enough i'm using almost the exact reverse of that technique to generate loot in the buildings - although for item collectors rather than object variables

    although the buildings that the player can break into are all different on the outside, they all currently lead to the same scene on the inside

    in that scene is an item collector, and i want that item collector to both reset, and have different loot in it, each time the player visits that scene

    so, what i'm doing is generating my own unique id each time the player enters the building, and passing that into the item collector, which seems to reset it and force it to create a new set of loot items

    i'd guess that there may be better ways of achieving it, but that method seems to work ok
    Post edited by HarryOminous on
  • Yep, there's a better way - you can use a Change Scene ID or Remove Scene Data node before changing to the scene to remove/reset the scene ID of the item collector.
    That way you wont have to generate a new scene ID each time and can just reuse 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 gil

    i rather thought there would be a better way, but i'm not sure i entirely understand

    i don't think i mentioned it, but i'm using the "box" item collector, which as far as i can tell uses its own box id, not a scene id like the "single" and "random" options?
  • edited May 2017
    When you're using item boxes, you can e.g. use the Remove Item Box Data node. Disable Set Empty to just remove the stored data, which would result in the item box being refilled when the scene is loaded.
    The node needs to be used before the scene load :)
    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!
  • ok, thanks, that's a lot cleaner solution than mine, and just needed the node to be added into my existing lockPick event (which is called before the building scene loads)
Sign In or Register to comment.