Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Ellipse Animation by code

Discussion in 'Scripting' started by AstridLongi, Apr 6, 2020.

  1. AstridLongi

    AstridLongi

    Joined:
    Nov 4, 2019
    Posts:
    15
    Hello, I really need help, I am trying to make this 3D animation by code,
    , I have tried to transform, translate, vectors3, quaternion and I am really lost, this is what I have know but I do not know how to make the red line follow the green ball without moving from the blue point. I will be very grateful for your help.
    What i want

    what i have:
     
  2. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    391
    Hi, sorry i don't have time to provide code but i would do the following:

    Write code to move a single point around an circle i think you may have done this already from your video. You can do this using sin and cosine functions with the angle on the circle. An ellipse is a circle where one axis is scaled, for example multiply y by 0.5

    For each frame, draw the complete ellipse and a line between the moving point on the ellipse and two fixed points on the sides.

    For the red blue line below, this is essentially the same except the ellipse has been scaled to have zero y

    Good luck!
     
    AstridLongi likes this.
  3. Emolk

    Emolk

    Joined:
    Feb 11, 2014
    Posts:
    241
  4. AstridLongi

    AstridLongi

    Joined:
    Nov 4, 2019
    Posts:
    15
    It worked!!! Thank you. With Line Renderer I put the green ball as the destination of the line renderer and it worked correctly. :)
    You are great, thanks.
     
  5. AstridLongi

    AstridLongi

    Joined:
    Nov 4, 2019
    Posts:
    15
    Thanks for your suggestion, it works with lineRenderer, Have a nice day :)
     
    jamespaterson likes this.