void Start() { meshRend = GetComponent <MeshRenderer>(); generalInfoHandler = GameGeneralInfo.Instance; if (generalInfoHandler == null) { Debug.LogError("General Info For Bullet Is Null"); } BulletWhizzRadius = (PlayerCharacterNew.Instance.bulletWhizzLot.GetComponent <SphereCollider>()).radius * 2 + 0.1f; if (direction == Vector3.zero) { direction = transform.forward; } Ray ray = new Ray(transform.position, direction); RaycastHit hitInfo; float rayMagnitude = MaxDistance; bool hitToPlayer = false; if (Physics.Raycast(ray, out hitInfo, rayMagnitude, generalInfoHandler.HitLayer)) { Ray newRay = ray; RaycastHit newRayHitInfo = hitInfo; bool rayHittedOk = true; if (GameObject.Equals(hitInfo.collider.transform.root.gameObject, Owner)) { newRay = new Ray(hitInfo.point + direction * 0.0001f, direction); if (!Physics.Raycast(newRay, out newRayHitInfo, rayMagnitude, generalInfoHandler.HitLayer)) { rayHittedOk = false; } else { //Debug.DrawLine(newRay.origin, newRayHitInfo.point, Color.red, 10); } } if (rayHittedOk) { if (newRayHitInfo.collider.gameObject == PlayerCharacterNew.Instance.bulletWhizzLot) { Vector3 startingPoint = newRayHitInfo.point + (newRay.direction * 0.0001f); Ray checkingRay = new Ray(startingPoint, newRay.direction); RaycastHit CheckinHitInfo; if (Physics.Raycast(checkingRay, out CheckinHitInfo, BulletWhizzRadius, generalInfoHandler.HitLayer)) { if (CheckinHitInfo.collider.gameObject == PlayerCharacterNew.Instance.gameObject) { hitToPlayer = true; //Debug.DrawLine(checkingRay.origin, CheckinHitInfo.point, Color.blue, 10); } } } else { if (!hitToPlayer) { string rootTag = newRayHitInfo.collider.transform.root.tag.ToLower(); if (rootTag == GeneralStats.playerTagName_ToLower) { //Debug.DrawLine(newRay.origin, newRayHitInfo.point, Color.yellow, 10); hitToPlayer = true; } } } } } velocity = direction * Speed; if (hitToPlayer) { velocity *= 70; if (meshRend != null) { meshRend.enabled = false; } } startPosition = transform.position; shootPoint.x = startPosition.x; shootPoint.y = startPosition.y; shootPoint.z = startPosition.z; hitManager = GetComponent <HitEffectManager>(); }
//public GameObject[] Soldiers_Hindi_Springfield; //public GameObject[] Soldiers_Hindi_MP18; //public GameObject[] Soldiers_English_Springfield; //public GameObject[] Soldiers_English_MP18; //public GameObject[] Soldiers_Ally; void Awake() { Instance = this; }