• 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
-2
Question by Chepe · Jun 05, 2010 at 03:28 AM · movementiphonedragnot-enough-information

Angry Birds hold, drag and catapult an object ...

Hi:

I want to be able to hold, drag and catapult an object from a corner of the screen to the opposite corner at an angle and speed from my drag. Download the #1 game on the Apple Store to see what I mean.

Help,

Chepe

Comment
Add comment · Show 5
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 _Petroz · Jun 05, 2010 at 06:29 AM 5
Share

Not only have you provided a insufficient description of what you are trying to acheive, you have shown no initiative to understand the problem, let alone solve it. We are not here to make your game, please try to refine your concept and ask a more specific question.

avatar image qJake · Jun 05, 2010 at 08:03 AM 1
Share

Your question is too broad to be answered. If you have a specific problem, feel free to ask about it.

avatar image Ricardo · Jun 05, 2010 at 08:22 AM 0
Share

So you would like to clone the #1 game from the AppStore, but don't know how?

avatar image GODLIKE · Jun 05, 2010 at 11:22 AM 1
Share

Ye, I think it's like that. Not only, he also wants somebody else do the job! LOL

avatar image runevision ♦♦ · Jun 07, 2010 at 02:51 PM 5
Share

@Petroz @SpikeX, @GODLI$$anonymous$$E : Please keep the tone in here friendly. This is NOT a place to point fingers at any users. @Ricardo : I understand the question fine and I don't thik it's that broad. Please don't use the "too broad question" card unless absolutely necessary.

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by runevision · Jun 07, 2010 at 03:00 PM

Copying Tetrad's comment since he didn't post it as an answer...

Well you usually have some position in the world that your sling shot is in (originalPosition). You can for example set that position on mouse down.

Then your drag will move your projectile to some other position in the world (draggedPosition). You could set that position on mouse up.

Subtract these two vectors to get a new vector from the projectile to the sling shot:

var shootVector = originalPosition - draggedPosition;

Use the vector's direction to set the force direction, and the magnitude to set the force amount (where further away is higher force magnitude, obviously). Actually you can do that just by setting the force directly to the vector, possibly with a multiplier:

projectile.rigidbody.AddForce(shootVector * multiplier, ForceMode.Impulse);

From there's it's usually a matter of just making sure your physics properties are set up right. More info here:

http://unity3d.com/support/documentation/Manual/Physics.html

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

Answer by Chepe · Jun 05, 2010 at 03:46 PM

I know how to drag the object but what would be the best way to calculate the force and angle based on the position of the drag. Again Im an artist, so Im giving it my best shot. I will post my code here very soon ...

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 Tetrad · Jun 05, 2010 at 06:40 PM 1
Share

Well you usually have some position in the world that your sling shot is in. Then your drag will move your projectile to some other position in the world. Subtract these two vectors to get a new vector from the projectile to the sling shot. Use the vector's direction to set the force direction, and the magnitude to set the force amount (where further away is higher force magnitude, obviously). From there's it's usually a matter of just making sure your physics properties are set up right. $$anonymous$$ore info here: http://unity3d.com/support/documentation/$$anonymous$$anual/Physics.html

avatar image Cyclops · Jun 05, 2010 at 07:15 PM 0
Share

@Tetrad, he's an artist, are you trying to make his head explode? :)

avatar image qJake · Jun 05, 2010 at 09:39 PM 0
Share

Also, don't answer a question with another question/comment. Read the FAQ: http://answers.unity3d.com/faq

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to drag object along with dragging touch? 1 Answer

How to drag the 3D model in screen with finger 1 Answer

Move a cube with mouse relative to the camera rotation 0 Answers

Move object with physic with drag 0 Answers

Have 2D Sprite Follow the Mouse in Straight Line 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