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

How do I make an animation property add a value every time a button is pressed?

Discussion in 'Animation' started by MosephHD, Feb 20, 2020.

  1. MosephHD

    MosephHD

    Joined:
    Jan 12, 2020
    Posts:
    5
    It's quite a confusing question, I know, and I probably haven't worded it properly.

    Here's my scenario:

    I am animating my Camera to move along the x-axis once a button is pressed. Currently, I need it to move about 20 units. However, once I press the button the Camera object only moves from x-position 0 to x-position 20. I need it so that if I press the button again it adds another 20 units to the x-position so the Camera would be about x-position 40, then x-position 60 etc.

    Hopefully that's clear enough.

    Any help is appreciated, thanks.
     
  2. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    989
    instead animation control wit code and translation
     
  3. MosephHD

    MosephHD

    Joined:
    Jan 12, 2020
    Posts:
    5
    I understand how to change the position with code, but then how will I animate the object from position to position?
     
  4. surfcode

    surfcode

    Joined:
    Oct 10, 2018
    Posts:
    15