bullet from the gun instantiate at right position when the gun is not a child of my player,but when i picked up the gun the bullet instantiate from different position…
this is the link of the video which i’m facing right now…
I'm not able to reply on you comment....!!!!here is my script
using UnityEngine;
using System.Collections;
public class WeaponInformation : MonoBehaviour {
public Vector3 LocalPositionInHand = new Vector3(-0.027615f, -0.10848f, -0.08597f);
public Quaternion LocalrotationInHand = Quaternion.Euler(-13.8380f, 32.90746f, 172.209f);
public int GunType;// 5=throwable , 1 = handgun , 2 = assultgun
public int BulletInMagazine ;
public int BulletBackup;
public int MagazineCanHold;
public GameObject Bullet; // Drag the sphere to the Bullet
public Transform BarrelPosition; // Drag the barrel to the BarrelPosition
public bool Trigger = false;
public bool Reload = false;
public bool AutoFire = true;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
//Fire Script
if (Trigger == true && BulletInMagazine > 0) // The Trigger is controlled from Weapon Handling Script which is attached to the player
{
BulletInMagazine -=1;
Instantiate (Bullet,BarrelPosition.position,BarrelPosition.rotation);
Debug.Log (BarrelPosition.position);
}
//Reload Script
if (Reload == true && BulletInMagazine!=MagazineCanHold)
{
if(BulletBackup>=(MagazineCanHold - BulletInMagazine))
{
BulletBackup = BulletBackup - (MagazineCanHold - BulletInMagazine);
BulletInMagazine = BulletInMagazine + (MagazineCanHold - BulletInMagazine);
}
if(BulletBackup<(MagazineCanHold - BulletInMagazine))
{
BulletInMagazine = BulletInMagazine + BulletBackup;
BulletBackup =0;
}
}
Physics.IgnoreCollision(GameObject.FindWithTag ("Player").GetComponent<CapsuleCollider>(), GetComponent<Collider>());
}
}