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 starta · May 04, 2011 at 05:21 PM · shaderopaquetranslucent

Character from transparent to opaque

When the boy close to those ball, the boy will become translucent.

So these ball will not block by boy's body.

Player (we) will see boy eat those ball.

My idea is:

Create a big cube to cover with those ball.

And let big cube don't show on scene.

As long as people within big cube, the boy will become translucent.

But the boy is out of big cube, the boy will restore to original appearance (opaque).

What can I do this code?

Thanks everybody :)

alt text

Comment
Add comment · Show 1
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 Jesse Anders · May 05, 2011 at 12:26 AM 0
Share

When posting to both the forums and UA, please provide a cross-link: http://forum.unity3d.com/threads/88061-Character-from-transparent-to-opaque

2 Replies

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

Answer by nowhereman · May 04, 2011 at 08:31 PM

I'm guessing (hoping) English is not your main language? =P

So what you're asking for is the boy to become transparent so he does not block the ball when he is within a certain area?

If that's the case, there's multiple parts to your code you will need to accomplish, I'll give you the basics to get you started, but if you don't know enough to do anything past that, just reply back and I'll see if I can walk you through the rest...

For one, you're going to want to access the alpha component of the boy's material, if you change that value it will make him simi-transparent. Material script referance: http://unity3d.com/support/documentation/ScriptReference/Material.html Color.alpha script referance: http://unity3d.com/support/documentation/ScriptReference/Color-a.html

So your code will have a line that looks something like:

renderer.material.color.a = (whatever value you choose here);

And of course you'll want some way to trigger that line, and from what I can make out, you want to do that with a triggerbox. So you'll take a cube (turn off its renderer so that it is see-through) and check the "Is trigger" part of this box. Then you're going to use a OnTriggerEnter function http://unity3d.com/support/documentation/ScriptReference/Collider.OnTriggerEnter.html

except you'll want it to check for when specifically the player enters. You can do this by adding a line to check the tag of whatever enters the triggerbox, then make sure you give the boy a "Player" tag

if (other.gameObject.tag == "Player") {  //do stuff here}
Comment
Add comment · 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
0
Best Answer

Answer by starta · May 05, 2011 at 06:48 PM

Thank you very much!!! I succeed!!!!

But I have a warning:

ArgumentException: Find can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. collision_cube..ctor () (at Assets/Standard Assets/Scripts/collision_cube.js:1)

How can I solve this problem?


Im Taiwanese and my English isnt good haha.

First, I choose "shadow material" to big cube's materials.

Let it becomes transparent.

In this way, cube doesnt show.

Tag name is called glass.

Second, put this script into boy:

(Boy's model is compose by 5 polygon)

var shader1 : Shader = Shader.Find( "Diffuse" ); var shader2 : Shader = Shader.Find( "FX/Glass/Stained BumpDistort" ); var face : GameObject; var face2 : GameObject; var face3 : GameObject; var face4 : GameObject; var face5 : GameObject;

function OnTriggerStay(other : Collider){ if (other.gameObject.tag == "glass" ) { face.renderer.material.shader = shader2; face2.renderer.material.shader = shader2; face3.renderer.material.shader = shader2; face4.renderer.material.shader = shader2; face5.renderer.material.shader = shader2; } }

function OnTriggerExit(other : Collider){ if (other.gameObject.tag == "glass" ) { face.renderer.material.shader = shader1; face2.renderer.material.shader = shader1; face3.renderer.material.shader = shader1; face4.renderer.material.shader = shader1; face5.renderer.material.shader = shader1; } }

Thank you very much again :)

Comment
Add comment · 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

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

No one has followed this question yet.

Related Questions

GameObject not receiving shadows 0 Answers

Cannot change material on build 1 Answer

Dirt / Dust Shader, Light Interaction 0 Answers

Help to do translucency + subsurface scattering 1 Answer

Standard Shader showing bleeding of color into alpha in opaque mode 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