// 初始化 void Start() { Instance = this; this.transform.parent = null; audio = GetComponent <AudioSource>(); anim = GetComponentInChildren <Animator>(); rgb = GetComponent <Rigidbody>(); original_scale = new Vector3(0.07f, 0.07f, 0.07f); // Add all the states to a list for easy disable of all but one. sonic_states.Add("is_idle", is_idle); sonic_states.Add("is_standard_movement", is_standard_movement); sonic_states.Add("is_boosting", is_boosting); sonic_states.Add("is_spindashing", is_spindashing); sonic_states.Add("is_homing_attack", is_homing_attack); sonic_states.Add("is_grinding", is_grinding); sonic_states.Add("is_drifting", is_drifting); sonic_states.Add("is_wall_colliding", is_wall_colliding); sonic_states.Add("is_riding", is_riding); sonic_states.Add("is_springing", is_springing); if (starting_pos != Vector3.zero) { this.transform.position = starting_pos; } }
IEnumerator Spin() { rb2d.isKinematic = true; //rb2d.velocity = new Vector2(0, 0); SonicController sc = player.GetComponent <SonicController>(); // sc.currSpeed = 0; sc.isAnimated = true; // player.GetComponent <Animator>().ResetTrigger("isRunning"); player.GetComponent <Animator>().SetTrigger("isRolling"); // player.transform.parent = anchor.transform; // anchor.GetComponent <Animator>().enabled = true; loopCollider.GetComponent <PolygonCollider2D>().isTrigger = true; // Hide behind loop sprite player.GetComponent <SpriteRenderer>().sortingOrder = -1; // yield return(new WaitForSeconds(1)); // After animation player.GetComponent <Animator>().SetTrigger("isRunning"); player.transform.parent = null; anchor.GetComponent <Animator>().enabled = false; sc.isAnimated = false; sc.currSpeed = 0.5f; yield return(new WaitForSeconds(0.35f)); player.GetComponent <SpriteRenderer>().sortingOrder = 10; loopCollider.GetComponent <PolygonCollider2D>().isTrigger = false; rb2d.isKinematic = false; yield return(new WaitForSeconds(0.5f)); // Set grounded to allow jumping after animation groundedCheck.GetComponent <GroundedCheck>().isGrounded = true; transform.GetComponent <BoxCollider2D>().enabled = true; //sc.isAnimated = false; //sc.currSpeed = 0; }
// Start is called before the first frame update void Start() { rb2d = player.GetComponent <Rigidbody2D>(); sc = player.GetComponent <SonicController>(); anchor.GetComponent <Animator>().enabled = false; }