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 EvilCrown · Sep 06, 2013 at 06:44 AM · rotationphysicsdirectiontreefall

Tree Fall Direction

Hey all. I am working on a game where you can select a number of trees a la RTS style, click a button, and select a spot where those trees fall but wondering how to make a tree object fall in a vector3 positions direction. Any thoughts?

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 ShadoX · Sep 06, 2013 at 07:04 AM 0
Share

Assu$$anonymous$$g that those trees are "static" at first, you'd probably would want to use them as rigidBodies when you want them to fall and add a bit of force into the direction you want them to fall in.

avatar image EvilCrown · Sep 06, 2013 at 07:06 AM 0
Share

the problem is adding them in the direction of the click. it's a bit over my head.

avatar image ShadoX · Sep 06, 2013 at 09:51 AM 0
Share

I'm assu$$anonymous$$g that you want the trees to fall in the direction you clicked on the ground (and not on that exact point) so I would suggest to have a look at http://answers.unity3d.com/questions/346804/is-there-a-way-to-get-mouse-position-in-3d-space-a.html to get the 3D coordinates of where you clicked with the cursor (which returns a Vector3) and use that value with http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForce.html to add force in that direction. I'm not too familiar with RigidBodies, so I'm assu$$anonymous$$g that this should be enough to get the trees falling (assu$$anonymous$$g that they won't start bouncing around the second you activate the rigidbody).

Or perhaps http://docs.unity3d.com/Documentation/ScriptReference/Rigidbody.AddForceAtPosition.html ... try having a look at both and see if any of those work for you.

avatar image EvilCrown · Sep 06, 2013 at 11:00 PM 0
Share

Thanks for the info. I will look into it.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by OP_toss · Sep 06, 2013 at 11:19 PM

You mean like this?

 Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition );
 
 tree.transform.rotation = Quaternion.LookRotation( ray.direction, Vector3.up );

This will make the tree's forward Z-axis point along your ray from the camera. I have no idea which direction you want, so if you wanna provide more info or fiddle with the above code, you should be able to figure it out :)

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 EvilCrown · Sep 07, 2013 at 06:59 AM 0
Share

Only problem is... will this actually rotate the tree itself? I want it to fall in the direction of the click, not rotate. Think as if the tree decided to fall over in the direction of the click without any rotation at all.

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

17 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

Related Questions

switching direction of gravity 1 Answer

Camera/Direction Rotation 2 Answers

How to apply parent based rotation? 1 Answer

Bouncing Ball Problem( bounces vertically forever) 1 Answer

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 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