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 Vadom6 · May 08, 2019 at 08:39 AM · scripting problemmovement script

How do i make a circular transition for movement between to points

I have a script here which when you hit the arrow keys it pushes an object between 4 different points, and if you hit two at once it sits the object between the two points. the only issue is that when it moves between the points it moves in a straight line. Would there be a way for me to make the transition be a more circular movement than a straight movement? the script is below:

  public GameObject OcculusUpPosition;
     public GameObject OcculusDownPosition;
     public GameObject OcculusLeftPosition;
     public GameObject OcculusRightPosition;
 
 if (Input.GetKey(KeyCode.UpArrow))
         {
             OcculusPosition = OcculusUpPosition.transform.position;
             SmoothedOcculusPosition = Vector3.Lerp(transform.position, OcculusUpPosition.transform.position, moveSpeed * 2);
             transform.position = SmoothedOcculusPosition;
             InUse = true;
             transform.rotation = Quaternion.Euler(-90, 0, 0);
         }
         if (Input.GetKey(KeyCode.DownArrow))
         {
             OcculusPosition = OcculusDownPosition.transform.position;
             SmoothedOcculusPosition = Vector3.Lerp(transform.position, OcculusDownPosition.transform.position, moveSpeed * 2);
             transform.position = SmoothedOcculusPosition;
             InUse = true;
             transform.rotation = Quaternion.Euler(90, 90, 0);
         }
         if (Input.GetKey(KeyCode.LeftArrow))
         {
             OcculusPosition = OcculusLeftPosition.transform.position;
             SmoothedOcculusPosition = Vector3.Lerp(transform.position, OcculusLeftPosition.transform.position, moveSpeed * 2);
             transform.position = SmoothedOcculusPosition;
             InUse = true;
             transform.rotation = Quaternion.Euler(180, 90, 0);
         }
         if (Input.GetKey(KeyCode.RightArrow))
         {
             OcculusPosition = OcculusRightPosition.transform.position;
             SmoothedOcculusPosition = Vector3.Lerp(transform.position, OcculusRightPosition.transform.position, moveSpeed * 2);
             transform.position = SmoothedOcculusPosition;
             InUse = true;
             transform.rotation = Quaternion.Euler(-180, -90, 0);
         }
         if (!Input.GetKey(KeyCode.RightArrow) & !Input.GetKey(KeyCode.LeftArrow) & !Input.GetKey(KeyCode.UpArrow) & !Input.GetKey(KeyCode.DownArrow))
         {
             OcculusPosition = OcculusIdlePosition.transform.position;
             SmoothedOcculusPosition = Vector3.Lerp(transform.position, OcculusIdlePosition.transform.position, moveSpeed);
             transform.position = SmoothedOcculusPosition;
             InUse = false;
             transform.LookAt(Idle_LookatPoint.transform);
         }


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
Best Answer

Answer by tormentoarmagedoom · May 08, 2019 at 09:09 AM

Hello.

Yes, you have multiple solutions.

Solution for more "beautifull" movement results is using animations. With animation you can not only have multiple points of trajectroy, you can also use "curves movement" istead of lines point to point, wich will give you a more "circular" movement.

But if you prefear some code for this, you can simply add some moevent in another axis, i mean:

If the object goes in straight line from (10,0,32) to (-25,0,75), you can modify the Y component during its movement, making sure it rises during first half of the voyage and goes down duiring the second half.

Incrementing Y component in a linear way will give you straight lines, but changing the value in square way will give you a aparabole, so more circular.

Bye!

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

183 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 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 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

How to Script "octopus swimming" movement? 2 Answers

Increase speed over time 0 Answers

Why can't i addforce to a rigidbody? 2 Answers

Why isn't my move on collision script working? 0 Answers

GameObject does not move with RigidBody2D velocity. 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