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 rick-grendel · Jul 29, 2014 at 09:56 AM · colliderprefabrandom

random spawn assigned prefab from collider

Hello I need an script that spawn a assigned prefab from al collider this must be random and the spawning must go faster and faster until the player dies

Comment
Add comment · Show 4
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 VesuvianPrime · Jul 29, 2014 at 10:10 AM 0
Share

What have you written so far?

avatar image rick-grendel · Jul 29, 2014 at 10:12 AM 0
Share

nothing I dont know anything about that spawn thing

avatar image T27M · Jul 29, 2014 at 10:45 AM 0
Share

Start here?

avatar image rick-grendel · Jul 29, 2014 at 10:49 AM 0
Share

T27$$anonymous$$ its a beginning but it must be the whole time and it must go faster in time

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by VesuvianPrime · Jul 29, 2014 at 11:29 AM

Rick, typically you need to show some effort on your part before asking the community for help. You can't expect us to write your game for you.

Programming is a matter of breaking down a large problem into smaller pieces.


Your problem is:

"I need an script that spawn a assigned prefab from al collider this must be random and the spawning must go faster and faster until the player dies"

We can break this down into a number of small problems:

1) Assigning a prefab to a variable on a script.

2) Instantiating the prefab.

3) Instantiating the prefab in a random place.

4) Instantiation is on a timer, and must increase in frequency.


The video T27M posted is perfect, and addresses points 1&2 very well.

For point 3 we can look at the UnityEngine.Random class: http://docs.unity3d.com/ScriptReference/Random-insideUnitSphere.html


Point 4 is where things get a little more interesting.

Firstly, we should take a look at the script reference for Time: http://docs.unity3d.com/ScriptReference/Time.html

You're going to need to write some kind of emission timer to handle your instantiation intervals:

 public class Emitter : MonoBehaviour
 {
     private float m_LastEmission;
 
     // You'll need to adjust this line to get the rate you want
     public abstract float emissionRate { get {return Time.time;} }
 
     protected void Update()
     {
         float elapsed = Time.time - m_LastEmission;
         int numEmissions = Mathf.FloorToInt(emissionRate * elapsed);
 
         Emit(numEmissions);
 
         if (numEmissions <= 0)
             return;
 
         float emissionTimePerInstance = 1.0f / emissionRate;
         m_LastEmission += emissionTimePerInstance * numEmissions;
     }
 }




Comment
Add comment · Show 2 · 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 rick-grendel · Jul 29, 2014 at 12:12 PM 0
Share

this thing is to hard for me can you please help me

avatar image T27M · Jul 29, 2014 at 12:25 PM 0
Share

You have got everything you need! We can't help you any further if you won't help yourself. Start writing some code, it probably won't work, make it work, ask specific questions about that code, repeat.

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

24 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

Related Questions

Is it possible to make thousands of colliders at once? 1 Answer

Problem with random spawning and coroutine 1 Answer

Trouble with triggers and colliders 1 Answer

This melee damage detector won't work... 1 Answer

instantiating vertically 2 Answers


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