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 artsdcs · Jun 04, 2012 at 07:56 PM · errormonobehaviourtypefire

unity script error

hey everybody i've got this script from someone but it wont work and i can't get it to work.

 public class Flamable : MonoBehaviour {

 public float FireHealth = 50;
 public float MaxFireHealth = 50;
 public float HealthRegen = 5;
 public bool IsOnFire = true;

 void OnParticleCollision(GameObject other) {     
    if(IsOnFire) {
      FireHealth -= 1.0f;
      if (FireHealth <= 0) {
       IsOnFire = false;
       transform.GetComponent<ParticleEmitter>().emit = false;
       // other things to do when fire goes out
      }
    }
 }

 void Update() {
    if (IsOnFire) {
      FireHealth += Time.deltaTime * HealthRegen;  
      if (FireHealth > MaxFireHealth) {
       FireHealth = MaxFireHealth;
      }
    }
 }

}

it keeps giving me this error

Assets/Flamable.cs(1,25): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing a using directive or an assembly reference?

can anybody please give me the solution of this error?


this is what the person who was so nice to give me this said:

The easiest way would be to use the legacy particle system, so you can add collision detection to the particles.

Set up your particle emitters that will represent the fire hose object emitting water particles and all of the flammable objects emitting fire particles. The legacy system requires you to add a particle emitter, a particle animator, and a particle renderer to the objects (See the menu Components->Effects->Legacy Particles). It doesn't use a separate GameObject particle system.

Add the World Particle Collider component to the fire hose object and check the "Send Collision Message" box in the inspector. This will let you use the collision in a script.

Next you will need to add a script to the flammable objects you created. I know C# better than javascript so this is in C#. Add the OnParticleCOllision function to the script. In side here you can create a counter that tracks all of the particles that have hit and if it reaches a certain number than you can turn the fire emitter off. In the Update function you can decrease the counter. Think of it like the fires health bar.

i did everything except i kept my original particle effect that was attached to my hoze instead of making a new one.

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 Drakestar · Jun 04, 2012 at 07:58 PM 0
Share

There's a dot after $$anonymous$$onoBehaviour. Is that in the code? If so, remove it.

avatar image artsdcs · Jun 04, 2012 at 08:01 PM 0
Share

whoops, no i accidantally placed that while fiddling around with it

1 Reply

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

Answer by rutter · Jun 04, 2012 at 08:59 PM

Do you have this line at the top of the file?

 using UnityEngine;
Comment
Add comment · Show 3 · 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 artsdcs · Jun 04, 2012 at 09:06 PM 1
Share

no and now i added it it works like a charm thanks!

avatar image Wolfram · Jun 04, 2012 at 09:28 PM 1
Share

Then please also mark this answer as "accepted" (checkmark).

avatar image meat5000 ♦ · Mar 12, 2016 at 10:52 AM 0
Share

Sometimes this doesnt work. In those rare cases it appears a reinstall is required.

http://answers.unity3d.com/questions/1117460/could-not-find-monobehaviour.html

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

some scripting help 2 Answers

`ActivateTrigger.target' is a `field' but a `type' was expected 1 Answer

Error trying to createMonoBehaviour using the 'new' keyword in cSharp script 4 Answers

How to create/fix fire damage script???? 1 Answer

My jump script isn't working? 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