0

solved: restarting unity and visual studio solved the problem.

im trying to inherit a class called Enemy from another one called Frog. In order to do that i use:

public class Frog : Enemy

When i do that, i get an error saying that the type or namespace Enemy could not be found.

Even tho it says that the class is not found, im still able to get all the information, for example i override the void Start and get all the information correctly using:

protected override void Start()

My problem is that, even tho i get over 20 error messages on the class Frog, when i try it in-game i dont get any compile errors and everything works exactly as intended.

Do i just leave the errors in the code because the script works as intended or am i missing something which may lead to a mess on the future?

4
  • 1
    Please provide more information like: Are you using Visual Studio? Post some more code (like the errors), and post you editor output log Commented Oct 10, 2019 at 8:25
  • 1
    Close down Visual Studio and Unity and open them up again. It might simply be a glitch of communication between the two. Commented Oct 10, 2019 at 8:26
  • 1
    Can you post the relevant parts of both classes? What is their namespace, how are the Start methods defined? Do you call base in Frog? Commented Oct 10, 2019 at 8:34
  • @aalmigthy yes i use base.Start(); and then on the enemy class i just use protected virtual void Start() Commented Oct 10, 2019 at 11:24

1 Answer 1

4

Try either or both of these:

1) Restart your code editor, if it doesn't help.

2) Delete the .sln, and .csproj files and then from unity click 'Assets' => 'Open C# Project', check if that helps.

Sign up to request clarification or add additional context in comments.

1 Comment

the first one solved it, i restarted Unity and now i dont get any errors. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.