Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by elilittrell · Dec 04, 2020 at 02:53 AM · delayfreezepositionfreezerotation

Needing help on Delaying and Freezing Axis.

So I am trying to Delay A command and Freeze All The Axis for my die function on my charachter.

delaying here //Wait .1 seconds to call the next line

Freezing Axis here //Freeze all points/axis

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class PlayerCombat : MonoBehaviour { public Rigidbody2D rb; public GameObject Player; public Animator animator; [Space] public LayerMask enemyLayers; [Space] public Transform attackPoint; public float attackRange = 0.5f; public int attackDamage = 15; [Space] public float attackRate = 2f; float nextAttackTime = 0f; [Space] public int maxHealth = 100; int currentHealth;

 // Start is called before the first frame update
 void Start()
 {
     currentHealth = maxHealth;
 }

 public void TakeDamage(int damage)
 {
     currentHealth -= damage;


     animator.SetTrigger("Hurt");

     if (currentHealth <= 0)
     {
         animator.SetBool("IsDead", true);

         //Wait .1 seconds to call the next line

         Invoke("Die()", 0.1f);
     }

     void Die()
     {


         animator.SetBool("IsDead", true);

         rb.constraints = RigidbodyConstraints2D.FreezeAll;

         //Freeze all points/axis

         GetComponent<Animator>().enabled = false;
         GetComponent<Collider2D>().enabled = false;
         this.enabled = false;
     }

     // Update is called once per frame
     void Update()
     {

         if (Time.time >= nextAttackTime)
         {

             if (Input.GetButtonDown("Fire1"))
             {
                 Attack();
                 nextAttackTime = Time.time + 1.5f / attackRate;
             }
         }

     }

     void Attack()
     {
         animator.SetTrigger("Attack");

         Collider2D[] hitEnemeies = Physics2D.OverlapCircleAll(attackPoint.position, attackRange, enemyLayers);

         foreach (Collider2D enemy in hitEnemeies)
         {
             enemy.GetComponent<Enemy>().TakeDamage(attackDamage);
         }
     }

     void OnDrawGizmosSelected()
     {
         if (attackPoint == null)
             return;
         Gizmos.DrawWireSphere(attackPoint.position, attackRange);
     }

 }

}

I am not sure what to do that will work without errors, I am not even sure if "delaying" is what I need?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image elilittrell · Dec 08, 2020 at 03:50 AM 0
Share

okay I got the constraints to freeze, but I still need know how to delay

avatar image elilittrell · Dec 08, 2020 at 03:51 AM 0
Share

If I can get an answer that would be great, really any information is good

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

138 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Rigidbody: Freeze All vs InKinematic 0 Answers

cannot have all constraints on in rigidbody? 1 Answer

How do you REALLY freeze a Rigid Body (no dragging allowed)? 1 Answer

STAY STILL 2 Answers

I cannot freeze both position on one axis together with rotation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges