spawn actor from the inventory

UltraLionBluUltraLionBlu Member, PRO Posts: 75

Hi everyone I'm trying to understand if it is possible to spawn an actor without using "spawn actor"
For example, I have an inventory and in each slot different things could happen depending on what you buy in the game.
Do I have to use spawn actor for every possible actor inside the slot actor? Let's say there may be 500 actors, it would become very long. It would make more sense something like "spawn actor with self index" and having an index in each actor, there is a similar thing in the scene change..

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,927
    edited January 14

    Noooo... don't spawn actors for an inventory system. Instead, just place an actor for each slot and then update the contents using a self attribute.

    I used to have an inventory template for sale on GSHelper.com but it looks like the site isn't functional right now.

    There's a free demo posted here: https://forums.gamesalad.com/discussion/91003/free-inventory-system-template.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • UltraLionBluUltraLionBlu Member, PRO Posts: 75

    Hi thanks, I downloaded the inventory you suggested but it doesn't come to the solution (or maybe I didn't understand it)
    I try to explain myself better, sorry but I don't speak English well ..
    If I click on the ax I get the ax in the first slot.
    If instead I click on the sword I get the sword in the first slot.
    Now if I want to click on the slot to spawn the object, what can I do?
    By object I mean the actor with his characteristics not only the image
    I did a test by matching each object with a number so I could say in the slot actor:
    change attribute game.object to its number taken from a table
    If game.object is 1 spawn ax
    If game.object is 2 spawn sword
    And this works
    But if I had an inventory with 500 items it would be very long.
    Is there a smarter way?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,927
    edited January 14

    Making a working inventory system is A LOT of work. But here's a demo (attached) I just made to get you started.

    In the full version I created for my client -- the version that had been on GSHelper.com -- I made it so that you can have multiple pages of items and scroll through them and also remove an item and use it on an object in the scene, etc.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • UltraLionBluUltraLionBlu Member, PRO Posts: 75

    thank you again but I think I could not explain. I have already created something similar to what you say, these 2 templates do not answer my question.
    If there is someone who can interpret what I ask, feel free to intervene: D

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,927

    If you want to spawn an actor when an inventory item is clicked, just spawn a single actor and use the ID system from my demo to transfer information from a table to the spawned actor. The algorithm for this is:

    When item is clicked
         Change game attribute to item's self attribute ID #
         Spawn new actor

    In new actor
         Change self.ID to game attribute
         Change self.____ (multiple attributes) to tableCellValue(tableName, self.ID, column #)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • UltraLionBluUltraLionBlu Member, PRO Posts: 75

    If I create a single actor as you say, if the actor must have different rules of various types each time?
    For example, a "sword" actor can move every 3 seconds and shine, another "ax" can spin and stretch and then destroy himself (I'm making random rules). Can I do everything through one actor and table?
    or do I have to use a lot of spawn actor voices in the same slot in this case?
    now I have to disconnect but thank you very much for helping me!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,927
    edited January 14

    You're welcome! You could use a single actor with a ton of rules... one set for each type of item: sword, ax, etc. But it might actually be easier to keep things straight if you use different actors. And yes, that means having 500 different actors. But you can still have a single spawner actor. The actors that get spawned would have to be unique with unique rules.

    Is this like a tower defense or RPG game or what exactly?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • UltraLionBluUltraLionBlu Member, PRO Posts: 75

    I finally think I managed to explain myself :)
    For now I will limit myself to creating something as simple as a platformer (with a small inventory) to learn gamesalad better.
    But I was thinking of a game where the main purpose is to collect objects, so the very large inventory from which to bring out actors with different rules would be important.
    From your answer I seem to understand that there is no sort of "spawn at index" or alternative method to spawn different actors.
    Too bad it would have been much faster and cleaner than an actor with hundreds of spawn voices, I don't know if this would affect performance. but it's ok at least I know how to behave! thx

Sign In or Register to comment.