void Start() { _rb = GetComponent <Rigidbody>(); _asteroidInfo = AsteroidScriptableObject.S; playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); if (_asteroidInfo != null) { wrap = GetComponent <ScreenWrap>(); //checks if has an parent and set values accordingly if (transform.parent == null) { EnableRB(); size = _asteroidInfo.size > 0 ? _asteroidInfo.size: 1; transform.localScale = Vector3.one * size; //_rb.mass = size; AddForce(Random.onUnitSphere, Random.Range(_asteroidInfo.minVelocity, _asteroidInfo.maxVelocity)); AddAngularVelocity(Random.insideUnitSphere * _asteroidInfo.maxAngularVelocity); } else { _rb.mass = size * 3; DisableRB(); } AddChildren(); } //initializing events if (onDestroy == null) { onDestroy = new UnityEvent(); } }
public AsteroidScriptableObject() { S = this; }