Hello community this is my first thread, i try to fix all by myself searching similar problems in the forum, but i can’t find this, so here is the problem.
I am working on a selection “Menu” for the moods/skills of the character.
This look like this. (The script is “Selector Animo” (Mood Selector))
It seem to work good, but here is the bug.
The ray works fine sometimes and randomly fails, i can’t identify why this happen.
So here is the code (Just the “Selection” part).
void Seleccion(){
if (Input.GetMouseButton(0)) {
RaycastHit2D hit = Physics2D.Raycast(RayStart.position, RayEnd.position, 10f, LayerMask.GetMask("Selector"));
//Dibuja linea en scene.
Debug.DrawLine(RayStart.position, RayEnd.position, Color.red);
//Diferentes casos, activa el booleano de la direccion a la cual el raycast esta tocando.
if (hit.collider != null && hit.collider.tag == "Neutro") {
Neutro = true;
}
else {
Neutro = false;
}
if (hit.collider != null && hit.collider.tag == "Triste"){
Triste = true;
}
else {
Triste = false;
}
if (hit.collider != null && hit.collider.tag == "Sensible"){
Sensible = true;
}
else {
Sensible = false;
}
if (hit.collider != null && hit.collider.tag == "Asustado"){
Asustado = true;
}
else {
Asustado = false;
}
if (hit.collider != null && hit.collider.tag == "Agresivo"){
Agresivo = true;
}
else {
Agresivo = false;
}
}
else {
followmouse.OnSelection = false;
//Desactiva selector
Selector.SetActive(false);
}
}
I hope you can understand my problem, my english get this harder i know, sorry for that.
Thanks for your time!