Zagan
Zagan
CC#
Created by Zagan on 2/7/2023 in #help
❔ Copying code from youtube and it doesn't work for me
I'm new to the C# scripts and i am trying to make a board game, while trying to understand how to do the movement. The code i copied from youtube doesn't work. Maybe i typed it wrong? It should show green line between the nodes but it doesnt. The code is here :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Route : MonoBehaviour
{
Transform[] childObjects;
public List<Transform> childNodeList = new List<Transform>();

void OnDrawGizmos()
{
Gizmos.color = Color.green;

FillNodes();

for (int i = 0; i < childNodeList.Count; i++)
{
Vector3 currentPos = childNodeList[i].position;
if (i >= 0)
{
Vector3 prevPos = childNodeList[i - 1].position;
Gizmos.DrawLine(prevPos, currentPos);
}
}

}

void FillNodes()
{
childNodeList.Clear();

childObjects = GetComponentsInChildren<Transform>();

foreach (Transform child in childObjects)
{
if (child != this.transform)
{
childNodeList.Add(child);
}
}
}


}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Route : MonoBehaviour
{
Transform[] childObjects;
public List<Transform> childNodeList = new List<Transform>();

void OnDrawGizmos()
{
Gizmos.color = Color.green;

FillNodes();

for (int i = 0; i < childNodeList.Count; i++)
{
Vector3 currentPos = childNodeList[i].position;
if (i >= 0)
{
Vector3 prevPos = childNodeList[i - 1].position;
Gizmos.DrawLine(prevPos, currentPos);
}
}

}

void FillNodes()
{
childNodeList.Clear();

childObjects = GetComponentsInChildren<Transform>();

foreach (Transform child in childObjects)
{
if (child != this.transform)
{
childNodeList.Add(child);
}
}
}


}
https://www.youtube.com/watch?v=d1oSQdydJsM heres the youtube video, In the intro section
11 replies
CC#
Created by Zagan on 1/23/2023 in #help
❔ Code stops after a bit
I'm trying to make 3d game in unity and i made dice check zone when i roll the dice it shows what i get, but after a bit it will stop showing what i roll
27 replies