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 /
This question was closed Oct 03, 2011 at 05:07 PM by DavidDebnar for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by DavidDebnar · Jul 07, 2011 at 09:58 AM · waterscalingbox

Scaling water flow parts

Hey! First when you saw this, you probably tought that some dumbass cant scale :). Well I don't wanna totally normally scale. I wanna do something like this.

I have an box.

Normal box.

and I want to scale it into this, and save the 1 and 2 scales.

Scaled box.

If you are wondering why do I need this. I need this to create flowing water. Because I need something pretty fast, and this will do. The algorithm will scale the side 2 saves the number than makes another box next to it with scale 1 that will be big as scale 2 from the one before etc. Is it possible? If so than how? :D

  • David

Comment
Add comment · Show 2
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 SilverTabby · Jul 07, 2011 at 10:25 AM 1
Share

It seems like you want to edit the mesh from inside a script. This is possible, and I have an idea of where to start, but from there, I've got nothing >.<

What you're looking for is probably somewhere near here

http://unity3d.com/support/documentation/ScriptReference/$$anonymous$$eshFilter-mesh.html

$$anonymous$$odifying a mesh through this class will modify only the instance attached to your object - exactly what you want to do - but the actual code that would control it is beyond me :(

Sorry I can't be of more help, but good luck with your project!

avatar image Bampf · Jul 07, 2011 at 11:21 AM 0
Share

That was a pretty good answer though. I$$anonymous$$HO you didn't need to post it just as a comment.

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by DavidDebnar · Jul 07, 2011 at 11:15 AM

Cube deforming webplayer

Ok I made it...I needed to understand how the vertices work, and than it was easy :). If you wanna test it, just create a new .js script and add it to some cube... than with adjusting the V1 and V2 floats you can make the cube change. And for collider I use mesh collider and than I update it each frame. The whole thing runs totally smoothly, when i have the algorithm for water finished ill post a demo on the forum.

var newVertices : Vector3[];

var v1 : float = 0.0; var v2 : float = 0.0;

function FixedUpdate () { var mesh : Mesh = GetComponent(MeshFilter).mesh;

 newVertices = mesh.vertices;
 
 newVertices[6].z = v1;
 newVertices[7].z = v1;
 newVertices[12].z = v1;
 newVertices[14].z = v1;
 newVertices[18].z = v1;
 newVertices[20].z = v1;
 
 newVertices[4].z = v2;
 newVertices[5].z = v2;
 newVertices[10].z = v2;
 newVertices[11].z = v2;
 newVertices[17].z = v2;
 newVertices[23].z = v2;

 mesh.vertices = newVertices;
 mesh.RecalculateNormals();

}

function Update () { var mesh : Mesh = GetComponent(MeshFilter).mesh; transform.GetComponent(MeshCollider).sharedMesh = null; transform.GetComponent(MeshCollider).sharedMesh = mesh;

 mesh.vertices = newVertices;
 mesh.RecalculateNormals();

}

  • David

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 Bampf · Jul 07, 2011 at 11:22 AM 0
Share

Cool. You can link to it here as well, for posterity.

avatar image
0

Answer by Bampf · Jul 07, 2011 at 11:20 AM

1) SilverTabby is right, modifying the mesh will do what you want. To match your illustration, you just need to move one of the vertices. See the documentation that SilverTabby linked to for an example.

More mesh deformation example code can be found here on Unity's website.

To do it without coding it yourself, there's a popular product in the Unity Store that deforms meshes for you. There are also people selling other water assets on the store.

2) Have you looked at the water assets that come with Unity? They get a flowing effect just with texture effects. Unity Pro's version of the water assets add reflection, and have an ocean example that deforms the mesh to make waves.

Hope this helps.

[1]: http://www.west-racing.com/megadoc/

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 DavidDebnar · Jul 07, 2011 at 12:51 PM 0
Share

I know and I tried both Indie and Pro waters... and they aren't flowing, when you try my code, you will probably get what i wan't :).

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to create water physics in Unity? 3 Answers

Water Pro + Terrain Tree Billboard Shaders 1 Answer

Underwater effect question 2 Answers

Water Effects 2 Answers

2D water shader effect 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