Home > other >  UGUI canvas in the following the movement of the object
UGUI canvas in the following the movement of the object

Time:09-19

Everyone a great god, and how to make the canvas below several different positions of the image, when click on it to be able to realize from their own moves to the center of the screen

CodePudding user response:

And when she is able to achieve click move to the center position, the image appears on a back key, click back to the original position, and can realize the zoom in and out of animation effects

CodePudding user response:

Vector3. Lerp (Vector3 a, Vector3 b, float t);

CodePudding user response:

You can do this things in dotween plug-in, tween animation have an oncomplete callback in the callback also use dotween execution back to the original location of the animation, in the most began to move his record an original position.
If it's not dotween can also in the update their writing animation as upstairs said with a vector3. Lerp method to Screen the middle Screen. The width/2, the Screen. The height/2

CodePudding user response:

How to control it's movement speed, using vector3. The lerp this method can control?

CodePudding user response:

Quote: refer to the third floor Lqyilo response:

How to control it's movement speed, using vector3. The lerp this method can control?

CodePudding user response:

The location of the mobile: nature is his position each frame changes slowly in the past,

Button zoom in general is to use the button component, hanging inside general button Animator, loosen press zoom zoom,

CodePudding user response:

Vector3. Lerp the last parameter is the percentage of the transition, count themselves transition time can
Lerp pseudo-code roughly as follows:
Vec lerp (vec A, vec B, percent)
{
Return A * (1.0 -percent) + B * percent;
}

So he is, the total time starting from the animation begins to play accumulative deltaTime, that you can gain has been broadcast time passTime,
Percent=passTime/totalTime;

CodePudding user response:

[b]
refer to 7th floor wurh80 response:
vector3. The lerp the last parameter is the percentage of the transition, count themselves transition time can
Lerp pseudo-code roughly as follows:
Vec lerp (vec A, vec B, percent)
{
Return A * (1.0 -percent) + B * percent;
}

So he is, the total time starting from the animation begins to play accumulative deltaTime, that you can gain has been broadcast time passTime,
Percent=passTime/totalTime; [/b

Not understand how to operate...

CodePudding user response:

using UnityEngine;

Public class Moving: MonoBehaviour
{

Public Vector3 Begin=Vector3. Zero;
Public Vector3 end=Vector3. One;
Public float totalTime=1.0 f;

Float passTime=0.0 f;

Void OnEnable ()
{
PassTime=0.0 f;
}

Void the Update ()
{
PassTime +=Time. DeltaTime;
Float NormalizeTime=passTime/totalTime;

If (NormalizeTime & gt; 1.0 f)
NormalizeTime=1.0 f;

The transform. The position=Vector3. Lerp (Begin and end, NormalizeTime);
//The same as:
//the transform. The position=Begin * (1.0 f - NormalizeTime) + end * NormalizeTime;
}

}


Can try this, three public out in front of the panel to change the value, then hide the reactivation of this component will play animation
This should be enough to explain everything

CodePudding user response:

If you want to control speed can add a value where the update passTime modified into

PassTime +=Time. DeltaTime * speed;
  • Related