Before you start scolding me, I have checked many different search engines about this, including Unity Answers.
I am attempting to make a realistic post-apocalyptic game, and my bullets need some bullet drop. I made my shooting script like so:
if(ItemType == ItemTypeEnum.GunFullAuto){
if(Input.GetButton("Fire1")){
if(AmmoInCurrentMag > 0){
FireOneShot();
ReloadAnim.animation.CrossFade(itemName + "Shoot", 0.1);
recoil2 -= new Vector3(0, 0, recoil / 2);
recoil4 -= new Vector3(recoil * 75, Random.Range(recoil * 100, -recoil * 100), 0);
recoilNeck += new Vector3(-recoil * 30, Random.Range(-recoil * 30, recoil * 30), 0);
fireTimer = 5;
} else {
ReloadAnim.animation.CrossFade(itemName + "Idle", 0.1);
}
} else {
ReloadAnim.animation.CrossFade(itemName + "Idle", 0.1);
}
}
You can ignore the FireTimer stuff, as that is irrelevant here. My bullet is a instantiated empty GO which will activate a Raycast, like so:
function Start(){
if(networkView.isMine)
networkView.RPC("SetOwner", RPCMode.All, Database.user);
var Hit : RaycastHit;
var temp : Vector3 = gameObject.transform.position + transform.forward * maxDistance;
Tracer.GetComponent(LineRenderer).SetPosition(0, gameObject.transform.position);
if(Physics.Raycast(transform.position, transform.forward, Hit, maxDistance)){
if(!Hit.collider.isTrigger){
if(HitMetal){
var myMetal = Instantiate(HitMetal, Hit.point + (Hit.normal * HitParticleSpacing), Quaternion.LookRotation(Hit.normal));
myMetal.transform.Rotate(90, 0, 0);
myMetal.transform.parent = Hit.collider.gameObject.transform;
}
if(Hit.collider.gameObject.tag == "Player"){
Hit.collider.gameObject.GetComponent(PlayerHealthScript).Blood -= damage;
Hit.collider.gameObject.GetComponent(PlayerHealthScript).BleedingLevel += damageBleed;
Hit.collider.gameObject.GetComponent(PlayerHealthScript).SetLastShotBy(owner);
}
Tracer.GetComponent(LineRenderer).SetPosition(1, Hit.point);
} else {
Tracer.GetComponent(LineRenderer).SetPosition(1, temp);
}
} else {
Tracer.GetComponent(LineRenderer).SetPosition(1, temp);
}
}
Anyone have any idea how I can make a bullet drop OTHER THAN ROTATING THE BULLET? I should not rotate the bullet as in multiplayer the tracer would look diagonal…