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 tacticz_03 · Aug 05, 2014 at 02:41 PM · anglearduino

How to get angle of terrain?

Hi! I'm developing a game for my final year project and it is a bike simulator game that uses a real bicycle as an input through Arduino and has a moving platform based on the angle of bike in the game. I want to get the angle of the terrain where the bicycle is oriented. I have searched but can't find the right solution. I think, to get the angle is to use raycast functon or Vector3.angle.

Please help me. Thanks

alt text

tatanoooong.jpg (347.5 kB)
Comment
Add comment · Show 5
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 meat5000 ♦ · Aug 05, 2014 at 02:11 PM 0
Share

http://answers.unity3d.com/questions/220536/get-slope-and-colortexture-at-point-on-terrain.html

avatar image tacticz_03 · Aug 05, 2014 at 03:01 PM 0
Share

I will try this. Thanks

avatar image meat5000 ♦ · Aug 05, 2014 at 03:22 PM 0
Share

No problem. There probably are easier ways :)

avatar image tacticz_03 · Aug 05, 2014 at 05:43 PM 0
Share

can i get the angle without using the raycast?

avatar image meat5000 ♦ · Aug 05, 2014 at 05:46 PM 0
Share

Check my link - the second one

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by FTdevelopment · Aug 05, 2014 at 07:31 PM

ALTERNATIVE WAY : 1-Create a little box. 2-Assign Rigidbody to the box. 3-Put the box where you want to know angle of terrain. 4-Get box's angle values.

(Also you can get bicycle's current angles)

Maybe this can help to you.

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 meat5000 ♦ · Aug 05, 2014 at 07:33 PM 0
Share

(Also you can get bicycle's current angles)

Thats what I was hinting at with my SOH CAH TOA link :P - The X and Z angles are there in the transform, of course this doesnt help deter$$anonymous$$e the slope if you are not On the slope.

avatar image tacticz_03 · Aug 07, 2014 at 01:38 PM 0
Share

Hi! Here's my code. It gets the angle and also orients the bike to the terrain using raycast. I'm not sure about the output of angle if its accurate. Can you look at the code?

 RaycastHit hitA;
 if(Physics.Raycast(transform.position + transform.forward, -transform.up, out hitA))
 {
   RaycastHit hitB;
   if (Physics.Raycast(transform.position - transform.forward, -transform.up, out hitB))
   {
     transform.forward = (hitA.point - hitB.point) * Time.deltaTime;
 
    }
 }
 angle = (($$anonymous$$athf.Atan2(transform.position.y, transform.position.x) * $$anonymous$$athf.Rad2Deg));

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

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Long lag in serial communication with Arduino 4 Answers

How to find how much an object has rotated? 2 Answers

How do I get a normalized vector2D from an angle? 1 Answer

Trouble Understanding Vector3.Angle() Result 2 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