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 C Griffin · Feb 15, 2013 at 12:01 AM · gameobjectpositionplayereditplace

How to have the Player place GameObjects in scene at runtime?

Long story short, what are the concepts to let the player place GameObjects in the scene in game.

e.g. Player has built a fence section and I would like him to place it in the scene wherever they please.

I was thinking of RayCasting and then having code to change the position and rotation of the Object in question to that of the point where the ray contacts the terrain or similar. Is this the correct way to go about it? Are there other methods I should use? Is this even feasible in Unity?

My goal is for extreme customization to the environment that would mean letting the player place GameObjects wherever they deem fit.

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 D12Duke1 · Mar 22, 2016 at 04:05 AM 0
Share

why the eff is this not an asset? I've paid 50 dollars for assets in the past and would pay upward to 100 for a complete 'place object' system...

2 Replies

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

Answer by Danmietz · Feb 15, 2013 at 01:03 AM

GameObject.Instantiate() will let you instantiate a new instance of an existing object or prefab, with potential paramaters of a position and rotation. From the sounds of it, this is what you're after; as you suggested, the best way to go about it would be to raycast to find their selected location and then instantiate the selected object.

From there, (depending on what you wanted to do with it) you could allow the rotation/further translation of the newly instantiated object.

If you're concerned about the performance impact of instantiating objects, you could then look at pooling your objects, but as far as the functionality you're after you should be ok with the above.

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 C Griffin · Feb 15, 2013 at 01:25 AM 0
Share

That was what I was thinking. I would check for Vector3.Up and Terrain tag, yadda yadda yadda. I was just worried that this would not work for some reason, as I'm still relatively new to Unity, and program$$anonymous$$g in general so I guess I was just looking for the best way(s) to go about this.

$$anonymous$$y other idea was a grid system of some sort, kind of like what you would find in Starcraft, but I don't think that would work as well with a large 3D environment, where everything won't be lined up on the same axes.

I'm just worried my code will be convoluted and disorganized by the time I'm done, lol.

Thanks again, much obliged.

avatar image
0

Answer by jumisko · Sep 17, 2020 at 10:50 PM

For anyone still seeking answers to this question, check out this video. It helped me a lot.

Player placing objects at mouse cursor

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

create a gameobject in front of fpsplayer 2 Answers

Camera rotation around player while following. 6 Answers

How to determine the direction of an object to the player. 1 Answer

How do I spawn a bullet correctly and add velocity to it? 1 Answer

PlayerPrefs Saving Player's Position Java Script 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