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 Kartik Vinayak · Jul 30, 2010 at 05:40 PM · rigidbodymousedraglaunch

"Launch" a rigidbody

Hello all,

I have been using unity for 6 days (And loving it so far)

So I want to know how to launch a rigidbody using the mouse. For example: There is a rigidbody just sitting there, I want to click on that rigidbody and drag. When i drag, the rigidbody does not follow, instead, a line connects my rigidbody to my mouse. When i release the mouse button, the rigidbody launches towards the mouse at a set speed.

So how would I do this?

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 flaviusxvii · May 08, 2011 at 02:51 AM 0
Share

TRANSLATION: I want to make an Angry Birds clone. I'm asking how to duplicate the slingshot launch dynamic.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by 3dDude · Jul 30, 2010 at 05:44 PM

if you have the standard assets imported then you can use the rigidbody dragger script. it wont do what you want but it will be close to what you want

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 Kartik Vinayak · Jul 30, 2010 at 06:06 PM 0
Share

I know about that script and that is not what i want. I just want it to move towards my mouse at a set speed after release.

avatar image
1

Answer by Deikkan · Jul 31, 2010 at 03:55 PM

What you could do is when you click on the rigidbody, record the transform.position of the GameObject. When you release the mouse button, record the mouse position using Camera.ScreenToWorldPoint and passing Input.mousePosition to it. You can then calculate the angle between the two points using Vector3.Angle and pass that angle to rigidbody.AddForce.

Hope this helps.

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 Kartik Vinayak · Jul 31, 2010 at 07:08 PM 0
Share

Thanks, that helps somewhat

avatar image
0

Answer by Persona · Jul 31, 2010 at 02:22 PM

You need to use a rigidbody.velocity code:

http://unity3d.com/support/documentation/ScriptReference/Rigidbody-velocity.html

That may solve your problem for speed. As for getting it to move toward the mouse, if you're in first person mode then set up a script with your Camera as a Target and have it move towards it.

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

No one has followed this question yet.

Related Questions

How to properly convert mouse pos to world pos 1 Answer

newbie: drag a rigidbody with mouse 2 Answers

Drag Rigidbody 2 Answers

Checking if mouse dragged from one point to another 2 Answers

Drag Object Via Axis Handles 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