• 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 ardy3344 · Aug 23, 2011 at 06:02 AM · movetransforms

move object

I have an object

and then it wants to move the semi-circle

how? Example move to A until B

A alt textB

But follow the line

sry my english bad....

Can somebody help me???

Thx

Comment
Add comment · Show 3
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 ardy3344 · Aug 23, 2011 at 06:13 AM 0
Share

i try with transform.rotation

avatar image Meltdown · Aug 23, 2011 at 06:28 AM 0
Share

What exactly is the 'patent' ? Or do you mean parent?

avatar image sriram90 · Aug 23, 2011 at 12:53 PM 0
Share

in order to do this you have to use circular motion concepts in physics....i have tried but couldn't get exact answer....

5 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by sriram90 · Aug 23, 2011 at 12:01 PM

Note :This answer will suite for Arc Movements (not for semi-circle)

Hi ardy3344,

have you ever tried with lerp movement for objects. if you use lerp movements using Vector3.lerp it would be easy.

First you need find the distance between A and B and divide the distance by 2.here you'll get half distance right ? . you can find the center point from here. add the half distance with A or minus from B.

After this process you'll get the midpoint for A and B. now increase Y-axis for 5 units and consider it as midpoint.

now you want to use Vector3.Lerp for A to midpoint, then midpoint to B. and you can do movements with time in lerp.

 1st movement :
 
 Vector3.lerp(GameObject.Find(A).transform.position,midpoint.transform.position,time);
 
 2nd movement : 
 
 Vector3.lerp(midpoint.transform.position,GameObject.Find(B).transform.position,time);

you have to increase time in loops. sure you'll get good arc movements.

I gave you the procedure for doing it simply. you may code it now.

Comment
Add comment · Show 6 · 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 Joshua · Aug 23, 2011 at 12:05 PM 0
Share

How does this move it along a semi-circle?

avatar image sriram90 · Aug 23, 2011 at 12:19 PM 0
Share

oops....just now noticed the word "semi-circle"...its my mistake..

avatar image ardy3344 · Aug 24, 2011 at 03:40 AM 0
Share

the code to move straight to target but i want semi circle..

avatar image sriram90 · Aug 24, 2011 at 04:48 AM 0
Share

i knew mistake you're doing....you gave time as it is inside of lerp...right? you have to increase the time from its moving A to midpoint, and decrease it from midpoint to B. sure you'll get slow movements of object in view..

avatar image ardy3344 · Aug 24, 2011 at 08:53 AM 0
Share

if other from

Vector3.lerp(GameObject.Find(A).transform.position,midpoint.transform.position,time);

how??? because this code no run.....

Show more comments
avatar image
0

Answer by Tyler 10 · Sep 07, 2011 at 06:14 AM

Just use Trig. Break out your highschool geomtry book :), you know you want to . . .

 // between 0 and 2 Mathf.PI.
 float mPosition = 0F;
 float mRadius = 5F;
 void Update () {
     mPosition += .01F;
     transform.position = new Vector3(Mathf.Sin(mPosition)*mRadius, 0, Mathf.Cos(mPosition)*mRadius);
 }
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
avatar image
0

Answer by Bhoomi · Sep 04, 2012 at 10:12 AM

Has anyone found the exact answer to this question? I am looking for something similar.

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
avatar image
0

Answer by Ecszavier · Oct 11, 2012 at 07:16 AM

You need to discover the center between A and B. Let's call this centerPosition. And your object be at A:

transform.RotateAround (centerPosition, Vector3(0,0,-1), 75*Time.deltaTime);

This will make the object do a circular movement. You will need to check if your object is already at B.

And know the B position is easy, is the same distance between A and the centerPosition.

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
avatar image
0
Wiki

Answer by ellioman · Jun 23, 2013 at 01:34 PM

I know that this is an old question but I was trying to accomplish a similar thing so I thought why not post my solution here. After looking this page (Transformations of Functions and their Graphs) I played a little bit with the half circle function and managed to create the following code which should give you what you want.

 // Private Instance variables
 private float speed;
 private float counter;
 private float length;
 private float height;
 private Vector3 startPosition;
 private Vector3 currentPosition;

 // 
 void Start()
 {
     startPosition = transform.position;
     currentPosition =  Vector3.zero;
     speed = 1f;
     counter = 0f;
     length = 30f;
     height = 30f;
 }

 // 
 void Update()
 {
     counter += speed * Time.deltaTime;
     currentPosition.x = Mathf.Sin(counter) * (length / 2f);
     currentPosition.y = Mathf.Sqrt((Mathf.Pow((length / 2f), 2f)) - Mathf.Pow(pos.x, 2f)) / ((length / 2f) / height);
     transform.position = currentPosition + startPosition;
 }


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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

How do I lock a certain Axis on a drag object script? 0 Answers

Moving object with mouse on release 0 Answers

How do I make the nose/whole of my spaceship move? 2 Answers

Make Objects to ricochet 1 Answer

How Can I Make The Parkour Moves Move Smoothly Instead Of Instantly Teleport? 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