public override void _OnTriggerEnter2D(Collider2D coll) { base._OnTriggerEnter2D(coll); if (coll.gameObject.CompareTag("character")) { BaseController baseController = coll.gameObject.GetComponent <BaseController> (); if (baseController.mIsGround) { return; } anotherPlayer = coll.transform; Transform parent = transform.Find("Parent"); anotherPlayer.SetParent(parent != null ? parent : transform); anotherPlayer.localPosition = Vector3.zero; anotherPlayer.localEulerAngles = Vector3.zero; ControllerManage.Instance.ChangeController(this); Rigidbody2D rigidbody2d = anotherPlayer.gameObject.GetComponent <Rigidbody2D> (); rigidbody2d.bodyType = RigidbodyType2D.Kinematic; SoftSprite softObject = anotherPlayer.GetComponent <SoftSprite> (); softObject.Density = 1.0f; softObject.ForceUpdate(); } }
private void JumpDown() { if (anotherPlayer != null) { anotherPlayer.parent = null; ControllerManage.Instance.ChangeController(anotherPlayer.GetComponent <BaseController> ()); Rigidbody2D rigidbody2d = anotherPlayer.gameObject.GetComponent <Rigidbody2D> (); rigidbody2d.bodyType = RigidbodyType2D.Dynamic; SoftSprite softObject = anotherPlayer.GetComponent <SoftSprite> (); softObject.Density = 0.14f; softObject.ForceUpdate(); anotherPlayer = null; } }