using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Trajectomatic : MonoBehaviour
{
private Vector3[] trajectory;
private int maxMoves;
private int i;
private int t;
private int unlaunched;
private Vector3 currentPosition;
// Start is called before the first frame update
void Awake()
{
unlaunched = 1;
maxMoves = 100;
currentPosition = transform.position;
}
void Start()
{
}
public void Launch(Vector3[] positions)
{
unlaunched = 0;
trajectory = positions;
maxMoves = trajectory.Length;
currentPosition = trajectory*;*
transform.position = currentPosition;
i = 0;
t = 0;
unlaunched = 0;
}
// Update is called once per frame
void Update()
{
Debug.Log(unlaunched);
if (unlaunched == 0)
{
if (t >= 100)
{
if (i < maxMoves - 1)
{
i++;
currentPosition = trajectory*;*
transform.position = currentPosition;
}
t = 0;
}
t++;
}
}
}
I am trying to change a boolean in a method that gets called shortly after the object is instantiated. I have now even tried to use an int to see if that would change. Using the log, I can find out that the Launch method is definitely running, but the main variables aren’t changing. Note that the boolean I was trying to change is now an int. The code to launch the arrow is found here
GameObject.Instantiate(arrow, new Vector3(0, 5, 0), Quaternion.identity);
arrow.GetComponent().Launch(source.GetComponent().CalculateArray(angle, power));