48 lines
1.2 KiB
C#
48 lines
1.2 KiB
C#
using Godot;
|
|
|
|
|
|
public partial class CharacterMeshSwapper : Node3D
|
|
{
|
|
|
|
[Export] public ArrayMesh[] _availableHeads;
|
|
[Export] public ArrayMesh[] _availableBodies;
|
|
[Export] protected MeshInstance3D _currentHead;
|
|
[Export] protected MeshInstance3D _currentBody;
|
|
|
|
private int headIndex = 0;
|
|
private int bodyIndex = 0;
|
|
|
|
public void NextHead(int? overrideIdx = null){
|
|
if (overrideIdx != null)
|
|
{
|
|
headIndex = Mathf.Clamp(overrideIdx.Value, 0, _availableHeads.Length);
|
|
}
|
|
else
|
|
{
|
|
headIndex++;
|
|
if (headIndex >= _availableHeads.Length)
|
|
{
|
|
headIndex = 0;
|
|
}
|
|
}
|
|
|
|
_currentHead.Mesh = _availableHeads[headIndex];
|
|
}
|
|
|
|
public void NextBody(int? overrideIdx = null){
|
|
if (overrideIdx != null)
|
|
{
|
|
bodyIndex = Mathf.Clamp(overrideIdx.Value, 0, _availableBodies.Length);
|
|
}
|
|
else
|
|
{
|
|
bodyIndex++;
|
|
if (bodyIndex >= _availableBodies.Length)
|
|
{
|
|
bodyIndex = 0;
|
|
}
|
|
}
|
|
GD.Print("Switching bodies to: " + bodyIndex);
|
|
_currentBody.Mesh = _availableBodies[bodyIndex];
|
|
}
|
|
} |