Space Rob thinking: update 14
- ronchisa
- Jun 11, 2024
- 4 min read
Time to get back to it, only had a...two months short break (update: actually, five months?? But, who is counting!)
Shows how rusty I am, as I kept clicking on the canvas before even being able to modify the scene, which lead to trying to move the canvas, which wouldn't, and having to change its render object property to world object to do such before re-setting it...moving on!

Firstly, let's make it a nice, plain plane of sorts...but, hark! Isn't dialogue an absolutely massive part of the game? How to do dialogue...time to learn, to the youtubemobile!
Found a really well explained one by Sasquatch B Studios: "Make a dialogue system", which also made my mind hurt in wonderment, but nevertheless not crack into insanity by knowing the steps were there to retrace...
First, though, I need to resolve a tiny yet irritating issues I've been skirting over since the dawn of time:

So, I've been opening all scripts outside of Unity, for I couldn't do such via, well, Unity. Which worked fine, but I don't get all the neat "auto fill" stuff I see in videos, so let's sort this out already!
Google tells me it's to do with the Unity Hub rights not being set correctly, so...hu, well that was easy: go to Edit, Preferences, external tools, then set Visual Studio, since that's the one I use.
As for the how to talk video, I'm not going to go through all the ins and outs of it since you can just check it out yourself, but I will highlight the quirks that I encountered:
-No UnityEngine.InputSystem downloaded: go to Window, Package Manager, then install what you desire. Which, didn't work...looks like it's another trip to the Preferences and External Tools, then needed look at to "Generate .csproj files for", whereas I ticked everything, then pick "Regenerate project files", and that did the trick.
-They use a bottom dash (this one, _ , which I'm sure has a suitably bizarre name) in variable naming convention, which I took to be a full stop. Do not put a full stop in front of your variables, Unity did not like that.
-Understandably, there is currently no Wraith object or NPC, and besides, I want to use this firstly so that Rob can talk by himself. So, I created an invisible "SelfTalkCheckpoint" GameObject (although, I've also given it the arrow sprite for now in case that's functionality we wish to mantain), and called the relevant script "SelfTalk", so that Rob triggers it when close by, which seems sufficient for now.
-5f trigger distance is much vaster than it seems in the video, reduced to 3f.
-Wait, that still doesn't cut it: it just ain't triggering same as the video. In there, player gets close, the arrow shows, moves away the arrow goes.
Here, get close, the arrow comes on, move away, it stays...get close again, it goes, move away, it's still a goner.
So, it's triggering once per player vicinity within the set parameter, perhaps? The code is exactly as in the video...to test it, I've placed a debug.log in the boolean method that gets called outside of the update method, thinking that perhaps it was busy at a party -but nein, it's ready with a strong cup of coffee and constantly being pulled...so, the fault must be in the IF statement's logic, or the boolean -or both! Which one, which one...
Ok, let's try this: get a debug.log of the distance between sprite and player, which is used for the boolean logic...well, that showed something interesting:

At the start of his brave quest, Space Rob is a mighty 13 units away from the sprite.

After having moved past it, he's still somehow within 2 units.
While I could humorously blame this on some space sci-fi shenanigans, it should not be: he's almost the same distance from the clearly visible arrow as he was when he started! Is the sprite moving with the player?
One thing I've noticed is that the GameObject "SelfTalkCheckpoint" and it's child "InteractObject" (which is the arrow sprite) are not at the same x/y co-ordinates, even though on screen it says they are. I tried rectifying this before, which made everything go skee-whif, and besides the Player and CheckGround are playing the same trick and they work, so it can't be that?
FOUND IT! And as often be the case, it's so simple in hindsight:

I added that it check the transform.position of InteractSprite, rather than the Game Object the script is placed in.
Which for sure still is odd, as being attached to the Game Object should be enough to warrant the correct transform.position...then, it's likely a fault with the SelfTalkChekpoint: in the video, the Wraith NPC has a collider and whatnot...but, since that causes my Player to, well, collide with the invisible checkpoint and be unwilling to move further, we shall just stick with this likely inefficient workaround.
And PAUSE. Because, if I've learned anything from painfully sludging through trying to emulate what is in the video, is that I need a way, way better grounding in all this coding malarkey. Sure, I can bumble along and keep grinding some progress, but when I get stuck, the foundations just ain't strong enough to smoothly see me through.
Time for that dirty word: learning! And what better place than the Unity Learn Junior Programmer course? Seems legit, let's give it a try!
Your regretfully back to school learner,
Stefano Ronchi
Comments