Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity movetowards 2d

/// <summary>
/// Move 2D sprite towards target
/// </summary>
/// <param name="target"></param>
/// <param name="movementSpeed"></param>
private void Move(Vector3 target, float movementSpeed)
{
    //Move
    transform.position += (target - transform.position).normalized * movementSpeed * Time.deltaTime;
}
 
PREVIOUS NEXT
Tagged: #unity #movetowards
ADD COMMENT
Topic
Name
1+4 =