how can i make an object move from one point to another… like a bullet in a gun
There are couple of ways to approach this. If you simply want to fire a bullet then the easiest would be to do the following.
void Update()
{
Vector3 directionOfFire = Vector3.forward;
float bulletSpeed = 10f;
gameObject.transform.Translate(directionOfFire * Time.deltaTime * bulletSpeed);
}
But if you want to move a bullet from one fixed point to another (which is not how it normally happens, but still might be a requirement in your game) the following might help you.
private float m_DeltaTime = 0f;
private Vector3 m_StartPos;
private Vector3 m_EndPos;
void Start()
{
m_StartPos = Vector3.zero;
m_EndPos = Vector3.left * 100f;
}
void Update()
{
if(m_DeltaTime < 1f)
{
m_DeltaTime += Time.deltaTime;
gameObject.transform.position = Vector3.Lerp(m_StartPos, m_EndPos, m_DeltaTime);
}
}