private void Start() { _player = FindObjectOfType <PlayerController>(); _linerRenderer = GetComponent <LineRenderer>(); _soundController = GetComponent <SoundOnObject>(); _soundController.PlaySound("HarpoonShotFx", false); }
private void Start() { DestroyBullet(_destroyTime); _playerController = FindObjectOfType <PlayerController>(); _soundController = GetComponent <SoundOnObject>(); _soundController.PlaySound("RocketShot", false, _rocketLounchVolume); }
/// <summary> /// Логика уничтожения пули /// </summary> private void DestroyBullet() { //анимация взрыва _soundController.PlaySound("RocketExplosion", false, _explosionVolume); GetComponent <SpriteRenderer>().enabled = false; Speed = 0; foreach (var item in GetComponents <Collider2D>()) { item.enabled = false; } Destroy(gameObject, 1); return; }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "PickUp" && _pickUpisCatched == false) { ///Здесь подбирается зацепленный обьект и становится дочерним //я всё-таки сделал с копированием объекта. Так реально получается сильно меньше кода. _soundController.PlaySound("HarpoonHitFx", false); GameObject affectedObject = collision.gameObject; GameObject pickedUpObjectClone = Instantiate(affectedObject, affectedObject.transform.position, Quaternion.identity, transform); pickedUpObjectClone.GetComponent <ScrollingGameObject>().ScrollSpeed = 0; affectedObject.GetComponent <ScrollingGameObject>().SwitchVisibility(); _moveToTarget = false; _pickUpisCatched = true; _typeOfCathedPickUp = affectedObject.GetComponent <ScrollingGameObject>().TypeOf; } }
private void FixedUpdate() { if (CanJump) { CanJump = false; _rigidBody.AddForce(Vector2.up * JumpForce * Time.deltaTime); var rnd = Random.Range(1, 6); _soundController.PlaySound("JumpFx_" + rnd.ToString(), false); } foreach (Transform child in _groundChek) { if (Physics2D.Linecast(transform.position, child.position, _groundLayerMask)) { IsGrounded = true; break; } else { IsGrounded = false; } } }