- Home /
This question was
closed Apr 28, 2017 at 05:33 PM by
melbok for the following reason:
The question is answered, right answer was accepted
How to change a value of a collider?
Hello, I am trying to change the value of scriptTwo using scriptOne when the objects, the two scripts are attached to, collide. Here are my scripts:
using System.Collections;
using UnityEngine;
public class ScriptOne : MonoBehaviour {
public float newValue = 1.5f;
void OnCollisionEnter(Collision obj){
obj.gameObject.GetComponent<ScriptTwo> ().Value = newValue;
}
}
ScriptTwo:
using System.Collections;
using UnityEngine;
public class ScriptTwo : MonoBehaviour {
public float Value = 1f;
}
But when the two collide, Value of ScriptTwo is still 1. Is there a way of fixing this?
Comment
Have you tried to debug this to see if your collision is being detected? Your code looks okay so my thoughts would be your collision is not being detected for some reason.
It looks like the collision is not being detected
Best Answer
Answer by melbok · Apr 28, 2017 at 05:23 PM
I know what I was doing wrong, I didn't have a box collider. It works now, thanks.
can you tell me cuz im having a problem trying to change my side ways friction on my wheel collider