void spawnAndFlingBullet(string _buttonToWatch, float _forceUp, float _forceForward) { Vector3 spawnProjectile = transform.position + transform.forward * m_OffsetForwardEarth; RaycastHit hit; if (Physics.Raycast(spawnProjectile, -Vector3.up, out hit, 50)) { if (m_attackObject.transform.childCount == 0) { return; } Transform child = m_attackObject.transform.GetChild(0); MeshRenderer meshRenderer = child.GetComponent <MeshRenderer>(); spawnProjectile = hit.point - new Vector3(0, meshRenderer.bounds.extents.y, 0); FlingableRock tmpBullet = ((GameObject)Instantiate(m_attackObject, spawnProjectile, Quaternion.identity)).GetComponent <FlingableRock>(); tmpBullet.setUser(m_username); tmpBullet.init(null, _forceUp, _forceForward); } }
private void spawnAndFlingBullet(AttackLauncher _launcher, float _forceUp, float _forceForward) { Vector3 spawnProjectile = transform.position + transform.forward * m_OffsetForwardEarth; RaycastHit hit; if (Physics.Raycast(spawnProjectile, -Vector3.up, out hit, 50)) { if (rockBullet.transform.childCount == 0) { return; } Transform child = rockBullet.transform.GetChild(0); MeshRenderer meshRenderer = child.GetComponent <MeshRenderer>(); spawnProjectile = hit.point - new Vector3(0, meshRenderer.bounds.extents.y, 0); FlingableRock tmpBullet = ((GameObject)Instantiate(rockBullet, spawnProjectile, Quaternion.identity)).GetComponent <FlingableRock>(); tmpBullet.setUser(gameObject); myCurrentBullet = tmpBullet; tmpBullet.init(_launcher, _forceUp, _forceForward); } }