edited June 2014 in ORK Support
I am currently using trees as scene objects with object variables that help them decide when to grow fruit. I have them also set up as combatants by using the add combatant component in order for them to take damage from damage dealers. The problem with this is that I have to have an active combatant group somewhere in the scene to prevent an error. I dont want the game to start with a fight each scene. The placement of trees is handled by a procedural terrain generator, so I dont have the option of spawning the trees with combatant spawners which also add movement and Ai which i dont need. what I want to accomplish is to have them fall over when cut/beat down, and have them disappear a few seconds after falling. They take damage just fine now but my question is this, Is there a way to transfer damage taken from damage dealers to object variables rather than a combatant component? or more simply is there an easier method I might use to make an object in the scene take damage, play damage sounds, spawn hit particles, and destroy itself if damage is too great?
Post edited by gamingislove on
  • Yeah, by using regular game events for that, e.g.:

    Use a Trigger Enter event interaction on the trees and enable Start By Other to allow it being started by other objects than the player.
    I'd recommend writing a small component script (that doesn't really do anything) and add it to the player's weapon - now you can check in the Trigger Enter event for that component to start the event.

    In the event itself, you can do whatever you want, play a sound, change an object variable on the tree (also based on formulas), etc.
    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 June 2014
    Ok I have this method implemented pretty well, Only how would I destroy the event object once its health <= 0? The destory prefab step only lets me choose from prefabs declared at the beginning step.
    Also how would I display the hit damage display text like when combatants damage each other
    Post edited by Ghostboxer on
  • Currently, you can use a Variable Event component with Autostart start type that checks for the object variable to destroy it.
    You can display those notification texts by using a Show Notification step.

    I guess its time for an event step to destroy any kind of 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!
  • ok so I set up a variable event with autostart. I set auto destroy to true and checked "Check Object Variables", then in the ORK Editor under scene object I added a variable (bool) called 'destroyTree' which initializes as false. It is set to true by the treeDamage event interaction after a variable fork determines that the 'health'(float) is < 0.01. Only when i start the game, all trees with this variable even instantly destroy themselves. Im assuming maybe it is doing this check before the object variable component is created or before the destroyTree variable is initialized as false.
  • If the object variable isn't found, the condition will always result invalid - and if the destroyTree variable is not initialized, it will always be false.

    How did you set up the variable condition in the variable event?
    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 June 2014
    Start type: Auto
    start after: 10s

    variable settings----
    general condition settings--
    auto destroy: true

    variable conditions--
    check Object variables: true
    Needed: all

    condition 0--
    value type: value
    value: destroyTree
    is valid: true
    type: bool

    ( alternatively i also tried )
    condition 0--
    value type: value
    value: Health
    is valid: true
    type: float
    check type: is Less
    value type: value
    value: 0.01

    the trees each have a scene object component, two event interactions (treeGrowth) and (treeDamage), and a variable event.
    In the scene object portion of the editor I have each tree type starting off with
    object variable settings
    use object variables: true
    local variables: true

    initial variables
    change variable 0--
    value type: value
    value: destroyTree
    remove: false
    type: bool
    value: false

    change variable 1--
    value type:value
    value: Health
    remove: false
    type: float
    operator: set
    value type: value
    value: 20

    does the scene object component that adds the object variables component initialize before variable events start? I also tried setting up the same condition on the scene object component, and the event interaction that handles the damaging of the tree.
    Post edited by Ghostboxer on
  • I have even tried pulling in a prefab to the scene while the game is play mode, but it instantly destroys itself and throws an error saying that I am still trying to access a destroyed object. Am I misunderstanding the use of "auto-destroy" ?
  • Should be working like that, I'll do some tests :)
    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, another thing to consider is that each tree is an instantiated (clone) and the child of a "chunk" which is the child of the "map"
  • Sorry, my bad - you need to set the variable condition to not be valid.

    Auto Destroy is used when the condition is not met, i.e. it's the other way round. When you want the tree to be destroyed when destroyTree is true, you have to set the condition to be invalid, i.e. set Is Valid to false.
    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!
  • yup that solved it.
    Awesome!
Sign In or Register to comment.