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 GameDBharat · Aug 23, 2017 at 06:32 AM · rigidbody2dgroundcoordinate-system

I want to calculate the coordinate points of both object and make fall body in pit.

alt text

coordinatepoint.png (6.1 kB)
Comment
Add comment
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

1 Reply

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

Answer by fafase · Aug 23, 2017 at 07:48 AM

You can go into math and vectors or you can use raycast.

If the black plane of your ground has a collider, then you can cast from the two top corners of your object downwards. If the raycast uses the rotation of the object it can be more accurate.

Then the hit point is the result. Convert that to local of the object and you're done.

 void Update(){
       Vector3 left = GetPosition(topleft.position);
       Vector3 right= GetPosition(topRight.position);
 } 
 private Vector3 GetPosition(Vector3 position){
       RaycastHit hit;
       Vector3 result = Vector.zero;
       if(Physics.Raycast(position, mainObject.transform.down, objectSideLength)){
             Vector3 pos = hit.position;
             result= mainObject.transform.InverseTransformPoint(pos);
      }
      return result;
 }

This is more pseudo code than pure solution. But hopefully it will be a lead.

The falling part, I am not sure, I guess you want to check the result of the two vectors and do something about it.

 if(left.y < value && right.y < value){  Fall(); }

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 GameDBharat · Aug 24, 2017 at 08:05 AM 0
Share

Thanks for your reply but it show total error.

avatar image fafase · Aug 24, 2017 at 08:09 AM 0
Share

it does because I said it is pseudo code. I guess it tells that mainObject and ObjectSideLength are not found. Those you need to create and assign. mainObject is the game object reference of the floating object. objectSideLength is the length of the vertical side of that object. topLeft and topRight are Transform (Empty object) place at the top corners of your main object.

I just provide the logic, you still need to work out the full implementation.

avatar image GameDBharat fafase · Aug 25, 2017 at 04:16 AM 0
Share

Once Again very much thank you #fafase

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

67 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 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 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 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

Car Wheels sink through the ground 1 Answer

Lights only work when I look at the ground. 0 Answers

Convert Vector2 to Vector3 based on the ground's height? 1 Answer

Object gets stretched out when parented to terrain 1 Answer

Pink stripes coming from the ground...Really need help! 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