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 /
avatar image
0
Question by aman779 · Oct 03, 2011 at 11:46 PM · windowscompilereffectsunderwater64bit

Underwater effects error?

I run my game, with a character controller and everything, and it says to fix all the errors in the compiler. I look in the compiler and I see this:

'Assets/Scripts/UnderwaterEffects.js(23,46): BCE0022: Cannot convert 'UnityEngine.GameObject' to 'float'.

What is this and how can I fix it? and there is no water in my scene...

Windows 7 64-bit

Comment
Add comment · Show 3
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 aldonaletto · Oct 03, 2011 at 11:50 PM 0
Share

Post the script here - it's an error in line 23 of the UnderwaterEffects.js, but we need to see it to help you. All scripts in the Assets folder and subfolders must compile ok - even those you're not using.

avatar image aman779 · Oct 04, 2011 at 12:26 AM 0
Share

var waterLevel : float; var uAudio : AudioClip; var aAudio : AudioClip;

var uColor = Color(1,1,1,1); var uDensity = .05;

var aColor = Color(1,1,1,1); var aDensity = .008;

var waterSurface : Renderer; var underwaterSurface : Renderer;

private var below = false; private var glow : GlowEffect; private var blur : BlurEffect;

function Awake() { if(!waterLevel) { water = FindObjectOfType(Water); if(water) waterLevel = water.gameObject; } aColor = RenderSettings.fogColor; aDensity = RenderSettings.fogDensity;

 glow = GetComponent(GlowEffect);
 blur = GetComponent(BlurEffect);
 if( !glow || !blur )
 {
     Debug.LogError("no right Glow/Blur assigned to camera!");
     enabled = false;
 }
 if( !waterSurface || !underwaterSurface )
 {
     Debug.LogError("assign water & underwater surfaces");
     enabled = false;
 }
 if( underwaterSurface != null )
     underwaterSurface.enabled = false; // initially underwater is disabled

}

function Update () { if (waterLevel < transform.position.y && below) { audio.clip = aAudio; audio.Play(); RenderSettings.fogDensity = aDensity; RenderSettings.fogColor = aColor;

     below = false;
     
     glow.enabled = !below; 
     blur.enabled = below; 
     waterSurface.enabled = true;
     underwaterSurface.enabled = false;
 }
 
 if (waterLevel > transform.position.y && !below)
 {
     audio.clip = uAudio;
     audio.Play();
     RenderSettings.fogDensity = uDensity;
     RenderSettings.fogColor = uColor;
     
     below = true;
     
     glow.enabled = !below; 
     blur.enabled = below;
     waterSurface.enabled = false;
     underwaterSurface.enabled = false;
 }

}

Thats my Underwatereffects.js. I barely understand this...

Line 23:

if(water) waterLevel = water.gameObject;

avatar image aman779 · Oct 05, 2011 at 01:18 AM 0
Share

What's a water gameobject? I'm sorry, im new to this.

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by subhendus · Feb 15, 2012 at 11:07 AM

waterLevel is float and gameObject is an object.

This has been discussed in Unity Forum and seems it happened for project conversion.

So the following will fix it. if(water) waterLevel = water.gameObject.transform.position.y;

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
-1

Answer by Minion54847 · Dec 23, 2011 at 12:51 PM

just switch the lower case g on gameObject to a capital so its GameObject

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

Answer by aldonaletto · Oct 04, 2011 at 02:34 AM

The beginning of Awake() is wrong. I don't know how it was before, but with some changes it may work - or at least stop producing compiler errors (any script with errors prevents the whole project from work, even if you don't ever use it).
I believe the modifications below are enough: add a water GameObject variable and modify the first if in the Awake function:

... private var blur : BlurEffect; var water: Water; // declare this variable

function Awake() { // and modify the first "if" of Awake to this: if (!water) { // if water not set at the Inspector... water = FindObjectOfType(Water); // try to find Water object // if found, set waterLevel to the water position if (water) waterLevel = water.gameObject.transform.position; } ...

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

Answer by LouisB · Jun 03, 2012 at 08:06 PM

switching the case on the G cleared the error for me. Not sure how to test if the script is still working. The next error was something about not supporting UnityEditor, so I just commented those two lines out in the file UpdateTreeColors

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

Answer by ramp · Nov 17, 2014 at 01:23 PM

Hi,

You can use the following code instead of code line 23.// if(water) waterLevel = water.gameObject;

if (water) waterLevel = water.transform.position.y;

Thanks Ram

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Overlapping Unity Players w/ Transparency 1 Answer

Underwater effects for rivers 0 Answers

Problem quitting app on Win7 64bit 1 Answer

VCRuntime errors with Universal Windows Platform, but it runs within Unity 0 Answers

Problems with 64-bit systems 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