Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 abhisheyk · Jan 19, 2017 at 12:09 AM · gameobjectinstantiatecrosshairradar

Instantiating game object

So I have a model which is shown as follows:

alt text As you can see there are two sliders and 2 planes whose scale I have reduced to make them seem like lines. There must be better ways for drawing lines. I want to instantiate an object at the intersection point(red circle). I can move the horizontal and vertical lines (orange) using the sliders and where ever they intersect I want to instantiate a gameobject which can be a small sphere. So how can I approach this problem.

nav.png (95.3 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by juicyz · Jan 19, 2017 at 12:36 AM

You can either find the point of intersection using the planes but likely the best way is to do some math using the slider values to place the red dot. As it seems that the lines will always intersect in some way based on the sliders and constrained position, you should be able to translate the y slider value into a y coordinate and the x slider value into a x coordinate. Place the red circle there :D

Comment
Add comment · Show 3 · 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 abhisheyk · Jan 23, 2017 at 05:31 PM 0
Share

When I try to move the slider and use the values the object is moving very far. I tried finding the intersection point using normal vectors of the two planes(transform.up), but when I do a cross product between the vectors it appears to be zero because both of their's normal vector point the same direction can you tell me whether we can use the two normal vectors to find the intersection point?

avatar image EDevJogos abhisheyk · Jan 23, 2017 at 07:01 PM 0
Share

Not sure if you've already tryed this, but sliders have a $$anonymous$$ and max value, try seting the $$anonymous$$Value = to $$anonymous$$ cordinate and the max to max, like:

The slider empty is at cordinates (540, 620) thats your $$anonymous$$ value. Then move the slider to its max and check the cordinate, that will be your max value.

Then set the object position = to each value of the slider: (horizontal.value, verticalSlider.value)

avatar image juicyz EDevJogos · Jan 23, 2017 at 07:54 PM 0
Share

Umm like I said and Search said, dont try to calculate the intersection as that's wasted time and effort. Where you want to place your dot will be at Vector2(horizontal.value, vertical.value). Since it appears by your UI, there will always be an intersection you can just simply get the x and y from the sliders as that is what they represent.

Then you just draw your circle and should also set the parent to the canvas. You are drawing it on the canvas or game? If you need world coordinates then you need to take that Vector2 (Vector2(horizonal, vertical) and convert it to world coordinates using the Camera.ScreenToWorld or something like that.

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

How can I add the OnTriggerEnter function to all game objects that I instantiate? 1 Answer

Instantiating GO infront of player 2 Answers

C# 2d Instantiate object randomly around gameobject 1 Answer

Souls pickup mechanic (Like Dark Souls, BloodBourne) 0 Answers

UnityEngine.Object.Instantiate 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