FEATURE INFO Modding models for blocks

Discussion in 'FAQ & Feedback' started by Pantera, Dec 17, 2020.

  1. LiftPizzas

    LiftPizzas Rear Admiral

    Joined:
    Sep 28, 2015
    Messages:
    1,434
    Likes Received:
    2,573
    Yeah, I was wondering if we were at the "make additional armor suits" stage yet. Looking at the configs those seem to be hard-coded with no room for new ones to be added.
     
    #21
  2. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    I have a problem with collision. For example, if I make a block like the T2 Fuel Tank ( 1 x 2 x 1 ) and make it a "child" of a cube (which holds the colliders, stretched to the model's dimensions) it can be rotated ok along the Y axis (so on the "horizontal" plane") but if I flip it upside down it will just sink in the geometry all the way up to the object's origin (from Unity's position).

    As for the offset, we have to put our model at 0.5m "below" the grid's origin (so at 0,0,-0.5) in the 3d app (I use Blender 2.83) so when we attach the model to its "parent" in Unity the object's origins will be merged, and the model will go up 0.5 meters. Forgetting that detail makes the model "float" at 0.5 meters above the ground, since the "parent" will jump to have its bottom face flat on the "voxel" ground, and its origin will move at (0.5, 0.5, 0.5) to match the CV/BA grid.

    So, is there a particular "rule" as to where we should place our model's "pivot point/ origin" relative to its own volume, to have it rotating like other game objects and keep their "collision" properties in whatever way we rotate them ?

    Edit : here is an example. I can stack the "blocks" on top of each other, I can stand on them, colliders work ok. But if I rotate them upside-down they "lose" their "bounding box" and sink in other geometry :

    NewGame_16_2021-01-09_00-41-33.png

    This does not happen with 1x1x1 blocks, only for blocks that exceed this size/ volume : all "volumes" that are further than 1 meter from the object's origin lose their "collision" when rotated on the side or upside-down.

    For some models I used the mesh colliders (non-convex) and for some others (like my example here) I used box colliders, adjusted to the right volume.

    Once the block has been placed, it has collision. This is just a "free placing" problem, as when trying to put the block next to another one, the "bounding box" will turn red when it "sinks" (upside-down).

    NewGame_16_2021-01-09_01-03-14.png

    On the left, the upside-down block "refuses" to collide with the ground. In the middle part of the image, the block can be placed against other blocks, so it can be raised up and placed correctly, even if upside-down. The block will have proper collision once placed, so this is just a problem when trying to place a block that was rotated 180 deg. on the X or Z axis.

    .
     
    #22
    Last edited: Jan 9, 2021
    LiftPizzas and ravien_ff like this.
  3. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    I made a switch, it's "activateable" in game and it plays the sound ok, but the animation did not follow. I made animations in Unity, but I don't know how to trigger them (my script crashed my scenario) as the game looks for an internal script. I "tweaked" the XrefActivate script provided with the example project, but I suspect that "activated/ deactivated" refers to the state of the object in memory and not what the player sees as "can be activated". For example, the big flower model : it has 2 models, and they are simply "switched" when the player has picked up the plant (the 2nd model replaces the first), so it's done instantly, and there is no animation, just a model swap : the model 1 is "deactivated" (flushed from memory). Am I right ?
     
    #23
  4. Taelyn

    Taelyn Guest

    its atm not possible to add custom scripts to the game

    The XrefActivate refers to the Power ON/OFF on a Structure

    Not to the pickup of a plant

    atleast thats my knowledge on it
     
    #24
    Kassonnade likes this.
  5. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    In the Big Flower prefab, the XRefActivate script is attached to it, and it is the script that shows in the editor (it shows 3 slots). One of these instantiates the "particle effects" of the flower, the other two I guess are just to "switch models" depending if plant is picked up or not.

    I checked the GameObject.SetActive method there :

    https://docs.unity3d.com/ScriptReference/GameObject.SetActive.html

    So I thought this was not going to accept player input, it just checks the state of the object (picked up/ intact). So I tried making a small script included in the prefab but the game didn't like it ; it called upon Unity's animator to play the 2 "states" (switch on/ off). If I make a generator and use the "rotation" function provided in the props example script, it will rotate as soon as it's placed down (it rotates the child object). At least that is what is happening with the light on the snowman, and I tried it on my own "prop" head.

    Would be cool to have one working example for a simple door/ switch/ activateable device, that we could simply tweak values (transform/ rotate/ move) to insert in a prefab... would be SOOOO COOOL ! :D
     
    #25
  6. Taelyn

    Taelyn Guest

    XRefActivates activated the particles yes but thats not how the plant works in game :)
    Its just a simple example how to Power a device ON/OF on a Structure
    to make something active like a constructor turns ON/OFF


    you need to set "EnergyIn: 1 and IsActivateable: true" in the BlocksConfig
    Then add the XRefActivate and set the part you want to turn ON/OFF

    1.png
    Flipping the power Switch in the CP turns my Fireworks ON or OFF


    To make something Rotate, Use the RotateObject Script:
    2.png

    These are the ONLY 2 scripts we provided you can use
     
    #26
    ravien_ff and Kassonnade like this.
  7. Joij

    Joij Lieutenant

    Joined:
    Nov 24, 2019
    Messages:
    69
    Likes Received:
    38
    Wait! We can now import 3d models and add custom icons for items now? :eek: When did this happen? How did I miss this thread? This wasn't true a few months ago! Was all of this secretly implemented in the 1.3 update? :confused:
     
    #27
    Kassonnade likes this.
  8. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Great! Thanks! That should do it for emissive screens/ buttons then. I'll try this.
     
    #28
  9. ravien_ff

    ravien_ff Rear Admiral

    Joined:
    Oct 22, 2017
    Messages:
    6,291
    Likes Received:
    11,948
    Thank you! I was wondering how to get something to rotate.
     
    #29
  10. Taelyn

    Taelyn Guest

    No the XRefActivate has nothing to do with this :) XRefActivate is ONLY for the Turn ON/OFF Power Switch in the CP


    { Block Id: 1346, Name: BigFlower, Ref: Mushroom01
    Class: CropsGrown
    { Child DropOnHarvest
    Item: Buds
    Count: 1
    }
    { Child CropsGrown
    OnHarvest: BigFlowerHarvested
    OnDeath: PlantDead
    }
    Model: @models2/Environment/Plants/AlienFlora/BigFlowerPrefab
    SizeInBlocks: "3,4,3"
    { Child DropOnDestroy
    Count: 0
    }
    }


    { Block Id: 1574, Name: BigFlowerHarvested, Ref: BigFlower
    Class: PlantGrowing
    { Child PlantGrowing
    Next: BigFlower <<<< Back To Harvestable Stage
    GrowthRate: 25
    FertileLevel: 1
    }
    Model: @models2/Environment/Plants/AlienFlora/BigFlowerHarvestedPrefab
    }


    The Harvested Version is its own Prefab. As you see the BigFlower has an OnHarvest Property what calls to the HarvestedModel :)
    Same goes for GrowingStages of a Plant. It just calls to a new Prefab whats the next stage


    { Block Id: 1531, Name: CobraLeavesPlantStage1, Ref: PlantGrowingTemplate
    Model: @models2/Entities/Farming/SpeedTrees/CobraLeavesPlantStage1Prefab
    MarketPrice: 77, display: true
    { Child PlantGrowing
    Next: CobraLeavesPlantStage2 <<<< Next Growing Stage
    GrowthRate: 25
    FertileLevel: 3
    OnDeath: PlantDead
    }
    CropType: Spice, display: true
    CropYield: 3, display: true
    GrowthTimeInfo: 50, type: int, display: true, formatter: Minutes
    Info: bkiPlantSprout, display: true
    Category: Farming
    PickupTarget: CobraLeavesPlantStage1 # disassemble
    TemplateRoot: CobraLeavesPlantStage2 # deconstruct - to avoid exploit
    ShowUser: Yes
    }
     
    #30
    Lyceq, Kassonnade and ravien_ff like this.
  11. Yarbles

    Yarbles Ensign

    Joined:
    Nov 1, 2020
    Messages:
    17
    Likes Received:
    7
    Plus 1 for RexXxuS run through
     
    #31
  12. Yarbles

    Yarbles Ensign

    Joined:
    Nov 1, 2020
    Messages:
    17
    Likes Received:
    7
    Are we limited to the existing classes for constructors and the like? so would it be possible to make a new constructor that only makes certain items?
     
    #32
    Lyceq likes this.
  13. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    We can make the model pretty much what we want, but we can't make new "classes". But for what you're trying to do, no need for a new class, and it's done by adjusting recipes (templates). In each template there is a list showing what type of constructor can make that particular item/ product (instructions are at the top of the Templates.ecf file) :

    { +Template Name: IronOre
    BaseItem: true # even though flag is set, it is not used for R2T repairing (NoRepairInputItem: true)
    CraftTime: 5
    Target: "SurvC,SmallC,HoverC,BaseC,LargeC,AdvC"

    { Child Inputs
    CrushedStone: 15
    }
    }

    Currently these are the "constructors" we have, so you would have to use one of these as your "special" constructor (even with a different name and model). Of course this means you have 1 constructor dedicated to that function, so you will have to re-shuffle all templates to rebalance the other constructors :


    SuitC = Survival Constructor - factor: 1.8
    SurvC = Portable Constructor (ConstructorSurvival) - factor: 1.6
    SmallC = ConstructorSV - factor: 1.4
    HoverC = ConstructorHV - factor: 1.4
    BaseC = ConstructorT0 - factor: 1.2
    LargeC = ConstructorT1V2 - factor: 1
    AdvC = ConstructorT2 - factor: 0.5
    FoodP = FoodProcessorV2 - factor: 1
    Furn = Furnace - factor: 0.2

    Last time I tried we couldn't change the "speed" (factor) but we can change the global speed of crafting in the gameoptions.yaml at the root of our scenario. Also note that not all constructors have all the items categories tabs (ex. food & medical) and there are 2 that can't really be used for what you want (the portable and the suit constructors).


    BUT... you can try making a pseudo-constructor with dialogues, and it should spit out whatever you want if you fulfill conditions !

    @ravien_ff can confirm this I think.

    .
     
    #33
    Lyceq and Yarbles like this.
  14. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    Well in fact it looks like it does what I mentioned previously, and if you think about it you also mentioned yourself that the script "turned off the part" so here's what I got so far, by assigning a model to the XRefActivate 1st slot :

    Device is "on" by default when I put it down :

    NewGame_23_2021-01-16_11-59-10.png

    Then when I turn it "off" (in fact I "switch off" the model, like I wrote previously) :

    NewGame_23_2021-01-16_11-59-17.png

    :D


    Well that's not at all what I expected anyway. I just wanted to turn on the "emissive" texture, but it does not show up in the inspector when trying to choose the XRefActivate "target" (that's why I chose the model...), even if I assigned it in the Empyrion shader...
    .
     
    #34
    Last edited: Jan 16, 2021
  15. Taelyn

    Taelyn Guest

    Ye dont set the model in the XRefActivate.. That will hide the model

    Emisive is done automaticly by the game. No need to set anything in the XRefActivate for it. Just leave it empty
    1.png

    Works fine for me that way
     
    #35
    Lyceq and Kassonnade like this.
  16. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    That is... a happy coincidence ! :D

    It worked fine with the standard shader, but I just wanted to try with the Emp shader, and it did not work at all. I don't know if it's because of how I set up my model or because I used more that 1 material, but that's not important as the standard shader works with emissive the same way as the Emp shader.

    shade.png

    In game there is more light (in space) but the emissive texture still shows :

    NewGame_25_2021-01-16_13-56-33.png

    It would be cool if we could adjust the space playfield's luminosity, because the default "dark" is much too bright and shadows are faint.

    .
     
    #36
    Last edited: Jan 16, 2021
  17. Taelyn

    Taelyn Guest

    Ill test later from my end and get back to you
     
    #37
    Kassonnade likes this.
  18. Yarbles

    Yarbles Ensign

    Joined:
    Nov 1, 2020
    Messages:
    17
    Likes Received:
    7
    Yeah we have already messed with those, and the same thing applies to furnaces and deconstructions AFAIK, though please correct me if this isn't the case. But we want to be able to make item specific constructors, though technically it would be item specific furnaces as we want to be able to automate production of some items.
     
    #38
  19. Kassonnade

    Kassonnade Rear Admiral

    Joined:
    May 13, 2017
    Messages:
    2,819
    Likes Received:
    4,114
    @Yarbles : I understood your first question, and my answer contained all what you can do regarding constructors. Other than that, you will need to be more specific. We can't create "new classes" and if you restrain one class to a small set of templates, that whole "branch" of constructors will only make the restrained list of items.

    Or maybe you mean you want to make some items that can be made only by one specific constructor ? Same answer as up here.

    Unless I missed something recently, we can't change the "Target" names ( ex. Target: "SurvC,SmallC,HoverC,BaseC,LargeC,AdvC" ). So even if we create another constructor with a different name, it will still be referred to by its "target" name, so all constructors with the same "target name" will only make the few items the "special one" can do.

    Besides that, this has not much to do with the current thread, which is about modding blocks with Unity. We can make a rabbit or a magician's hat to be a constructor or a fridge, but the details regarding templates have nothing to do with models.
     
    #39
    Yarbles likes this.
  20. Yarbles

    Yarbles Ensign

    Joined:
    Nov 1, 2020
    Messages:
    17
    Likes Received:
    7
    @Kassonnade I was hoping to be able to copy the class, but as you mentioned the target name gets in the way. Hopefully custom blocks is only the first step in this seeming new path and this will be a thing in the future...

    Back to topic though, Im not sure where exactly to upload the final product for it to be used in game. from what I have found, the location is in content/bundles., however i would expect that with a server, the clients would have to have the blocks in their own bundles folder as well?
    The confusion is coming from the example where it appears that there is a SharedData folder in the scenario file, which i would assume then that allows a player of a sever to use whatever is in that without having to have a copy in their game directory.
     
    #40

Share This Page