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 Skjalg · Oct 27, 2011 at 11:21 AM · transformplayerdontdestroyonload

Player using Dont destroy on load

Hi,

In order to get around some problems with initialization happening twice (because of some parameters being static and what not) I thought it would be a good idea to make our player character use the Object.DontDestroyOnLoad functionality.

The description reads as follows:

Makes the object target not be destroyed automatically when loading a new scene.

This means that when I load a new level the old player controller is just moved to the new scene without deleting it.

In all the scenes that we use we have a very generic trigger/entity setup that revolves around dragging in the references to the transforms of whatever you want to perform any action on. One example is that when our player character picks up a gadget we will teleport the gadget to the players hand-transform and play a "I found a gadget" animation on the player that moves the hands into the air (with the newly attached gadget). The problem now is that all of those generic entities have lost their reference to our player because we cant really drag in the players hand into the "transform" slot in the entity anymore because the player is not present in the scene anymore (since it gets transferred over from the previous scene instead).

I am curious if there is a smart way around this, or do I really have to create separate entities for everything that has to do with the player? (This is a HUGE task and I would like to hear a good way around this issue).

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by john-essy · Oct 27, 2011 at 11:38 AM

If i am reading this right you want to do this in the start of your scripts function Start() { gameObject.Find("Gadget").GetComponent("something"); }

but if you mean like it needs to be placed at the player hand just put everything you need in the players hands and turn of the renderers. Then you could do

var gadget = GameObject.Find("Gadget").renderer.enabled = true;

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Setting Player positioning on a different loaded scene with Dont Destroy On Load attached. 0 Answers

Need enemy to follow only active character 0 Answers

Making a powerup that transforms player scale 1 Answer

Main Camera GetComponent doesn't work for a script? 0 Answers

Should I use DontDestroyOnLoad or prefab for player 1 Answer


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