Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MattG · Dec 24, 2012 at 01:01 PM · transformprefabarray

Nested Prefab Issue

Hi All,

I've been searching on here for help on my issue, but I can't seem to find anything like I have built. I am thinking someone else has run into this problem before, and can point me in the right direction.

Here is the issue:

I have an NPC prefab, I then place a script on it with a public array of transforms. I place another script on it, that when start is called on the first script, it loads the tags and transforms into a dictionary on the second script.

This works fine, and if I only have one NPC, everything is peachy. If I drop these same scripts on another NPC GameObject with the same Transforms in it's Transform array, then I run into problems when I hit play.

The message I get is that the dictionary already has a key of the same name. Which means that the script that controls the dictionary is being shared between the two game objects it's been placed on.

How do you get around that?

Let me know if I didn't explain it well.

Thanks, Matt

Comment
Add comment · Show 5
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pako · Dec 24, 2012 at 01:10 PM 0
Share

Hi $$anonymous$$att,

$$anonymous$$aybe it would be helpful to post your scripts together with this question.

avatar image MattG · Dec 25, 2012 at 03:08 AM 0
Share

Here is my Prefab that I can drop on a game object.

alt text

Looking at the Entity AI script, it has an Array of tasks. These are themselves prefabs. A method to load the tasks in the Task Processor script is called from the Entity AI script. This load tasks method takes the array as a parameter, and puts the array contents into a dictionary.

$$anonymous$$y problem is that the dictionary seems to be shared between any game object I drop this prefab on.

Thanks, $$anonymous$$att

avatar image MattG · Dec 25, 2012 at 04:46 AM 0
Share

Looks like I fixed part of the issue. I created a child object and dropped the TaskProcessor script on it. Now I don't get any problems with the dictionary in the TaskProcessor. However I am still having issues with the actions under my tasks which were set up similarly.

I'll have to mess with it and move things around until they aren't conflicting.

avatar image MattG · Dec 26, 2012 at 05:09 PM 0
Share

So a quick overview of what I am trying to accomplish.

I'm trying to build an easy way to create tasks for an AI entity. If everything is pre-made, all the actions are atomic, then you can drag and drop the actions on a new task, configure them, then you have a new task for your Entity to perform.

The problem I am still having is that the entities are sharing the tasks. So any randomness in the tasks will be the same for each entity. I can make the tasks and actions configurable, but I can't expect them to be treated differently for each entity.

Do I need to design the tasks and actions to act as singletons? They seem to be acting that way now.

How do you not share state between prefabs of the same type? How do I have all my skeletons act differently? Drive the randomness from somewhere else?

Thanks, $$anonymous$$att

avatar image MattG · Dec 26, 2012 at 05:11 PM 0
Share

I'm not sure if it would be different if these entities were being spawned vs. dragging an AI prefab controller onto an entity in the scene. Right now I am just dragging the AI prefab on 2 different entities in the scene.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting Position of Spawned Prefab 2 Answers

How to Spawn a Prefab over an Array of Transforms, One Prefab at a Time? 1 Answer

Prefab Transform variable missing. 1 Answer

Create Transform from prefab file in a project 4 Answers

How to move along a group of waypoints at a certain speed? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges