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 JanJanB · Jan 01, 2017 at 05:36 PM · objectsideland

How to make an object always land on one certain side?

Hi all,

I'm pretty new to Unity, so please excuse if there is an easy solution for my question I just don't know yet.

I am working on a VR project, in which objects spawn from random locations in the air, fall down to the floor, bounce off and finally stop moving and lie on the floor.

Is there a solution, for making these objects all come to lie on a certain side after the movement?

Many thanks and happy New Year!

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 Ambrose998800 · Jan 01, 2017 at 06:29 PM 0
Share

Do you need a natural look? Basically, it's an easy task to make an object to face into a certain direction.

If you want a natural look like a cat dropped upside down with a smooth controlled turning while in air, that could be more challenging. Especially if the objects are droped dynamically and bounce off several times...

I used once a script in .js for my camera to look dynamically into a certain direction. $$anonymous$$aybe you can use that code snippet:

 var TargetRotation = Quaternion.LookRotation(TargetToFace.transform.position - transform.position);
     transform.rotation = Quaternion.Slerp(transform.rotation, TargetRotation, TurnAtSpeed * Time.deltaTime);

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by IgorAherne · Jan 01, 2017 at 06:30 PM

You could use Transform.Rotate() of an object from its OnTriggerEnter()

You should rotate the object over a few frames, such that transform.up is aligned with the Vector3.up (the world's up direction).

The trigger could be a spherical, and could extend 1 extra meter, beyond the object. As soon as it touches anything, your object will begin spinning to the needed orientation

Comment
Add comment · Show 2 · 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 RobAnthem · Jan 01, 2017 at 07:56 PM 0
Share

You could also scale the rotation over the distance it falls relatively easy.

avatar image JanJanB · Jan 02, 2017 at 12:14 AM 0
Share

Thank you all very much for all the help already and your advice on the solution. $$anonymous$$aybe it's helpful, if I post as well a Screenshot of the project to specify more.

Please see below the setting. It's a cloud, out of which toasts spawn randomly. Those toasts shall all bounce off, but when they stop bouncing they shall als get to lie on one specific side.

Is it possible to achieve this with the solutions provided? Or is there maybe another script for this?

$$anonymous$$any thanks again, really appreciate your help!

alt text

unity-problem.png (426.1 kB)
avatar image
0

Answer by salex100m · Jan 02, 2017 at 03:50 AM

HAHAHA I love this toast rain cloud idea!

Here is my solution.

If the toast lands on the wrong side, then just apply a new force to it that bounces it back up a little. Eventually every toast will land on the correct side and be stable. Maybe add a counter to your toast (if landed on wrong side then countTries++) and if countTries > 10 or something, just allow the toast to land on the bad side and then flip it over using transform rotate 180 degrees. It would actually be funny if it happens as opposed to unnatural if it happens too early.

Another way to adjust the probability of landing on one side is to think of a coin flip with a weighted coin that has more weight on one side. Add an invisible object with a heavy (more mass) rigidbody to one side of the toast and that side will fall down more likely than the other side I think.

Comment
Add comment · Show 2 · 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 JanJanB · Jan 02, 2017 at 08:27 AM 0
Share

@salex100m haha, I'm glad you like it. And a massive thanks as well for your thoughts!

I tried the second idea already, as it's easy to realize for a Beginner like me, though I think I need to experiment with this way a bit more, as toasts still land on the wrong side in too many cases.

The first solution though sounds very interesting and would be quite funny! And it sounds like a solution always bringing the right outcome :) Is that code you mentioned hard to realize? Any chance you could help me out on that one as well?

$$anonymous$$any, many thanks!

avatar image salex100m JanJanB · Jan 02, 2017 at 08:09 PM 0
Share

How are you moving the toast from the cloud? Are you just letting them fall due to gravity?

I assume they have rigidbodies and colliders attached right? If not, add that to the toast object. Then look up this code and use it if the toast hits the ground: rigidbody.Addforce()

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Place an object on the side of another object 0 Answers

How to deactivate background music when I land on an object? 1 Answer

How to move a object side to side using mouse? js3 0 Answers

Changing properties of sections of objects and take properties of objects during play? 1 Answer

Animating an object so it doesn't bounce to the initial location the animation was recorded 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