Topic: [Solved] Need help with a moveinfo script
I'm In need of some help with a moveinfo script.
The goal of this script is to check if a move that's being used is one of the moves on the script, then do a thing.
The issue I'm having is the script only seems to work with the Element 0 properly.
When a move in any of the other Element's is used it executes the if and the else if
public void CheckIfMoveIsEnhanced()
{
foreach (MoveInfo move in enhancedMoves)
{
if (cScript.currentMove.moveName == move.moveName)
{
script.enabled = true;
Debug.Log("CheckIfMoveIsEnhanced");
break;
}
else if (cScript.currentMove.moveName != move.moveName)
{
script.enabled = false;
Debug.Log("CheckIfMoveIsNonEnhanced");
}
}
}
Any help or a better way to do this would be greatly appreciated
I used some of @MrPonton's AlternatePalettes code from this thread: http://www.ufe3d.com/forum/viewtopic.php?id=2469
Full code of script I'm using:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UFE3D;
public class EnhancedMoves : MonoBehaviour
{
public List<MoveInfo> enhancedMoves;
public MonoBehaviour script;
private ControlsScript cScript;
// Start is called before the first frame update
void Start()
{
cScript = gameObject.GetComponentInParent<ControlsScript>();
}
// Update is called once per frame
void Update()
{
if (UFE.p1ControlsScript != null && UFE.p2ControlsScript != null && cScript.currentMove != null)
{
CheckIfMoveIsEnhanced();
Debug.Log("if");
}
else
{
CheckIfNotPreformingMove();
Debug.Log("else");
}
}
public void CheckIfMoveIsEnhanced()
{
foreach (MoveInfo move in enhancedMoves)
{
if (cScript.currentMove.moveName == move.moveName)
{
script.enabled = true;
Debug.Log("CheckIfMoveIsEnhanced");
break;
}
else if (cScript.currentMove.moveName != move.moveName)
{
script.enabled = false;
Debug.Log("CheckIfMoveIsNonEnhanced");
}
}
}
public void CheckIfNotPreformingMove()
{
script.enabled = false;
Debug.Log("CheckIfNotPreformingMove");
}
}