Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | StrikerSVX |
Hello, Striker here, in the past i attempted to make a racing game on Unity, the project was good but i didn’t like the way things were going there, i need some help to make the transition of a very important code from Unity to Godot this is the code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PathRace : MonoBehaviour
{
public Color limeColor;
private List<Transform> nodes = new List<Transform>();
private void OnDrawGizmos()
{
Gizmos.color = limeColor;
Transform[] pathTransforms = GetComponentsInChildren<Transform>();
nodes = new List<Transform>();
for(int i = 0; i < pathTransforms.Length; i++)
{
if(pathTransforms[i] != transform)
{
nodes.Add(pathTransforms[i]);
}
}
int count = nodes.Count;
for (int i = 0; i < count; i++)
{
Vector3 currentNode = nodes[i].position;
Vector3 previousNode = nodes[(count-1+i) % count].position;
Gizmos.DrawLine(previousNode, currentNode);
Gizmos.DrawWireSphere(currentNode, 2.5f);
}
}
}
What this code do is to draw on the editor a “path” between various “nodes” creating a circuit of nodes where later i can tell my racer ai to drive through this circuit, the code is very simple in Unity but i don’t really know how to achieve the same on Godot, or at least something near that, any type help or direction i could go would be appreciated!