• 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
Question by Sarethen · Mar 04, 2014 at 02:38 PM · 2dphysicsrigidbody2dslingshot

Drag and throw Rigidbody2d (Angry Birds style)

How can I achieve this?

I've been googling for hours! My scene consists of some simple shapes at the moment, a sphere and some box colliders. Got the gravity how I like it.

I just need to figure out how I can take the sphere, suspend it in space, drag it and release it and watch it fly.

Comment

People who like this

0 Show 7
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 Graham-Dunnett · Mar 04, 2014 at 02:39 PM 0
Share

What have you already tried? Why didn't it work?

avatar image Sarethen · Mar 04, 2014 at 02:45 PM 0
Share

I've found a bunch of code snippets online that involve using variations of the 'Drag Rigidbody' script but when I run the game I clicking on the rigidbody does nothing.

avatar image Getindor · Mar 04, 2014 at 02:54 PM 0
Share

So do you program or are you just looking for a cut-paste solution?

avatar image Sarethen · Mar 04, 2014 at 02:57 PM 0
Share

Cut and paste at this stage. This is just me playing around and learning the ropes. Kinda like a proof of concept.

If I were going to consider creating this for release I would delve into real coding.

avatar image CyberMew · Mar 04, 2014 at 03:04 PM 0
Share

Disable the rigidbody2d (or set it's value isKinematic = ticked/true). When you click on the birds, save it's current position. When it is being held down on the birds, set it's position to follow your mouse/input. When you release on the birds, you can calculate the direction of where you want it to go, by taking the originalpos-currentpos. You can also calculate the power here. The shorter it is, the less powerful the shot. The more their differences, the more powerful/further it can fly. At the same time, enable the rigidbody (or it's value isKinematic = unticked/false) At the same time, addforce to the birdy and it will fly "automatically" with the physics.

This is just one way to do it.

Show more comments

0 Replies

  • Sort: 

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta by June 9. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

24 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

(2D) character jumping problem [is grounded detection, rigidbody2d] 2 Answers

Need help on my script to calculate gravity for a mass 1 Answer

the player is flying off the ramp (collider) 1 Answer

How to move rigidbody relative to a moving object? 0 Answers

How can I move a 2D GameObject left/right relative to its forward direction? 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