Alright this is a simple problem but rly hard for me to solve. Is gonna be long and with few codes so take a sit.
Lets go. Im trying reload a previus setup of an object when something is happening, the issue comes when i check this thing happens.
First code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SegmentoBlock2 : MonoBehaviour {
public Text text;
public bool bloqueo;
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Ataque")) {
bloqueo = true;
text.text = ("Perfect Block");
}
}
}
Here I check if 2 objects are in colision no problems with that. If they are in collision bla bla bla.
Second Code:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class SameSegmentBlock : MonoBehaviour {
//Segmentos
public Seg1 seg1;
public Seg2 seg2;
public Seg3 seg3;
public Seg4 seg4;
public Seg5 seg5;
public Seg6 seg6;
public SegmentoBlock2 segBlock;
public int bloqueoP;
public bool bloqueo;
public Text text;
void OnTriggerEnter(Collider other)
{
if (segBlock.bloqueo == false) {
StartCoroutine (ABC ());
}
}
IEnumerator ABC()
{
//returning 0 will make it wait 1 frame
yield return new WaitForSeconds (0.01f);
CheckBlock();
if (bloqueo == true) {
text.text = ("Block");
} else {
text.text = ("Fail");
}
}
void CheckBlock()
{
if ((seg1.bloqueo) == true)
bloqueo = true;
if ((seg2.bloqueo) == true)
bloqueo = true;
if ((seg3.bloqueo) == true)
bloqueo = true;
if ((seg4.bloqueo) == true)
bloqueo = true;
if ((seg5.bloqueo) == true)
bloqueo = true;
if ((seg6.bloqueo) == true)
bloqueo = true;
}
}
On this code i take the value of “bloqueo” from the other script. If is true pass away, but if is not check the colission between the first object and other 6 objects around . If they match in any of the segments (what is done in next script) then the value of “bloqueo” changes to “true”, If not stay false
using UnityEngine;
using System.Collections;
public class Seg1 : MonoBehaviour {
public bool at;
public bool bl;
public bool bloqueo;
public MeshCollider atMesh;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag ("Ataque")) {
at = true;
atMesh.enabled = false;
} else {
bl = true;
}
CheckSegments ();
}
void CheckSegments ()
{
if ((at && bl) == true)
bloqueo = true;
}
}
This is the script to check the colisions i say before. I apply this scripts on the 6 external objects.
I take the Collider of the first object and check the colision with the others.
Well, this is working perfectly. My problem comes when im trying to do something when one of the things happen “Perfect Block” “block” and “fail”. I know is something stupid but for one or another reason im truly stocked in this. I cant continue with my proyect without solve this problem.
I know it can be a bit messy but i splitted the code in many scripts. If theres any question i will be proud answering it.
Thanks in advance!.