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 husbandofemily · Dec 11, 2014 at 03:09 AM · raycastwaterverticesbobbing

Find height above a mesh without raycasting (for bobbing a boat).

Hi guys. I don't like the indie water plane that comes with Unity, so I though I'd improve it. I've written a script that periodically uses the Perlin noise generator to generate new vertical positions for the vertices in the water plane mesh, then Lerps the vertices over time to make the water move up and down like waves. It works really well (well, I'm happy with it), but now I want to put boats on my newly moving water. I thought to start with I could just use a raycast on the boats going straight down, and use the raycast.hit to create a new position. This doesn't work though, since I've disabled the collider for the water, and anyhow the collider is fixed and doesn't move with the surface of the waves. What I really need is one of two things. Either:

1) find out how far above the surface of the water the boat is, using some other method

or

2) find a way to sample the Vector3 where a point on the boat intersects the mesh of the plane and use that to change the position of the boat.

Or some third thing I can't think of!

Can anybody help me please? Any help greatly appreciated, thankyou.

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

Answer by blueLED · Dec 11, 2014 at 03:19 AM

It seems to me that if you're generating the "new vertical positions for the vertices in the water plane mesh", then you know where the boat should be based on that, no?

That is to say, if you feed your noise generator an X and Z value, it can tell you the Y value? Then apply that to the boat.

Just a guess.

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 husbandofemily · Dec 11, 2014 at 03:30 AM 0
Share

Hi, thanks for the quick reply. I do know where each of the vertices are on the Y axis, but the mesh is quite big (that is, large gaps between the vertices).

Since there's a large gap, one vert might be quite high, and one next to it low. This would give a steep plane, and depending on how close to either vert the boat is, it could be anywhere along that line from low to high.

I want a boat that looks like it's following the water, so following where it intersects the plane (regardless of how close it is to any verts).

Sorry, that was quite hard to explain clearly. Do you see what I'm trying to say?

avatar image blueLED · Dec 11, 2014 at 06:10 AM 0
Share

Perhaps increase the size of the noise generated, so that the space between vertices can be sampled for height too. Then the boat would be closer to where it needs to be. Or maybe take and average of the 3 closest verts, but how you do that, I have no idea :P

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

25 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

Related Questions

vertices in current camera view 1 Answer

Raycasting to the polygon level. 1 Answer

Unity Water (Pro) raycasting for bouyancy 0 Answers

Generate mesh from raycast positions, independent of rotations 0 Answers

distance between raycast hit and vertex 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