Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Sep 25, 2017 at 03:13 PM by LemurusBalok for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by LemurusBalok · Sep 24, 2017 at 10:50 AM · delayinvoke

Invoke Method Not Working Properly!

I am trying to make a Simple Turn-Based Combat and have almost achieved it. However, I wanted some delay between the Enemy Turns and so I introduced a Delay between their attack scripts using INVOKE() Function. But this results in an overall Delay between the Player and the Enemy Turns, and not between the Enemy Turns (i.e) Once The player completes his/her turn, the Enemy Attack Scripts Fire TOGETHER after the delay I gave in INVOKE.

What am I doing wrong here?

case ENEMYTURN:

         GameObject[] EnemyObjects = GameObject.FindGameObjectsWithTag ("Enemy");

         foreach (GameObject EnemyObject in EnemyObjects)
             EnemyObject.GetComponent<SkeletonWarrior> ().Invoke("attackPlayer", 3f);

         nTurnMode = PLAYERTURN;
         break;
Comment
Add comment · Show 1
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 navot · Sep 24, 2017 at 12:04 PM 0
Share

I'm guessing the 3 seconds is based on the current time, so I would replace the foreach loop with a for loop, and multiply the delay by the index

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by TheMannyzaur · Sep 24, 2017 at 03:07 PM

trying using a bool that the player script can access so that when the player's move is done it calls on the bool in the enemy's script to be true. if the bool is true then you Invoke the function! hope that helps

Comment
Add comment · Show 1 · Share
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 LemurusBalok · Sep 25, 2017 at 03:13 PM 0
Share

I did exactly that after posting this Question! Thank you very $$anonymous$$uch!!

Follow this Question

Answers Answers and Comments

70 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

Related Questions

Why won't invoke work in my script to delay the scene change? 1 Answer

Delay If statement in Update c# 2 Answers

Repeating after variable delay 1 Answer

Access to float seconds ago 2 Answers

Why is my program not working properly ? 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