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 TomatuAlus · Feb 11, 2016 at 09:31 PM · c#vector3lerp

Lerp on the every 3 * n cycle does some wierd thing.

To fill you in on the details, i have a tower set from two pieces. The upper piece is floating a top the bottom one. There is a third part which is invisible and basically works as a lerp destination. So the problem is:

  1. 2nd part goes to the 3rd part smoothly

  2. Goes down to its starting position smoothly.

  3. When the percent is 100% it should go to top part again, but it leaps to mid of the animation, goes back to starting point and does the two next steps smoothly again before again leaping for a split second.

Here is the code :

 using UnityEngine;
 using System.Collections;
 public class TowerUpDownEffect : MonoBehaviour
 {
     public float speed = 0.1f;
     public GameObject MovingTowerPart;
     public GameObject Staaa;
     public Vector3 MovingTowerPartVector3down;
     public Vector3 MovingTowerPartVector3up;
     private float Percent = 0;
     private bool doOnce = true;
     private int Switch = 1;
     // Use this for initialization
     void Start()
     {
         MovingTowerPartVector3down = MovingTowerPart.transform.position;
         MovingTowerPartVector3up = Staaa.transform.position;
     }
     // Update is called once per frame
     void Update()
     {
         if (Switch == 1)
         {
             if (Percent > 1)
             {
                 Switch = 2;
                 Percent = 0;
               //  MovingTowerPart.transform.position = MovingTowerPartVector3up;
             }
             MovingTowerPart.transform.position = Vector3.Lerp(MovingTowerPartVector3down, MovingTowerPartVector3up, Percent = Percent + (Time.deltaTime * speed));
             Debug.Log(Percent);
         }
         if (Switch == 2)
         {
             if (Percent > 1)
             {
                 Switch = 1;
                 Percent = 0.04f;
                // MovingTowerPart.transform.position = MovingTowerPartVector3down;
             }
             MovingTowerPart.transform.position = Vector3.Lerp(MovingTowerPartVector3up, MovingTowerPartVector3down, Percent = Percent + (Time.deltaTime * speed));
             Debug.Log(Percent);
         }
     }
 }

The album of the problem. You can see that between 3-4-5 image it leaps to mid and start again at bottom. It does this every time it goes to bottom and goes up starting from 0 percent.

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 TomatuAlus · Feb 14, 2016 at 08:46 PM 0
Share

I have tried setting Percent to 0, 0.04. or even 0.1 and it still does it.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Quaternion lerp slowing down movement? 1 Answer

hi everyone how can i move an object from a point to specific point(point b) by mouse click 0 Answers

Object moving problem 0 Answers

Smooth Forward Movement with a CoRoutine 1 Answer

Vector3.Lerp not moving object backwards 0 Answers


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