first script: namespace could not b e found

Hi
I try to integrate some script in another, both in the same project and get:
Error CS0246: The type or namespace name ‘Ocean’ could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp-firstpass)

Ocean.cs is in the project. What do I need to change for my first scripting attempt?
Thanks

It sounds like a naming issue, but if you want specific help, you need to post the script (inside Code Tags).

using UnityEngine;
using System.Collections;

public class AddBuoyancy : MonoBehaviour
{
    Ocean m_ocean;

I’m only pasting from the other script. I want to merge those two.
Thanks

Could you show the Ocean script?

Why? I don’t modify that, only merge the two others. Anyway it starts alike:

using UnityEngine;
using System.Collections;

public class Ocean : MonoBehaviour
{

Because the error message says that there is no Ocean. In which folder do you have Ocean.cs and where is AddBuoyancy.cs?

I want to merge buoyancy and mouselook ie integrate bouyancy into mouselook.

That’s not what I asked. Are you still getting the error from the first post?

Yes but it might be cause I’m on Linux? I’ll try on Windows now.

Most likely it is not related to Linux. But I am still trying to help you to resolve that initial issue. That’s why it would be extremely useful if you could answer my questions.
Unity has several compilation steps for the scripts, depending on the folders in which the scripts are placed.

That’s why it is important to know in which folder the scripts are.

Well I didn’t change anything. I only disabled buoyanc script and pasted most into mouse look. Both are parented by player. Unfortunately I’ve erased this and loaded a new script that I did last week. Now this seems ok so maybe you need
a new script while changing deps? I might try again but not sure if I can redo the very same.
Now for debugging the new script how to set the current debugger position visible. It debugs but I cannot see at what
line the debugger currently is. (cs monodevelop on Windows)
Thanks

I am trying to help you. If you are not answering my questions, I can’t help. Last chance:
Please post the whole error message from the first post.

1 Like

f: \ UnityprojWin \ Surfs_High2a \ Assets \ Standard Assets \ Character Controllers \ Sources \ Scripts \ MouseLook.cs (2,2): error CS0246: The type or namespace name “Ocean” could not be found. (Missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp-first pass)

The error happens in the MouseLook script. Please show that script.

1 Like

using UnityEngine;
using System.Collections;

/// MouseLook rotates the transform based on the mouse delta.
/// Minimum and Maximum values can be used to constrain the possible rotation

/// To make an FPS style character:
/// - Create a capsule.
/// - Add the MouseLook script to the capsule.
/// → Set the mouse look to use LookX. (You want to only turn character but not tilt it)
/// - Add FPSInputController script to the capsule
/// → A CharacterMotor and a CharacterController component will be automatically added.

/// - Create a camera. Make the camera a child of the capsule. Reset it’s transform.
/// - Add a MouseLook script to the camera.
/// → Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.)
public class AddBuoyancy : MonoBehaviour
{
Ocean m_ocean;

still the same as above. I only pasted from the other script as said multiple times.

This is the MouseLook script? First the class and file name have to match. If the class name is MouseLook, the script name has to be MouseLook.cs, if it is a C# script.

Besides that, you still didn’t answer in which folder those scripts are. I don’t care about how it is setup in the game object right now. What matters is the place where the script is stored, like Assets/Scripts/Ocean.cs.

And please use code tags.

A script cannot have multiple classes? So that’s it. Thanks

Any ideas why I cannot see the debugger yellow line?

What do you want to do?

debug my script. I set a breakpoint, attach to unity and press play in editor. I see it stops but I cannot see the yellow debug line.-

You should either create a new thread or check the existing ones if it is a different topic. Just in the case you are using Linux, make sure to mention it.