private void OnTriggerEnter2D(Collider2D collision) { departPlayer = false; StickSpeed = GameObject.FindGameObjectWithTag("Stick").GetComponent <StickPlus>(); if (collision.CompareTag("Stick") || collision.CompareTag("PrefabStick")) { /*rb2D.velocity = Vector2.zero;*/ StickSpeed.Speed = 0; oui(); Debug.Log("Merguez"); departPlayer = true; DestroyComponent(); } if (departPlayer == true) { Player.GetComponent <Rigidbody2D>().AddForce(Vector2.right * 150); departPlayer = false; StickSpeed.enabled = true; } }
void Update() { MyStickPlus = GetComponent <StickPlus>(); foreach (KeyCode kcode in Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(kcode)) //Event.current.keyCode { stopStick = true; } else if (compteur == 2500) { print(compteur); status = true; } } if (stopStick == true) { RotationDuStick(); return; } else if (stopStick == false) { } if (compteur == 0) { print(compteur); status = false; } else if (compteur == 1580) { print(compteur); status = true; } if (status == true) { temp = transform.localScale; temp.y -= Time.deltaTime; transform.localScale = temp; compteur--; } else if (status == false) { temp = transform.localScale; temp.y += Time.deltaTime; transform.localScale = temp; compteur++; /* float smooth = 5.0f; * float tiltAngle = 90.0f; * * { * // Smoothly tilts a transform towards a target rotation. * float tiltAroundZ = Input.GetKeyDown(KeyCode.A) * tiltAngle; * * * // Rotate the cube by converting the angles into a quaternion. * Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ); * * // Dampen towards the target rotation * transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth); * }*/ } }
void Awake() { m_rb2D = gameObject.GetComponent <Rigidbody2D>(); m_renderer = gameObject.GetComponent <SpriteRenderer>(); MyStickPlus = GetComponent <StickPlus>(); }