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 /
avatar image
0
Question by Avenium · Oct 15, 2016 at 12:35 PM · sceneupdatescene-loadingscene change

Start Method and scene hierarchy

I'm new in unity ev and tried many ways (used to try some options by myself) and I can't figure out how to set this procedure

  • Start -> LoadLevel (Scene) // It works

  • Now if loaded Scene(name) init methods // I've done it so

  • Update player position of method
    // This part of init wont work like i want it is called from Update and it start as Main_Menu Scene is loaded

This is part of code is connected =

 //Location 
 Vector2 pos;
 public float slow = 5f;
 public float destP;
 private float startP;

 //StartFlag
 bool start;

 // Use this for initialization
 void Start () {
     pos = transform.position;
     startP = pos.x;
     start = true;
 }
     
 // Update is called once per frame
 void Update () {
     if(start) {
         ToPosAtStart ();
     }
 }

 public void ToPosAtStart() {
     if (pos.x != destP) {
         pos.x = Mathf.Lerp (startP,destP,Time.time / slow);
         transform.position = new Vector2 (pos.x,pos.y);
             Debug.Log ("Start is True like life suck is true kappa");
     }
 }
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 b1gry4n · Oct 15, 2016 at 01:19 PM

Do you want the transform to slide across to the desired spot or do you want it to start at the desired spot? Youre making it more complex than it has to be.

if you want it to teleport instantly:

 public Vector3 desiredStart;
     void Start()
     {
         transform.position = desiredStart;
     }

if you want it to slide:

     bool isSetup = false;
     void Update()
     {
         if (!isSetup)
         {
             float distance = Vector3.Distance(transform.position, desiredStart);
             if (distance > 0.1f)
             {
                 transform.position = Vector3.Lerp(transform.position, desiredStart, Time.deltaTime / slow);
             }
             else {
                 isSetup = true;
             }
         }
     }
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 Avenium · Oct 15, 2016 at 01:40 PM 0
Share

I see you know what i want to do but problem is that it is called as I hit play button (this one from load level) but the script has been called before.

And it looks like this depend of time you run game you can see it setting up at position or it is just on it because of flown time.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

SceneManager.LoadScene not working with button 1 Answer

How Do I Link Different Scenes? 4 Answers

Canvas gets invisble after changing scene 1 Answer

Help with error message "Overwriting the same path as another open scene is not allowed" 0 Answers

Scene Not loading in game view 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