- Home /
Question by
DankDev22 · May 09, 2017 at 05:45 AM ·
scripting problemscripting beginnertriggers
How to get a variable from a triggers script.
I was wondering is there any way to get a variable from a trigger object? I need to be able to hit hundreds of triggers and get variables from them as I hit them. This means individually adding script objects via the public field would be unrealistic. I have something I thought would work below.
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Jump"))
{
int height = other.gameObject.GetComponent(JumpPadScript).Ypower;
}
}
The issue is it doesn't accept JumpPadScript Even though that is the exact name of the script. it says: JumpPadScript is a type, Which is not valid in the given context.
I'm kind of a beginner at unity scripting so any help is greatly appreciated.
Comment