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 tomas123 · Jan 14, 2013 at 11:16 AM · gameobjectlerpmove

Use Vector Lerp or other to move back with arc

Hi guys can you tell me how can I use Vector Lerp to move back to start position with arc. Check image below :

alt text

When we press button gameobject move from other position to start position but back with arc like on image.Can you help me with this ?

lerp.jpg (16.0 kB)
Comment
Add comment · Show 2
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 Lovrenc · Jan 14, 2013 at 12:28 PM 0
Share

I think you will have to write your own function. Lerp by itself cannot do this.

avatar image Dave-Carlile · Jan 14, 2013 at 12:48 PM 0
Share

LERP stands for Linear intER$$anonymous$$te, which implies moving in a straight line. You probably want some sort of spline function which will allow you to follow a curve through a given set of points.

2 Replies

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

Answer by robertbu · Jan 15, 2013 at 01:46 AM

There are a number of ways to creating this movement. Dave Carlile's suggestion of using a spline can easily be implemented in iTween (a free addon package to Unity). Probably other packages as well. Slerp will do the job, but you might have trouble hitting percise values like z=1 if that is what you are looking for. If you wanted more control of the arcs you could handle the movement yourself with sine curves. Something line:

 void MoveObject(float fFraction)
 {
     Vector3 v3Delta = v3EndPos - v3StartPos;
     Vector3 v3Pos = v3StartPos;
     v3Pos.x += v3Delta.x * fFraction;
     v3Pos.y += v3Delta.y * fFraction + Mathf.Sin (fFraction * Mathf.PI) * fYFactor;
     v3Pos.z += v3Delta.z * fFraction + Mathf.Sin (fFraction * Mathf.PI) * fZFactor;
     transform.position = v3Pos;
 }

This would be called by Update(). fFraction is the fraction of the way between start and end to place the object. fYFactor and fZFactor are the amount you want to offset at the max in the Y and Z directions.

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 muhammadtahiriqbal · Jul 02, 2015 at 01:22 PM 0
Share

there is no documentation of spline in iTween so can you help me out where i can find this

avatar image kraa · May 01, 2017 at 04:07 PM 0
Share

This was extremely helpful! Thank you!!

avatar image
1

Answer by Wolfram · Jan 14, 2013 at 01:47 PM

If a circular arc is OK, you can use Vector3.Slerp with an origin between your two positions and with negative Z.

Comment
Add comment · 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

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

13 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

Related Questions

Move child gameobject in x axis (Lerp) 1 Answer

Can I move a component from one GameObject to another in script? 1 Answer

C#: Move an object along one axis at time 3 Answers

How to move an object from point A to point B with one key press 3 Answers

Detect when a UI button is not pressed and change GO transform rotation. 2 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