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 DeadKenny · Sep 12, 2013 at 05:31 PM · c#airandomspawnspawning

AI spawning areas. What are the ways to make them?

I was thinking of making a gigantic collider and making a randomising code which would randomly pick a point given some ifs and linked to game time.

Is that good idea? Is it possible with a collider?

What other ways, better or worse are there?

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 AndyMartin458 · Sep 12, 2013 at 05:33 PM 2
Share

Well, the way that I've done before is to actually pick points that will be good for spawning. You might find it completely satisfactory that new players can't spawn at any place in the map. $$anonymous$$y suggestion is to pick 5 points to start with. Have your AI use a rand to pick one of those 5 points as their spawn point.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by clunk47 · Sep 12, 2013 at 05:39 PM

Why don't you just use some empty gameObjects and access their Transforms as spawn points?

OR

Use a random range for each axis in a Vector3.

 position = new Vector3(Random.Range(0, 100), Random.Range(0, 100), Random.Range(0, 100));

Also have a look at Collider.Bounds if you HAVE to use a collider.

Comment
Add comment · Show 5 · 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 DeadKenny · Sep 12, 2013 at 08:03 PM 1
Share

I don't want points like in skyrim or fallout, thats weak. I want properly random within a big area type spawning. The terrain can get very barren and open in most places so things getting spawned in shouldnt cause any issues with colliding. Also the way the AI is spawned makes them not appear instantly, so that nothing will just pop into your face.

What I need is a way for picking a random point wihin a collider. Is that possible?

avatar image AndyMartin458 · Sep 12, 2013 at 08:10 PM 1
Share

I don't know about a collider specifically. You could make your own point generator though if you were given the coordinates you want to spawn in. Like if your colliders are spread throughout the level, and you want it to spawn within them (and they are large). Randomly pick a collider, and then generate a point (naieve implementation), that fits the constraints of the collider. I don't really know where Skyrim came from. I suppose I was thinking of Halo, where there are lots of points throughout the level from where you can spawn.

avatar image clunk47 · Sep 12, 2013 at 08:25 PM 2
Share

Use a random range for each axis in a Vector3.

position = new Vector3(Random.Range(0, 100), Random.Range(0, 100), Random.Range(0, 100));

avatar image clunk47 · Sep 12, 2013 at 08:26 PM 2
Share

Also have a look at Collider.Bounds if you HAVE to use a collider.

avatar image DeadKenny · Sep 12, 2013 at 10:00 PM 2
Share

Ah ok clunk47. Thats what I wanted to see.

I can make those ranges within the size of a collider and use the collider to set the ifs of Players entering it and such.

Ok I think I have the basic idea now. Implementing it will happen soon, which will most likely include me running back here confused as usual.

Thanks dudes.

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

18 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

Related Questions

Enemies spawn on top of each other(C#)(Unity) 1 Answer

Distribute terrain in zones 3 Answers

Why is this room always spawning on left side? 1 Answer

How do I spawn objects randomly near an object then delete them? 1 Answer

Spawn random Obstacles along the x-axis 0 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