Hello everyone, first post on the forum!
I’m having trouble with my script: I’m trying to know if the collision of one object is with another object with a particular tag. What I’ve got is:
var sur1 : Collider;
var carSur1 = 0.0;
var caricaS = 0.0;
function OnCollisionStay (collisionInfo : Collision) {
for (var sur1coll : Collider in collisionInfo.collider){
if (sur1coll.tag == sur1.tag) {
caricaS += carSur1;
}
}
}
But it doesn’t work and it gives me this error:
Keep in mind that I’ve never programmed before I started using unity!
Thank you in advance for your help!
I dont think you need the curly bracket at the end of the for line. for var convert. And that means one less curly bracket at the end. worth a try.
It still does not work, thanks anyways.
afaik there is only 1 collider in the collision info, so you could take the for(…) line out (and all related brackets obviously) and change sur1coll.tag to collisioninfo.collider.tag