unity make object move towards position code example
Example 1: move towards target unity
private void Move(Vector3 target, float movementSpeed)
{
transform.position += (target - transform.position).normalized * movementSpeed * Time.deltaTime;
}
Example 2: movetowards unity
void Update()
{
transform.position += (target - transform.position).normalized * movementSpeed * Time.deltaTime;
}
Example 3: how to move towards an object unity
Vector3.MoveTowards(transform.position, taretPos, Qiaternion.identiy)
Example 4: how to make an object move towards another in unity
transform.position = Vector3.MoveTowards(transform.position, taretPos, Qiaternion.identiy)