Forum rules - please read before posting.

Multiple instances of the same object?

Hello there,
I have a character running around dropping objects in my scene.
When he reaches path node, he stops and drops an item.
This item is the same for each node so I have on items that needs to be spawned many times.
In the Remember Transform it explains 'multiple instances of the object can be spawned'.
I can't seem to get it to add multiple instances, but instead just use the object and spawn it the new place (using a marker to place it) and removing from the previous place.
I read using Object: Add it should be possible - how do I place it at the marker and having it placing the same object around the different nodes when my character reaches it? So far I have tried to use the object add action, followed by the teleport - but I recon only one is needed.
Any direction would be much appreciated.

Best, Dan

Comments

  • You're correct in that you'll need to use a single Object: Add or remove Action to both spawn and position the object - a further Object: Teleport Action that refers to the prefab will not necessarily refer to the correct object at runtime if multiple instnces are present.

    To have a prefab spawn at a given Marker, without the need to separately teleport it, make sure that it's original Position in the prefab's Transform is 0,0,0. Then, in the Object: Add or remove Action, set the Position relative to option to Relative To Game Object, and assign the intended Marker in the Relative GameObject field.

    To have multiple be spawned, set the Remember Transform component's Linked prefab ConstantID field to match its own Constant ID value, and make sure that it's placed in a Resources folder with a unique filename. Bear in mind, though, that these steps are only necessary if you wish to save the state of the objects being spawned.

  • Ahh, I missed the marker with the Relative to Game Object - Thanks a lot Chris, got it to work!
    I have added a hotspot to the prefab and added a Object Remove and selected the spawn object - however it does't remove the object - is that because there are multiple with the same name? I'm wondering if this will work on prefabs with the same name or how to get around this.
    I also noticed when I tap the spawned object fast (before the character gets to a new node and should spawn a new item) it is as if the spawning stops (breaks)

    Much appreciated!
    Best, Dan

  • I have added a hotspot to the prefab and added a Object Remove and selected the spawn object - however it does't remove the object - is that because there are multiple with the same name?

    This is in an ActionList asset file? When objects are assigned directly in ActionList asset files, AC will look for them in the scene via their Constant ID number. This can't be used, however, if you're spawning multiple instances of the prefab.

    The way around this is to assign the object to remove via an ActionList parameter. Essentially:

    1. Enable parameters at the top of the ActionList asset's Inspector, and define a new GameObject parameter.
    2. In the Object: Add or remove Action that removes the object, override the Object to remove field with this parameter.
    3. On the prefab with the Hotspot, attach the Set Interaction Parameters component, and assign itself (the prefab) as the value for the GameObject.

    I also noticed when I tap the spawned object fast (before the character gets to a new node and should spawn a new item) it is as if the spawning stops (breaks)

    I'll need more details on this - can you provide more + screenshots in a new thread?

  • Thanks a lot Chris - I expected the Constant ID to be the issue and tried to use parameters - I missed the set Interaction Parameters component - and its now working:)
    Having so much fun getting all these small things to work!
    In terms of the issue, I will test further and see if it's something I have missed.
    Thanks a bunch!
    Best, Dan.

  • A question:
    I have added a particle system to my spawned objects - it plays correctly on each spawned object - however when I add a particle switch component and on my hotspot of the spawned object have a message send to run the particle with active, it doesn't play the particle system on each spawned object, but instead only on the one original in 0,0,0 that is being used as the one to instantiate. Not sure how I get it to play on the spawned objects?
    Any direction would be much appreciated.

  • You'll need to make use of the Set Interaction Parameters component here as well, so that it always assigns its own ParticleSystem component in the Object: Send message Action.

  • Thanks a lot Chris!
    Then using the parameters for the particle system as well - that did the job.
    Best, Dan

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.