- Home /
unity 2d trigger a script with a trigger?
I wrote this script: I added the script to the player. TAG "Arma" is set at the box collider. When the character enters the box collider2D the script works, active script (Colpo2Null) is off (Colpo1PuntaRossa). Everything works. But the problem is that the player will block without walking both right and left. Any suggestions?
script:
using UnityEngine;
using System.Collections;
public class CambiaArma : MonoBehaviour {
public MonoBehaviour attivo;
public MonoBehaviour disattivo;
void OnTriggerEnter2D (Collider2D other)
{
if(other.gameObject.tag== "Arma")
{
GetComponent<Colpo1PuntaRossa>().enabled = false;
GetComponent<Colpo2Null>().enabled = true;
}
}
}
what exactly do you mean by block? do you mean the player wont move at all when they collide?
Yes. The player does not move does not walk, it remains blocked. Unity will be a Bug?
I honestly have no idea whats going on in this script(im english). Could you try to explain whats going on in your game, hwo the player is moving, what is the player colliding with, how is the player supposed to be colliding with it, etc. And no, i dont think this is a bug in unity