I am trying to set a speed to missile instead of teleporting it to a position:
public GUITexture guiTex;
public Transform missile;
public LayerMask rayMask;
private Transform target;
void Update()
{
if (Input.GetMouseButtonDown(0))
{
Ray ray = (Camera.main.ViewportPointToRay(guiTex.transform.position));
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 1000, rayMask))
{
missile.transform.position = hit.point;
}
}
}
}
i need the “missile.transform.position = hit.point;” to have a speed.
i already tried to set “target = hit.point” but then i can’t use the transform and i have to set it to vector3.
so i can’t use missile.transform.position = vector3.MoveTowards(start, target, speed);
I already tried alot of other things but it just won’t work in this script.