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 Oninji · Jan 15, 2012 at 08:50 PM · instantiateoptimizationdesignarchitecture

Confirm Instantiation or Object Confirm it's Instance

Greetings,

I kinda have an argument here. So I need to know, what would be better in a case of having different ways of spawning enemies and keeping these enemies in memories as integer variables.

Make each type of spawning confirm that an object has been correctly instantiated or make enemies simply confirm their existence when the awake?

Edit: Here a more thorough explanation, perhaps I wasn't clear enough. I keep tabs on my instantiated objects with an Array : Int with each Int pointer representing a certain object. This enable me to keep in memory Objects across several scenes, using a very low memory footprint.

So what I'm actually asking is, keeping in mind there's multiples scripts that can instantiate these objects. Is it better to have each scripts confirm the existence of the object they spawned which get me to simply copy the same code across several scripts or simply have a script attached to my objects that let them confirm their existence?

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by davidt · Jan 16, 2012 at 02:28 AM

The instantiated objects won't be integer variables, they will be of type GameObject. If you just want to confirm that they instantiated OK, check the return value from your instantiate call. If it is null, then something went wrong.

In any case if you need to reference them later you'll need do this anyway so you can add the returned object to an array etc.

Comment
Add comment · Show 1 · Share
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 Oninji · Jan 16, 2012 at 10:43 AM 0
Share

I already know it won't be an Integer, perhaps I wasn't clear enough. I edited my post with the relevant info.

avatar image
0

Answer by Tasarran · Jan 16, 2012 at 03:32 AM

You can do this:

 var instance : GameObject;
 
 instance = Instantiate(Prefab, Position, Rotation);
 Debug.Log(instance);

You could also Add each one to an array as you create them.

Comment
Add comment · Show 1 · Share
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 Oninji · Jan 16, 2012 at 08:45 AM 0
Share

This not at all what I seeked, please read thoroughly before answering.

Or comment for precisions if you're not sure.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Development / Live Build Coding 0 Answers

[SerializeField] for self components instead of GetComponent<>? 1 Answer

Keeping track of which areas remain unexplored 1 Answer

Network.Instantiate/Destroy vs Instantiate/Destroy on each client using [Command] and [ClientRpc] 1 Answer

Is it legal to copy the Resident Evil Spencer mansion for my game? 0 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