Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  get sign when cloth is tore
#11
(07-03-2019, 02:49 PM)josemendez Wrote: There should not be a file named "ObiTearableCloth (1)".

It should be "ObiTearableCloth". Again, look trough your project for copies of this file and remove them, since the name "ObiTearableCloth (1)" indicates you have created a copy of the file, instead of replacing the original one.

There should be only one file named ObiTearableCloth.cs, located at Obi/Scripts/Actors/ObiTearableCloth.cs

I removed (1), but can't add script.


Attached Files Thumbnail(s)
   
Reply
#12
(07-03-2019, 03:08 PM)Richard Wrote: I removed (1), but can't add script.

Have you made sure that:

- There are no compile errors.
- The name of the script and the class are exactly the same.

Also, removing the (1) from the file name (if that's what you did) is not enough. There should only be one file with that name in the entire project. This is all standard Unity know-how.
Reply
#13
(07-03-2019, 04:04 PM)josemendez Wrote: Have you made sure that:

- There are no compile errors.
- The name of the script and the class are exactly the same.

Also, removing the (1) from the file name (if that's what you did) is not enough. There should only be one file with that name in the entire project. This is all standard Unity know-how.
There was a compile error.

New error happened. 
NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnEnable () (at Assets/ClothTornEvent.cs:16)

NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnDisable () (at Assets/ClothTornEvent.cs:22)
Reply
#14
(11-03-2019, 03:16 AM)Richard Wrote: There was a compile error.

New error happened. 
NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnEnable () (at Assets/ClothTornEvent.cs:16)

NullReferenceException: Object reference not set to an instance of an object
ClothTornEvent.OnDisable () (at Assets/ClothTornEvent.cs:22)

There's no ClothTornEvent class in Obi. That's a file you created, how am I supposed to know what's wrong with it? Assuming you copied the one I provided verbatim, this error refers to empty lines in the original script, so you must have modified it.

Make sure the cloth variable is not null (my script uses the RequireComponent attribute to make sure there's a cloth component in the object, so "cloth" can never be null).
Reply
#15
(11-03-2019, 08:41 AM)josemendez Wrote: There's no ClothTornEvent class in Obi. That's a file you created, how am I supposed to know what's wrong with it? Assuming you copied the one I provided verbatim, this error refers to empty lines in the original script, so you must have modified it.

Make sure the cloth variable is not null (my script uses the RequireComponent attribute to make sure there's a cloth component in the object, so "cloth" can never be null).

Yes, I changed a bit, but error is same(line is different).  Even the original code you did cause error, so I tried to find out what I have to do.

"cloth component" means obi cloth or obi tearable cloth?

(11-03-2019, 08:41 AM)josemendez Wrote: There's no ClothTornEvent class in Obi. That's a file you created, how am I supposed to know what's wrong with it? Assuming you copied the one I provided verbatim, this error refers to empty lines in the original script, so you must have modified it.

Make sure the cloth variable is not null (my script uses the RequireComponent attribute to make sure there's a cloth component in the object, so "cloth" can never be null).

I set the ClothTornEvent and Obi Tearable Cloth as the image


Attached Files Thumbnail(s)
   
Reply
#16
(11-03-2019, 10:20 AM)Richard Wrote: "cloth component" means obi cloth or obi tearable cloth?

Hi,

It means ObiTearableCloth, as regular ObiCloth cannot be torn.

About the null ref issue:

- It is happening in two lines where the only thing that can be null is the "cloth" variable, of type ObiTearableCloth.
- If the RequireComponent attribute is being used (which it is in the original code), then cloth cannot be null, since Unity guarantees a ObiTearableCloth component is present.

So either you're removing the component programmatically in some other script (only way to trigger a null ref exception in this situation), or things aren't set up as you described.
Reply
#17
(11-03-2019, 07:45 PM)josemendez Wrote: Hi,

It means ObiTearableCloth, as regular ObiCloth cannot be torn.

About the null ref issue:

- It is happening in two lines where the only thing that can be null is the "cloth" variable, of type ObiTearableCloth.
- If the RequireComponent attribute is being used (which it is in the original code), then cloth cannot be null, since Unity guarantees a ObiTearableCloth component is present.

So either you're removing the component programmatically in some other script (only way to trigger a null ref exception in this situation), or things aren't set up as you described.

I would like to deny about removing or setting. Can I send you the project(my setting)?
Reply
#18
(12-03-2019, 11:21 AM)Richard Wrote: I would like to deny about removing or setting. Can I send you the project(my setting)?

Yes, send it to support@virtualmethodstudio.com.
Reply