how i can fix this problem? error CS0019: Operator `!=' cannot be applied to operands of type `UnityEngine.ContactPoint[]' and `int'
void OnCollisionEnter (Collision other) {
if (other.transform !=transform && other.contacts!=0)
{for( I =0; I < other.contacts.Length; I++)
{GameObject SS = Instantiate(spark,other.contacts[I].point,Quaternion.identity) as GameObject;
Destroy(SS,0.5)
}
}
other.contacts != 0 is where your issue is. You cant compare an array to an integer. I would need more context around what its doing to tell how to resolve.
Answer by WillNode · Mar 14, 2017 at 09:49 PM
This is the corrected code
if ( other.transform !=transform && other.contacts.Length != 0)
{ for(int I =0; I < other.contacts.Length; I++)
{ GameObject SS = Instantiate(spark,other.contacts[I].point,Quaternion.identity) as GameObject;
Destroy(SS,0.5f);
}
}
Answer by XALO1 · Mar 14, 2017 at 07:38 PM
I'm trying to convert js to c# This code was correct in js
function OnCollisionEnter (other : Collision ) {
if (other.transform !=transform && other.contacts!=0) {for( I =0; I < other.contacts.Length; I++) { var SS : GameObject = Instantiate(spark,other.contacts[I].point,Quaternion.identity) as GameObject; Destroy(SS,0.5); } } It is a racing game And this Code is to establish a particle spark when dealing with something
Your answer
Follow this Question
Related Questions
Stop Unity from opening blender. 0 Answers
WHAT THE HECK? Rotations not working. 0 Answers
My cube gets stuck at 0 degrees rotation 1 Answer
trying to start making a fighting game... Where to start? 2 Answers