Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Jaibeer72 · Feb 17, 2017 at 10:19 PM · playerprefsloadlevel

How to make a Player Spwan at the same point at a different scean depending on where The player Triggered the LoadScean

Hello Guys

   I am making a Student project based on the Idea of haveing Different environments for the same Level.

Basically what i wanted to do was to create a 2 scenes where a player can choose between 2 aesthetics.

In simple algorithm what i want the game to do is

  • There is a scean where a player can anytime trigger a script to chang how the map looks

  • The Level will basically be the same (geometrically ) except some objects will be added to the level and textures will change.

  • and the player can trigger that back .

  • at all points his position in the map remains the same.

How can i basically do that ?

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
Best Answer

Answer by aFeesh · Feb 18, 2017 at 04:44 AM

If I understand your question correctly you want to load a new scene, but have the player in the same position as he was right before the new scene loaded.

If that is the case you can store the player position into a static Vector3 right before the scene changes, and then set the player position immediately on void Start() to the static Vector3 value.

Like so:

 private static Vector3 spawnPosition = new Vector3(0, 0, 0); // Change the X Y Z values to wherever you have the player in the FIRST scene
 
 void Start(){
     transform.position = spawnPosition;
 }
 
 public void SavePlayerPosition(){ // Call this before the level changes!
     spawnPosition = transform.position;
 }

Simply create a new script with that code and attach it to your player. Static variables will persist until the game is terminated. So by storing the player position in a static variable it can be saved and accessed for when the next level loads.

Comment
Add comment · Show 2 · 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 Jaibeer72 · Feb 19, 2017 at 08:42 AM 0
Share

thank You sir !

 Could you also give me some book that can halp me program better for unity 3D i am co$$anonymous$$g from C++ scripting and 

i am more used to creating my own header files which can be called the "Using Unity" type files is there a way i can do that in Unity and CS scripting that can be really helpful

avatar image aFeesh Jaibeer72 · Feb 21, 2017 at 04:01 AM 0
Share

@jaibeer72 Try Sebastian Lagues Intro to C# and Unity tutorials!

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

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

Related Questions

How to load the last level when the game open again ? 1 Answer

pause menu loads saved game quirky 0 Answers

PlayerPrefs Not Saving When I Click the Button. 1 Answer

PlayerPrefs works fine in Unity Editor but not on Android 0 Answers

Life countdown for unity using PlayerPrefs? 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