• 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 Okura · Dec 02, 2017 at 06:58 PM · playerteleportscene-change

Teleport Player to a specific object after scene change

Hi everybody!

I try to teleport my playerFPS to a 3D cube after the change of scene. I use the DontDestroyOnLoad function but I can not teleport my PlayerFPS to a specific location... The player goes to the center of the map automatically.

An idea? Thanks !

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 mefsh · Dec 02, 2017 at 10:01 PM 1
Share

What's stopping you from just setting the players position after the scene changes?

avatar image Okura · Dec 02, 2017 at 10:35 PM 0
Share

@mefsh That is to say? Currently my player is instantiated with the function DontDestroy, so it is TP at the center of the level that is loaded after with the scene manager. I would like to know how to change his spawn position? Thanks :)

avatar image MaxGuernseyIII Okura · Dec 02, 2017 at 10:47 PM 0
Share

Do post questions or comments as answers.

avatar image mefsh Okura · Dec 02, 2017 at 11:41 PM 0
Share

I'm afraid I'm not understanding your question. Are you saying you're trying to teleport the player to the cube and it's ins$$anonymous$$d being teleported to 0,0,0? If so please post your code.

avatar image Okura mefsh · Dec 02, 2017 at 11:56 PM 0
Share

I summarize:

  • I have my Player, with script "DontDestroyOnLoad" (To keep it between levels)

  • I have a door, with a script for change active level with the scene manager (Level1 to Level2) When changing scene, my player is teleported to 0 0 0.

I would like to teleport my "Player" on an object with a script, during the change of scene... Player(DontDestroyOnLoad) go from Level1 to Level2 (door/scenemanager) And now i want to teleport on a gameobject with a script. It's pretty clear? Sorry I have a little trouble today ...!

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by mefsh · Dec 03, 2017 at 12:15 AM

Ok I think I understand. You're going to want something like this. https://docs.unity3d.com/455/Documentation/ScriptReference/MonoBehaviour.OnLevelWasLoaded.html

 //This is called when a new level is loaded. 
 void OnLevelWasLoaded(int level) 
  {
         if(level == 1)
         {
              transform.position = new Vector3(Your spawn points position);
         }
  }








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 Okura · Dec 03, 2017 at 05:03 PM 0
Share

Yeah ! It's work. Thank you very much for your help!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

82 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

Related Questions

Object Teleports but returns back to original location super fast 1 Answer

Can't teleport a car? 0 Answers

Unty 3D C# Load other scene when bool = true, otherwise perform teleportation as commanded. 1 Answer

Is there a way to teleport player after countdown timer hits zero? 1 Answer

Need help with trigger event! 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges