Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Move Entity

Discussion in 'Project Tiny' started by TheFordeD, Feb 13, 2019.

  1. TheFordeD


    Jul 9, 2018
    Hi, people. And it's I again.

    How need Moving Entity on scene?

    I need create Movement controller for many moving Entities in time.
    For example:
    Start on position x:0, y:0
    End position: x: 120, y: 0
    Moving time: 1.6 seconds
  2. Guilherme-Otranto


    Mar 12, 2014
    Okay, so, you need two things:

    1) A component that holds a few things: initPos (vector3), endPos (vector3), moveTime (float)...
    As well as some hidden variables (e.g., currentTime (float), destroyAfter (bool), etc) that will help your behavior out.

    2) A behaviour that filters that component and moves the thing...

    (1) is really simple... Create the component through the "Create -> Tiny" menu and add the necessary fields.

    (2) is not difficult at all, use the "Create -> Tiny" and ask for behaviour.
    The default behavior is really helpful. Just make sure that you filter for your component on your component and use the OnEnable to initialize the hidden variables and the Update to move and update the necessary components (in your case, the mover and the position).
    TheFordeD likes this.
  3. TheFordeD


    Jul 9, 2018
    Thanks, but how i can get access to position variable\method to change this?

    I need change position like as SmoothDamp in Unity:

    float newPosition = Mathf.SmoothDamp(transform.position.y, moveToPosY, ref yVelocity, time);
    transform.position = new Vector3(transform.position.x, newPosition, transform.position.z);