Unity Shenanigans - Part 1
What I've done in the past weeks and months
These last months I've decided to learn more about Unity by trying to make some scenes with some level of procedurality.
Dialogues
First I started trying to make a dialogue box and interactions with the enviroment. I first tried managing every interaction on a separate thread, but I quickly discovered one can not interact with the Unity API from different threads. I ended up discovering about IEnumerators and yield return, allowing me to code very specific events, with just C#, that can be stopped mid-execution to wait for user input (Like closing a dialogue box!).
public class InteractionText1 : Interactable {
override public string GetUIName() {return "Talk";}
//Performs an action
protected override IEnumerator Action() {
PlayerController.EnablePlayerInteraction(false);
List<DialogueElement> ds = new List<DialogueElement>();
ds.Add(new DialogueElement(LOC.Get("1c_NPC1_Dial1_1"), "Nice NPC"));
ds.Add(new DialogueElement(LOC.Get("1c_NPC1_Dial1_2"), "Nice NPC"));
DialogueManager.StartDialogue(ds);
//Wait for the dialogue to end and advance
yield return WaitForCheck(DialogueManager.active, false);
ds.Clear();
ds.Add(new DialogueElement(LOC.Get("1c_NPC1_Dial1_3"), "Nice NPC"));
DialogueManager.StartDialogue(ds);
//Wait for the dialogue to end and advance
yield return WaitForCheck(DialogueManager.active, false);
PlayerController.EnablePlayerInteraction(true);
}
}
An example of an Interaction, starting some dialogues and waiting
with yield return for the dialogue to indicate it has ended (active == false).
Shadergraph learning
Then I delved straight into Unity's Shadergraph functionality, which allows users to create shaders with graph-style programming. Starting with a sweet tutorial by Brackeys, I made a simple first water shader, and as I wanted a pixelated style, I forced the UV map to have a "resolution" of sorts, giving the final product a nice style.
A low-poly planet
A pixelart dynamic sky
I'm extremly proud of this one, even though it has used a lot of my time (But look how cute it looks!)
More Random Stuff
A test scene to try out the positioning of planets in the sky. The big
sphere is the Sun.
Trying out rendering whole planets. In this case,
I used Kerbal Space Program's planets to test it.
(The tidal locking worked!)
(The tidal locking worked!)
The surface of the test scene (Triplanar mapping everywhere).
The ground's detail can be found here, made by hhh316
What now
I'm still learning step by step how to use Unity, but I think I'm already doing very cool stuff. I might use this in future projects if it turns out very well.
I will post more about my Unity Shenanigans in the future.
I will post more about my Unity Shenanigans in the future.
ahhhhh dunno c#
ReplyDelete