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 KaiserJohan · Jan 12, 2012 at 08:26 AM · instantiate

Scripting within a area in the game

Hello,

I need to have a area within the game in which things will randomly instantiate. Is this possible to achieve in the editor? For example to draw some boundaries in an area and apply a script there. Or do I have to manually hardcode the area boundaries I want stuff to instantiate in?

EDIT: I have a terrain in which I want an area that will randomly spawn stuff

Thanks

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 Bunny83 · Jan 12, 2012 at 11:57 AM 0
Share

Please try to find a proper "question title". "Scripting within a area in the game" could be anything and doesn't explain anything.

Even a title of "Spawnarea" would be much more helpful ;)

$$anonymous$$eep in $$anonymous$$d that the questions should be helpful for other people as well. Also A lot people have made TD-games in Unity where you need spawning areas but they won't even look at this question...

1 Reply

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

Answer by adrenak · Jan 12, 2012 at 10:14 AM

Do it manually. Just put a trigger in the area and some empty game objects in it. When the player enters that area then instantiate the objects in the position of the game objects that you created. Generate some random numbers to decide which positions the objects will instantiated.

Comment
Add comment · Show 6 · 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 syclamoth · Jan 12, 2012 at 10:26 AM 1
Share

$$anonymous$$eep in $$anonymous$$d you don't have to 'hardcode' anything- if you make them public variables, you can still edit them in the inspector.

avatar image KaiserJohan · Jan 12, 2012 at 10:30 AM 0
Share

How do I define the boundaries of that area? Can it be done in the editor? For example is there a tool for 'marking' a section of terrain?

avatar image syclamoth · Jan 12, 2012 at 10:35 AM 0
Share

No, but feel free to write one.

avatar image KaiserJohan · Jan 12, 2012 at 10:39 AM 0
Share

How do I map this area manually then? O_O I guess I need the four X,Y,Z Corners, can you read the XYZ of where a mouse points in unity for example?

avatar image adrenak · Jan 12, 2012 at 11:19 AM 1
Share

you need not consider the 4 coordinates as you said. That way it might get complicated. If the part of the map you are interested in is lets say, square then its fine, but what if its an octagon? Ins$$anonymous$$d make a mesh that resemble the part of the map and make it a trigger and that will work as the boundary.

Show more comments

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

7 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

Set npc to active in same position as previous npc (script not working) 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

How do i Instantiate a prefab with specific assests included 3 Answers

C# Instantiating a Gameobject with a Flat Sphere Collider 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