Hey,
I want to access a C# script and change some public values in them on collison with a collider tagged “Water” By my player(Lets say that the script is called ScriptA). I’d do it myself but I’m not good with C# and the script I’m trying to change values in is in C#. I’d love if someone would give me the full thing or at least good guidelines to follow.
Here is a hint of how to do it:
public class Example : MonoBehaviour
{
void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Water"))
{
ScriptA sa = collision.gameObject.GetComponent<ScriptA>();
if (sa != null)
sa.ChangeValuesOnHit();
}
}
}