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 /
  • Help Room /
avatar image
0
Question by alarm656 · Aug 19, 2015 at 06:51 AM · addforcetriggers

Fall down Cube object from platform.

Hello Unity Developers, I have a problem with 'rotation falls' of "Cube" object. The Cube object (as you can see on the picture) has a scale size (1.2.1). I want the cube falls down when it's half part on the air. I mean if cube's half part on the platform and other part on the air . There are empty objects with tag "Fall" and with collider (Trigger is checked). When my cube is EnterTriggers it must fall down from the platform. It's works only in sometimes but not always. I put Y Gravity -175 in Edit=>Project Settings=>Physics. alt text

There is a code which must make my Cube falls down (outweigh).

`using UnityEngine; using System.Collections;

public class ObjectFallAway : MonoBehaviour {

 public Rigidbody rb;
 public AudioClip fail;
 

 void Start ()
 {
     rb = GetComponent<Rigidbody>();
     //rb.constraints = RigidbodyConstraints.FreezePosition;

 }
 
 void OnTriggerEnter (Collider other)
 {
     if (other.gameObject.tag == "Fall") 
     {
         gameObject.GetComponent<Roll>().enabled = false;
         rb.constraints = RigidbodyConstraints.None;
         StartCoroutine (Load());
     }
 }

 IEnumerator Load ()
 {
     yield return new WaitForSeconds (0.5f);
     //GameObject.Find("Map").GetComponent<AudioSource>().PlayOneShot (fail);

     yield return new WaitForSeconds (3.0f);
     Application.LoadLevel ("Island");
 }

}

Is there a best way to solve my problem please? If I use Rigidbody.AddFore, can it help me? if yes please comment and give me please sample how to do it. Because I'm new in coding(( I only make simple codes. Thanks in advance.

jpeg.jpg (222.1 kB)
Comment
Add comment · 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 Mike-Geig ♦♦ · Sep 08, 2015 at 08:31 AM 0
Share

Howdy, so I'm not sure I totally understand your problem. Are you saying that you'd like the cube on top to naturally fall off of the platform when moves over the edge? If so, that should happen normally. Perhaps you can explain in more detail what you really are trying to do?

Also, your gravity value is HUG$$anonymous$$ I would recommend setting it back to its default.

avatar image alarm656 · Sep 08, 2015 at 11:03 AM 0
Share

Thank you $$anonymous$$ike:) There is a link video which shows the (1.2.1) sized Cube falling down from the platform: https://www.dropbox.com/s/7lhv23bh2jq8n3j/Falling.mov?dl=0

I would like to have exactly such as falling in my game.

There is someone has commented on my FB post, but I know nothing and can't understand about Raycasting :( His answer: "you could do a little raycast going a little in down direction on each side of the cube, when your ray don't hit anything (this side of the cube is in the air) add a strong force downward (in global space) at this position of the cube. This way if your cube is ~50% mid air (taking in $$anonymous$$d that the center of balance is the center of the cube), the cube should fall easily. Else you could try to create a physics material with little drag."

avatar image Scribe · Sep 08, 2015 at 11:22 AM 0
Share

If will only happen if the centre has gone past the edge of the cube below, and in some cases it won't have, as I assume the cubes are exactly half the size of the block.

You could try raycasting from each 'part' of the block, where the block would be 2 parts, each a cube. if you hit something, leave it alone, if one end doesn't hit anything, use AddForceAtPosition to push it down where it didn't hit the raycast.

Alternatively you could reduce your cubes to be the tiniest bit smaller than half your block, and it should work.

If neither of those work, how are you controlling the position and rotation, perhaps you are stopping it from moving naturally?

avatar image alarm656 · Sep 08, 2015 at 01:30 PM 0
Share

Raycasting sample will be great. I can't figure out what to write in code raycasting

avatar image Mike-Geig ♦♦ · Sep 08, 2015 at 01:50 PM 0
Share

Try this example to learn about raycasting: http://unity3d.com/learn/tutorials/modules/beginner/physics/raycasting?playlist=17120

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Scribe · Sep 09, 2015 at 08:36 AM

If you are successfully triggering the 'Fall' collider, then you can make a simple change, instead of:

 AddForce

try

 AddForceAtPosition(-Vector3.up * hoverForce, other.transform.position+new Vector3(0, 0.5f, 0), ForceMode.Acceleration):
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Not able to add forces to a Rigid Body Game Object from a script attached to another Game object which is a Trigger. 0 Answers

My complete script dont work (if a collision appear, push) 0 Answers

Time.deltaTime doesn't help on different devices! 0 Answers

Why when I press "RightArrow"the object do not go right?(only go forward),Why when I press "RightArrow" when the program start, the RES BOX does not move to right? 1 Answer

Could someone help me with scripting a Trigger that when the player enters and then presses the E Key a new level is loaded. My script is JS at the moment. 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