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. Dismiss Notice

Move Entity

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

  1. TheFordeD

    TheFordeD

    Joined:
    Jul 9, 2018
    Posts:
    32
    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

    Guilherme-Otranto

    Joined:
    Mar 12, 2014
    Posts:
    28
    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

    TheFordeD

    Joined:
    Jul 9, 2018
    Posts:
    32
    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);