Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity move in x seconds to pos

    StartCoroutine(moveToPosition(yourTransform, newPosition, time));

public IEnumerator moveToPosition(Transform transform, Vector3 position, float timeToMove)
    {
        var currentPos = transform.position;
        var t = 0f;
        while (t < 1)
        {
            t += Time.deltaTime / timeToMove;
            transform.position = Vector3.Lerp(currentPos, position, t);
            yield return null;
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: AutoMapper Add Assemblies 
Csharp :: reflection static method c# 
Csharp :: using randomly chars to build a string 
Csharp :: asp.net issue 
Csharp :: .net 6 minimal api authorization net 6 
Csharp :: asp.net mvc class="" inline select 
Csharp :: c# decimal literal 
Csharp :: who is dani? game dev 
Csharp :: How to get the value of an input button in an ASP.NET Core MVC controller 
Csharp :: C# Move Camera Over Terrain Using Touch Input In Unity 3D - Append To Camera 
Csharp :: how to change an object color with fill c# 
Csharp :: C# downloadstirng download old 
Csharp :: c# treeview keep selected node highlight 
Csharp :: c# Color Convert 
Csharp :: tempdata serializer cannot erorr 
Csharp :: generate an mvc controller when dotnet core command line 
Csharp :: remotefx 3d video adapter warning 
Csharp :: log4net.dll 
Csharp :: regex ip rage detect 
Csharp :: unity torque distance joint 
Csharp :: telerik mvc grid required field 
Csharp :: .net return context.Result without extra new objectResult 
Csharp :: dotnet core ef add multiple records 
Csharp :: c# call by reference 
Csharp :: json string to JObject object c# camelCasing key .net 
Csharp :: C# program applies bonus points 
Csharp :: .net open config file by name 
Csharp :: windows forms picturebox click event 
Csharp :: C# string go to line 
Csharp :: c# check number is odd or even 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =