edited April 2018 in ORK Scripting
Hey , @gamingislove , I have 2 quick questions,

1 ) I was wondering how to change an items spawn offset through scripting? For example, I want to drop an item and instead of dropping at vector3 (0,0,0) I want to assign that offset spawn to a variable I create in my own script. So when the object is drop it will spawn at my vector3 variable instead of the items default/preset spawn offset. I have went through the API and I'm struggling to figure out how to assign the spawn offset to my own variable. How do I reference the spawn offset directly ?

2) Currently I’m using %bonus in the description of the weapon/items, the problem is that it's showing all the bonuses, but I want to manually choose individual bonuses .How do I add specific item info manually into Tooltip by using Text Codes?

Example : items Value Cost, items Inventory Space, Items Bonuses each Manually ( like attack damage & armor but not all bonuses just the ones I have chosen)

Post edited by tribbles on
  • 1) You'd have to change it in the settings of the item, you can do that like this:
    ORK.Items.Get(0).spawnOffset = yourVector3Value;
    Instead of 0, just use the index/ID of the item you want to change.

    2) Hm, I don't think you can. The bonus text code uses the texts set up in the text display settings (menu section). You can manually input whatever text you want, though.
    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 April 2018
    Thanks for the quick response :)!
    It's for my housing/building system I scripted.
    What I'm trying to do
    Psuedo CODE :
    I have set a raycast to be casted from camera.forward and on hit layer it will show a preview of object ,
    if object isBuidable is true, the spawn offset is assigned to raycast hit.point ,
    ORK drops combatant item(x) from inventory into world space (raycast hit.point)
    Another way I could try is to get Item Collector component > prefab settings / mount settings > spawn offset & rotation offset . is there anyway I can reference the item collector rotation / position offsets?

    1) I tried to assign a spawn Offset to new vector3 , it works but the spawn Offset is set to local position of the item collect that is spawned after i drop an
    item, is there any way to make the spawnoffset vector3 world space and not local? For instance if my raycast hit.point is equal to world space (100x,25y,75z) and I assign spawnOffset = new vector3(x,y,z);
    The object is not spawned at the world space of the hit.point but spawns in local transform of the item collector. So then the spawned prefabs transform is way off from my my raycast hit position.

    I found a way to integrate it with orks combatant.inventory.drop() , because it saves the data of dropped items position/rotation For saved/load game .
    Post edited by tribbles on
  • edited April 2018
    In that case you can just get the prefab of the item and spawn an instance wherever you want, unless you need the item collector functionality on it (i.e. collectable by the player):

    GameObject.Instantiate<GameObject>(ORK.Items.Get(0).prefab, position, rotation);
    Again, replace 0 by the index/ID of the item, position is a Vector3, rotation a Quaternion (e.g. use Quaternion.identity).

    As for dropping stuff into the world using ORK's drop system, you can also access that directly via:
    ORK.Game.Scene.Drop(position, shortcut);
    position is a Vector3, shortcut is an instance of an IShortcut interface, e.g. the ItemShortcut of the item you want to use (you can get that either from the inventory or instantiating a new one, like this: new ItemShortcut(id)).
    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!
  • edited April 2018
    @gamingislove I really appreciate your time to help me :)!

    ORK.Game.Scene.Drop(position, shortcut);This code works perfect to save/load the dropped item and its position , but is there a way to also save the rotation of the dropped item?
    Can you add something like this :
    ORK.Game.Scene.Drop(position, rotation, shortcut);

    This is what I have so far, without saving/loading the prefabs/objects:
    image

    BUG: Also when dropping items into scene and saving the game, and on loading the game it duplicates the items dropped , idk if thats a bug or I'm doing something wrong.
    Post edited by tribbles on
  • I'll look into that.
    Do you also have a custom management for the placed items? That might cause double placement.
    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 April 2018
    Thanks @gamingislove , I'm willing to pay for a way to drop items into scene with rotation and position! Just let me know :D!

    I deactivated all my building system scripts and it still seems to duplicate all dropped items from inventory & Scene.drop() , but only when I save and then load back into the game (it happens in editor and in a standalone build.)
    Post edited by tribbles on
  • There's an issue when loading from a save game in a running game that leads to double spawning. Will be fixed in the next update.
    There'll also be a rotation parameter for the drop function, as well as storing the rotation :)
    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 @gamingislove you are awesome! As soon as i can afford it , I'm doubling my patreon to 30$ :D
  • Thanks, I'd appreciate that :)
    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.