move object A to B

Hi guys,

I’m having trouble moving one object to another objects position… Im pretty sure it has to do with Vector3 stuff but i just dont understand it and what I’m doing wrong, can anyone help?

cheers

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class follow : MonoBehaviour {
public GameObject cam;
public GameObject goal;
private Vector3 velocity = Vector3.zero;      
public float smoothTime = 0.3F;               

	
	// Update is called once per frame
	void Update () {
		 cam.transform.position = Vector3.SmoothDamp(transform.position, goal, ref velocity, smoothTime);
	}
}

void Update () {
cam.transform.position = Vector3.SmoothDamp(cam.transform.position, goal.transform.position, ref velocity, smoothTime);
}

The first parameter and the storing result should be the same variables. It does not have to be at all time but it actually is most of the time.

You take the current value of your camera, then you check the target value and move towards it by a factor. Then place that result in the camera value so it has a new value.

You can also use lerp to compare the result. Basically lerp is linear and smooth is a curve.