Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Help With Rigidbody.AddForce and "Frozen Time"

$
0
0
I'm making a game where when "time is frozen", after a certain amount of hits, the amount of hits will be affected after time resumes. The way I simulated frozen time was by making the enemies' rigidbodies kinematic. With my current code, after time resumes, nothing happens. void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "enemy") { if (animator.GetCurrentAnimatorStateInfo(0).IsName("Barrage") || (animator.GetCurrentAnimatorStateInfo(0).IsName("Hook Punch"))) { collision.gameObject.GetComponent().AddForce(transform.up * hitForce, ForceMode.Impulse); } if (TimeFroze == true) { if (animator.GetCurrentAnimatorStateInfo(0).IsName("Barrage")) { hits = hits + 1; for (int i = 0; i < hitrb.Length; i++) { hitrb = collision.gameObject.GetComponents(); } StartCoroutine(Damage()); } } } } private IEnumerator Damage() { yield return new WaitUntil(() => TimeFroze == false); foreach (Rigidbody enemyrb in hitrb) { enemyrb.AddForce((transform.up * hits) * hitForce, ForceMode.Impulse); } StopCoroutine(Damage()); }

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>