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 /
This question was closed Oct 31, 2013 at 04:41 PM by DeadKenny for the following reason:

The question is answered, right answer was accepted

avatar image
1
Question by DeadKenny · Oct 30, 2013 at 04:52 PM · playerontriggerenterloadleveldontdestroyonloadnext level

Next LEVEL Load Problem.

Ok I have a problem which should be easy to solve.

I have this building that when you enter it, a new level loads with your player in it. The problem comes with placing the player in the new scene in a specific position away from the door so he doesn't go back out when the new scene loads. My player pretty much does not move an inch. Technically still outside even after the new level loads.

So How would I do that?

The code I have isn't working. By not working I mean it has no errors, instead it just does not do what I need it to.

My code for the Entrance/Door:

 public string nextLevel;
 
 private Transform plyrObject;
 
 //enterPoint is the point where the player is supposed to be positioned after entering. 
 
 public Transform enterPoint;
 
 
 
 void Awake(){
    
 GameObject.DontDestroyOnLoad(this.gameObject);
 
 // Posotion player after entering:
 plyrObject.position = enterPoint.position;
 
 
 }
 
 
 void OnTriggerEnter(Collider col){
 
  if(col.tag == "Player"){
 
    Apllication.LoadLevel(nextLevel);
 
    playerObject = col.transform;
 
 
 }
 
 
 
 }
 
 
 
 
 
 }


HALP!

Comment
Add comment · Show 2
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 DeadKenny · Oct 30, 2013 at 04:54 PM 0
Share

http://forum.unity3d.com/threads/200629-Omega-Void-WIP

$$anonymous$$y game. That Hangar type building in the first pic is what this here question is about.

avatar image Josh707 · Oct 30, 2013 at 06:23 PM 0
Share

Use OnLevelWasLoaded() to execute code after loading a new scene.

2 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by DeadKenny · Oct 31, 2013 at 04:41 PM

Ok problem solved(yesterday).

I just did all the positioning in the OntriggerEnter as it triggerrrrd.

 void OnTriggerEnter(Collider col){
 
 if(col.tag == "Player"){
  
    Apllication.LoadLevel(nextLevel);
  
    col.transform.position = enterPoint.position;
 
 }
 
 
 
 }
 
 

Wham bam thank you mam.

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
avatar image
2

Answer by Stormizin · Oct 30, 2013 at 04:55 PM

private Trnasform plyrObject;

Transform *

Comment
Add comment · Show 4 · 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 DeadKenny · Oct 30, 2013 at 04:57 PM 0
Share

Oh thats a typo. The code has no errors, it just does not do what I want it to.

avatar image Stormizin · Oct 30, 2013 at 05:01 PM 0
Share

try to playerObject = new Vector3(x,y,z); Change his position manually

avatar image DeadKenny · Oct 30, 2013 at 05:30 PM 0
Share

Nope... Perhaps its not referencing the player...

Will make it public and see.

avatar image DeadKenny · Oct 30, 2013 at 05:42 PM 0
Share

Its not getting the playerObject transform in OnTriggerEnter.

Anyone know why that could be?

Follow this Question

Answers Answers and Comments

17 People are following this question.

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

Related Questions

how can i make my character to be on another scene? 1 Answer

Should I use DontDestroyOnLoad or prefab for player 1 Answer

Instantiate spawns 2 instead of 1, help? 2 Answers

help loading level after destroying objects 1 Answer

Delete duplicate gameobject on restart 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