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 basavaraj_guled · May 29, 2015 at 05:22 AM · rotationproblem during runtimeloading screenafterfrom

quaternion.lerp not working properly after loading from menu scene to play scene

hi there, i m new to unity i have problem after loading from menu scene to play scene.

here i have 2 scripts, one script instantiate the prefab and the prefab is attached the script that have translate and lerp between the quaternion angle, when i play the "play" scene in the editor its working fine but when i start from the menu scene lerp between quaternion angle not working properly please suggest me to get things correctly.

this is the generator script that instantiate the prefab

 public class ObstacleGenerator : MonoBehaviour
 {
 
         private GameObject obstacleGenerator;
         public GameObject[] obstaclePrefab;
         private Vector2 obstPos;
         public static ObstacleGenerator Instance;
         public float speed = 7;
 
         private GameObject fishGenerator;
         public GameObject[] fishPrefab;
         private Vector2 fishPos;
         void OnEnable ()
         {
                 Instance = this;
                 //if (PlayerMovement.stopObstacle == false)
                 //InvokeRepeating ("Spawn", 0f, Random.Range (2f, 5f));
                 InvokeRepeating ("SpeedMovement", 2f, 5f);
                 InvokeRepeating ("FishMove", 2f, 3f);
                 InvokeRepeating ("JumpFish", 2f, Random.Range (2, 4));
         }
 
         void SpeedMovement ()
         {
                 speed ++;
                 if (speed == 14f) {
                         speed = 7f;
                 }
         }
         void FishMove ()
         {
                 if (SettingsManager.instance.isPause)
                         return;
                 int size = Random.Range (0, fishPrefab.Length);
                 fishGenerator = fishPrefab [size];
                 Instantiate (fishGenerator, transform.position, Quaternion.identity);
         }
 
         private GameObject jumpFishGen;
         public GameObject[] jumpFishes;
         private Vector2 jumpFishPos;
         void JumpFish ()
         {
                 //int size = Random.Range (0, jumpFishes.Length);
                 jumpFishPos = new Vector2 (Random.Range (9f, 16f), -0.3f);
                 jumpFishGen = jumpFishes [Random.Range (0, jumpFishes.Length)];
                 Instantiate (jumpFishGen, jumpFishPos, Quaternion.identity);
         }
 
 }
 

Blockquote

this script is attached to the prefab

 using UnityEngine;
 using System.Collections;
 
 public class JumpFish : MonoBehaviour
 {
 
         private Quaternion start;
         private Quaternion end;
         public float speed;
 
         void Start ()
         {
                 speed = Random.Range (5, 8);
                 start = Quaternion.Euler (0f, 0f, -50f);
                 end = Quaternion.Euler (0f, 0f, 50f);
         }
         void Update ()
         {
                 Movement ();
         }
         void Movement ()
         {
                 if (SettingsManager.instance.isPause)
                         return;
                 transform.Translate (-Time.deltaTime * speed, 0, 0);
                 transform.rotation = Quaternion.Lerp (start, end, Mathf.PingPong (Time.time, 1f));
         }
         void OnTriggerEnter2D (Collider2D other)
         {
                 if (other.gameObject.name == "DestroyPrefab") {
                         Destroy (gameObject);
                 }
         }
 }
 

Comment
Add comment · Show 1
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 basavaraj_guled · Jun 02, 2015 at 08:37 AM 0
Share

i have solved this problem by rewriting the script attached to the prefab,

i took one private variables

private startTime; void Update(){ startTime = Time.timeScenceLevelLoad; // then i have edited in transform.rotation

transform.rotation = Quaternion.Lerp (start, end, $$anonymous$$athf.PingPong (startTime, 1f)); }

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

2D Sprite constantly flipping 0 Answers

Flip over an object (smooth transition) 3 Answers

Minor scale issue on play mode 0 Answers

Rotation of Object on single axis in direction of the mouse position 0 Answers

How to make the player rotate to where an object is being thrown? 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