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
1
Question by BaldBadger · Mar 10, 2013 at 03:58 AM · spawnrespawnrpgnodegathering

Node Respawn Script?

Sorta new to scripting (can read a script and understand it, but unsure of how to make one myself). I'm trying to write a script for nodes of minerals, such as Ore for mining in a game that you can gather from them.

I know I want to write something that would set the ore to be "alive" on awake, and then when it is gathered, or "killed", destroy it, then start a respawn timer, and then when the respawn timer hits 0, make it spawn that object to a certain point again.

I figure my variables would look something like this:

var respawnTimer : float = 10; var orePrefab : Transform; var spawnPoint : Transform; var oreDead : boolean = false;

.... Now, I'm not sure where to start, or what it would look like, or if I'm even missing some key variables... any tips?

Comment
Add comment · Show 3
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 Statement · Mar 10, 2013 at 04:21 AM 0
Share

What you want to make might be very clear in your head but it's very abstract for us (at least me) to understand what you want to do, what an ore node is represented by in your game and so on.

Could you tell us a little bit more about what you want to learn and how you picture the game part to look like? $$anonymous$$g. "There should be 3 icons on the screen. Each time I click one, my resource points for that resource should tick up by one. When I click a resource 5 times, that one should disappear for 10 seconds, sort of a cool down effect."

avatar image Kleptomaniac · Mar 10, 2013 at 04:28 AM 0
Share

Not particularly sure what he means by nodes, but I believe all he wants to know is how to respawn his ore objects after a certain period of time following them having been destroyed. Am I correct @BaidBadger?

I would check out Invoke() for your respawn timer, as this will allow you to invoke a function after a certain period of time has elapsed. :)

avatar image BaldBadger · Mar 10, 2013 at 04:41 AM 0
Share

Yes, you're correct actually... I was referring to the spent ore's original form as a "node" (Old WoW nerd ._.).

And that sounds wonderful... $$anonymous$$d dropping a link to a good reference?

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Statement · Mar 10, 2013 at 04:48 AM

You could disable the collider of the ore node and hide the object until some time has expired.

You could do something like:

 function OnOreDespawn() {
     renderer.enabled = false;
     collider.enabled = false;
     Invoke("OnOreRespawn", 60); // Respawn in 1 minute
 }

 function OnOreRespawn() {
     renderer.enabled = true;
     collider.enabled = true;       
 }

But you'd need some code that calls OnOreDespawn after it has been "consumed".

Comment
Add comment · 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

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

12 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

Related Questions

Help! My respawn script isn't working! (Answered) 4 Answers

Respawn random objects 1 Answer

Why doesnt my checkpoint system work? 1 Answer

Respawn after falling off script? 2 Answers

Character respawns invisable? 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