• 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 Dark_Tiger · Oct 27, 2014 at 06:00 AM · c#planeget-value

Get Y value of plane at position X,Z

I'm trying to do a jump, and I just need to basically detect when the player is back on the ground, and I've already got it all sorted out, I just need to know if it's possible to get the Y value of a X,Z position on a plane. To back up my terrible explanation, here's a diagram, which is equally terrible.

alt text

A pseudo way of putting what I'm after would be Y = the Y value of the plane at position X,Z

untitled.png (5.3 kB)
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 mouurusai · Oct 27, 2014 at 06:09 AM 0
Share

I'm not great mathematician but i'm sure this is not a plane)

avatar image Dark_Tiger · Oct 27, 2014 at 06:12 AM 0
Share

You're correct xD sorry about that, change the curved line to a straight lol, I was thinking about how to apply it to a proper terrain, so when I was drawing the diagram I put a curved line in there, but this method would be for proper terrains, because, well if I was just using planes then there'd be no problem cause the y value never changes.

avatar image robertbu · Oct 27, 2014 at 06:55 AM 0
Share

I don't know if you have something special or are just new to Unity. The typical solutions is to put a collider on the object and Raycast() down. For a Unity Terrain, you can use Terrain.SampleHeight().

avatar image Dark_Tiger · Oct 27, 2014 at 07:03 AM 0
Share

Gee thanks Sir High and $$anonymous$$ighty, even if I wasn't new to unity that's rather uncalled for. But thanks for telling me about racycasting anyway

Here's some links for future people if they ever need to know about it http://docs.unity3d.com/ScriptReference/RaycastHit-point.html http://answers.unity3d.com/questions/607226/get-height-of-a-mesh-by-x-and-z-coordinates.html

1 Reply

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

Answer by _Yash_ · Oct 27, 2014 at 06:53 AM

You can Raycast in downward direction from that point. And use RaycastHit.point to get y value.

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 Dark_Tiger · Oct 27, 2014 at 06:58 AM 0
Share

Aye, I'm looking into that at the moment, got about 5 tabs about raycasting open xP

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

29 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

C# Plane Collision Detection 1 Answer

Can I use "Plane Constructor" in NavMesh? 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