private void Awake() { animat = GetComponent <Animator>(); weaponEquip = GetComponent <WeaponEquip>(); playerrigidbody = GetComponent <Rigidbody>(); TR = GetComponentInChildren <TrailRenderer>(); swordSound = GetComponent <AudioSource>(); }
public void ThrowAway() { if (!m_WeaponEquip) { Debug.LogWarning("Trying to throw away but weapon does not exist. Ignore."); return; } m_WeaponEquip.physicsEnabled = true; m_WeaponEquip.transform.parent = null; m_WeaponEquip.transform.localScale = Vector3.one; var _position = m_WeaponEquip.transform.localPosition; _position.x += -0.5f; m_WeaponEquip.transform.localPosition = _position; m_WeaponEquip.rigidbody2D.velocity += -3 * new Vector2 { x = transform.right.x, y = transform.right.y, }; m_WeaponEquip.rigidbody2D.angularVelocity += transform.right.x > 0 ? 100 : -100; Destroy(m_WeaponEquip.gameObject, 2); m_WeaponEquip = null; }
// Use this for initialization void Start() { _anim = GetComponent <Animator> (); _weaponEquip = GetComponent <WeaponEquip> (); }