Hello guys, im working with some shooting script this week and i want to know the easier way to get a good bullet drop, all the ways that i’ve tried so far the bullet instantly starts to fallof, doesn’t matter if it have a rigidbody attached on it or not (used transform.position.y - drop * Time.deltaTime too).
So, maybe you guys can help me with it. I don’t want anything complex, just a projectile that is instantiated and have a bullet drop.
public class Bullet_Main : MonoBehaviour
{
private float bulletSpeed;
public float destroyTime;
private float currentDestroyTime;
void Start()
{
}
void Update()
{
transform.Translate(Vector3.forward * bulletSpeed * Time.deltaTime);
currentTimeToDestroy += Time.deltaTime;
if (currentDestroyTime> destroyTime)
{
Destroy(gameObject);
}
}
public void SetBullet(float speed)
{
bulletSpeed = speed;
}
}
That’s all, my Fire method instantiate the bullet and give it the bullet speed. Also, i set a variable so i can change the destroy time.
Thank you.
EDIT:
Forgot that: i don’t have a specific target.