- Home /
A trigger is activating scripts of other triggers
So I am trying to make a line of platforms that rise up as the player enters their triggers, supposedly each platform has it's own trigger.
for the first five everything works fine but the sixth and sventh rise up when the player steps into the first one( each trigger can only be linked to one platform )
I also tried putting a different script on them but to no avail
here's the script I am using
using UnityEngine;
using System.Collections;
public class Trigger_Test : MonoBehaviour {
public GameObject stair1;
bool risertrig=false;
public float height=76f;
public float speed=1000f;
// Use this for initialization
void Start () {
}
void OnTriggerEnter(Collider trigger){
if (risertrig == false) {
risertrig = true;
}
}
// Update is called once per frame
void Update () {
// Debug.Log(stair1.transform.position.y);
if (risertrig == true) {
print ("true");
}
if (risertrig == true) {
print ("false");
}
if(risertrig == true){
stair1.rigidbody.velocity=transform.TransformDirection (Vector3.up * speed *Time.deltaTime);
}
if (risertrig == true) {
if (stair1.transform.position.y >= height) {
risertrig = false;
stair1.rigidbody.velocity=transform.TransformDirection (Vector3.zero );
}
}
}
}
[1]: http://s927.photobucket.com/user/FRESHERMAW/media/2014-05-02_0024.png.html?filters[user]=109301372&filters[recent]=1&sort=1&o=0hill\C+Valley\2014-05-02_0024.png
Are you sure the box colliders are properly placed on the sprites? (Check by selecting them in the scene view and see if the green outline fits the sprite)
Answer by KOKOStern · May 03, 2014 at 03:15 PM
You should make sure every trigger is on the same layer and then uncheck collision between the layer and itself using the physics layer matrix (found in Edit --> Project Settings --> Physics/Physics2D).