Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 TheflyingDutchmen · Nov 24, 2016 at 04:24 AM · 2dphysicsmobiledevelopmentshapes

Making a 2D line?

Hey everyone,

I want to see if I can make a line when the user touches the screen on their phone and have two colliders that detect the start and end point.

Here is what I have in mind:

alt text

So I want the user to press on the semi-circle on the left and then pull the line down to the right semi-circle.

Can someone help? I really cant seem to think of a way to approach this one?

Cheers,

screen-shot-2016-11-23-at-214953.png (23.3 kB)
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 hexagonius · Nov 25, 2016 at 12:27 AM 1
Share

you could use a line renderer and configure it with two points. the first is always the center of the first collider object and the second gets updated with the finger position.
or you have a gameobject with a quad $$anonymous$$esh and renderer childed to an empty gameobject offset by .5f, have the parent positioned at the first collider, have it look at Vector3.forward, while the up vector used is towards the finger position and scale it by the distance between finger and collider.

avatar image TheflyingDutchmen · Nov 27, 2016 at 08:19 AM 0
Share

Hey thanks for your reply,

But do you reckon I could add a collider to it so that it debugs a message that says it has hit the second semi-circle?

Can you add a collider to the line renderer so that the ball understands it has been hit?

If you could reply, that would be great.

Cheers

avatar image hexagonius TheflyingDutchmen · Nov 28, 2016 at 04:30 PM 1
Share

afraid not, the line renderer consists only of positions. it does not even need to start at it's own transform position. But what you could do is attach colliders to the semi circles. because your finger reaches them indefinitely. you can use raycast to check if you hit them

avatar image TheflyingDutchmen hexagonius · Nov 28, 2016 at 07:26 PM 0
Share

Cheers Hexagonuis.

I will try it out and let you know how it went.

Thanks.

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Change shape of object upon collision 1 Answer

Run some code just after physics is calculated 1 Answer

Size and Position of BoxCollider 2 Answers

Once more with the Aspect Ratio's 1 Answer

Lights that ignore position.z of GameObject 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