Forum rules - please read before posting.

Activating\deactivating GameObjects

13»

Comments

  • The inventory is persistent in all scenes because the game is composed just by one large scene or two at best, and you need to access it quite often. I'm not sure what you meant by "importing at runtime" ? I need game objects to be activated at runtime and that's because you can use or not use them whenever you want. So you take them off\on.

    As for why assetlist are a must, that's because of the way AC is currently coded. Currently, there is no other option but to use an actionlist asset put in the InvActionLists folder, if you want to run the "standard use" action of an inventory item (i.e. an action that runs when you click on it in the inventory). I'm guessing  it's because AC rightfully thinks that it needs to run "in whatever scene you are, whenever you click on it" .

    I don't understand what you mean when you say "If the player and the GUI start in-scene then an actionlist asset is not needed and the activate/deactivate actions will work as required."
    My player is in-scene already and the GUI is AC's GUI. Maybe I could make something with the new Unity 4.6 UI but after having a look at it, it doesn't seem possible.
     For example, I could re-do the inventory box as an in-scene Unity GUI - AC does leave you this possibility - but it still goes on to use the " Inventory " panel of AC (the one with "create new item", etc) so we're still at point zero.
    So the only solution would be to completely discard AC's inventory, create my own GUI buttons with the icons and so on but then I couldn't link your custom action. It would also cause a tot of other problems, like me having to code the GUI to pop up when you press a button, and, in particular, the mouse cursor that needs to switch from locked to non locked. It'd be a nightmare.

    Also, I guess only Chris might have an idea about why your original custom script doesn't work during building, it's weird, but I'm not sure if he had a look at it.
  • Hi David

    Actions need to have the source for the action set in the inspector. This can be an assetList in the resources or it can be in-scene. 

    Would not an easier option simply be to set the object as visible or invisible and then use get component to attach/remove a mesh collider to the weapon?

    That functionality is no doubt in AC already.
  • Hey, thanks for your help even in the holidays! :D

    "Actions need to have the source for the action set in the inspector. This can be an assetList in the resources or it can be in-scene."

    Sorry,but at the cost of being repetitive I'm not sure what you mean. At this point could I ask you to post a screen? Apologies. The problem is that, to my knowledge, what you're suggesting doesn't help in my case since, as I said, it is not possible to link an in-scene interaction to the inventory.
    The option you're talking about is only given through the Interaction Script.
    The only thing that you can do in-scene, is when an inventory item is selected and then its icon is used on something. Like, you pick the sword from the inventory, your cursor clicks on an hotspot, and then, yes you can run an in-scene interaction.

    But in my case, the action needs to be run in the very same moment when you click on the inventory icon (let's say the sword) itself. This is possible, to my knowledge, only through this panel:
    Adding a screen:
    image

    Which, yeah, requires an external actionlist file. :(

    Would not an easier option simply be to set the object as visible or invisible and then use get component to attach/remove a mesh collider to the weapon? That functionality is no doubt in AC already.

    This could be an interesting option, as Visibility works and I could put it on an external asset file. But I'm not sure about the get component - can you explain ? I know generally what it does but how do I set this up at runtime? I don't think it's in AC's actions ?

  • I just checked the action scripts in AC. there is a script 'Invisible' which is probably used to set visibility, if not look at the 2D demo, visibility is used on the worm etc. so that should provide a decent example for what you want.

    All interactions require colliders i.e. hotspots need a collider to register a mouse click etc so I checked the hotspot actions in the scripts section

    In the hotspot actions script there is an example of the code to  set a collider to active, also given is the code for get component, so these actions will work from an asset file resource which is what you need and the code is there already. Basically your action to enable/disable colliders should be set to the weapons mesh collider placed in the scene.


  • Perfect, good logic flow. I'll have a look at it for sure. Thanks, again!
  • edited August 2016
    Hi, I was dealing with the same problem today, where I had to enable a (already disabled) game object in the scene using an AC action. It's super simple and it works:
    // Replace "true" on line 55 with "false" to disable an object instead.
    // The link above will expire in a year.
  • Would probably be best to integrate both into a single action. With a simple toggle to select the state. Then, when enabling, just verify if its already enabled or not (If its enabled already do nothing, else enable), same for disabling (if it's already disabled do nothing, else disable).   
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.