« first day (3828 days earlier)      last day (1486 days later) » 
00:00 - 21:0021:00 - 00:00

00:08
@noobprogrammer It's already defined by my SaveLoad script, and whatever it is in this script is supposed to be affecting the one in the SaveLoad script. So I use SaveData.KeyCard1. But, it says that I need an object reference. Well, my SaveLoad script is not a MonoBehaviour so it isn't in an object.
So then how do I fix that?
00:33
Hint: anything defined by a class is an object. That includes public class SaveData
Something constructs an object that is an instance of this class, so that it can call the SaveData() function on that object. Whatever script that is that has the SaveData object can populate the data on it.
Uh... Populate? (I know what Populate means, but not in this context) So then... what would the object be called?
Oh! Oh! I jsut figured out how to use "KeyCard1"!!! I used:
using UnityEngine;
using System.Collections;

public class KeyCard : MonoBehaviour {
    public GameObject target;
    public SaveData myScript;

    void OnCollisonEnter ()
    {
     if (myScript.KeyCard1 == false)
     {
         myScript.KeyCard1 = true;
     }
    }
}
And it worked! And to my surprise, it also registers every other variable that's also in my SaveLoad script that I want to save!!!
00:59
"Populate" in a programming context means "put a value into this variable"
Oh.
Oh wait.
My save script saves my game when I call "SaveLoad.Save()"; and it Loads from a file (loads) into "data" when I call "SaveLoad.Load()". And then I need to use "data" to access my values. Well, does that mean that I need to call "data" somehow to actually load my game?
Because I looked through the script, and it doesn't look like it has any errors. It also has no compiler errors in Unity. But when I test it, it does nothing.
So... What should I do to actually load my game?
01:19
Usually you will have a script that loads the values from a file into variables in memory, then either acts on that information itself, or stores them in an easily-accessible place for other scripts to look up the values and put themselves in the right state when they spawn.
its been a while since ive been on this. I think it said 201 days...
Welcome back. 😊
And in my save/load script, if my "public void Save()" and "public void Load()" are instead "public static void Save()" and "public static void Load()"; will they not work?
They can, but then the variables you store in that class will also need to be static.
01:45
@DMGregory thanks!
Okay. Also I just got into getting the save/load to work, and the saving works. But when I try to load, it will tell me "Attempting to deserialize an empty stream." as an error. When I persist and try again, it will tell me "Sharing Violation on path" in which the path I won't say. If I continue to persist, it just repeats the first error.
What is going on and how am I supposed to fix that?
Sharing violation usually means you have the file open in another program.
Oh and if it helps, the first error is a "SerializationException" while the second is an "IOException". Also, I don't have any of those files open in another program. Strange.
Could be the last time you ran your app, you didn't close and release the file properly, so the OS still thinks it's in use.
Attempting to deserialize and empty stream means the app found no data in the file stream you gave it.
Wuh? That makes no sense! (Not you, the error). It saves and I've checked the save files. They all have the funky gibberish characters all over the thing, which I believe is what it's supposed to be like.
I thought the sharing violation might hapen if I had that loading script or something in 2 different scripts, so I eliminated the other one.
*happen
01:56
That could happen too, if your program tries to open the file twice without closing it in between.
Oh wait!
No no
I figured out that I forgot to put a space in one of the file name destination locations in the file location for the two, but the issue persists. So, I went ahead and checked it play-by-play. So what's happening is that when I save, it writes correctly into the file. I checked. But when I load it, it says "Attempting to deserialize an empty stream" error, and when I go to check the file, it's suddenly blank. It's like when I try to load, it sets the file to blank just before it loads.
Sounds like you might inadvertently be creating a blank file, then loading that.
Maybe so! Turns out that my script for loading was using File.Create like my saving part, when it should probably be doing something else. But it doesn't end there though. I switched File.Create with File.Open, but instead I get a compiler error saying "No overload for method 'Open' takes 1 arguments."
So... Should I not be using File.Open? And if not, then what other argument do I need?
02:11
Can we see the save/load script
@Wasabi That would be helpful.
public class SaveLoad {

public static string currentFilePath = "SaveData.cjc";

public static void Save ()
{
Save (currentFilePath);
}
public static void Save (string filePath)
{
SaveData data = new SaveData ();

Stream stream = File.Create(Application.dataPath + "/../../../Documents/Security Cameras/" + "MySavedGame.game");
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Binder = new VersionDeserializationBinder();
Debug.Log ("Writing Data");
bformatter.Serialize(stream, data);
There's the portion of it that's not working the way I need it to.
@noobprogrammer I hope that helps you help me :)
Here's a tutorial I used for my saving system. It looks similar to yours: red-gate.com/simple-talk/dotnet/c-programming/…
You'll likely want to use Application.persistentDataPath, not dataPath.
@DMGregory I agree. I was wondering what was going on there.
for both of them or just the load?
I mean the persistent
02:22
Think through that for a moment. If you saved to a different path than you loaded from, would that work?
I got a compiler error saying that 'Application' does not contain a definition for 'persistentDataPath'
It exists - check your spelling, and be sure that it's detecting UnityEngine.Application correctly.
Oh. I must have spelled it wrong somewhere, because I copy/pasted it and it worked. But now it's trying to take from C:/#####/###########/AppData/Documents instead of C:/#####/###########/Documents
*Takes from the AppData when I try to load
That's what's supposed to happen. AppData is a good place to save this kind of file on Windows, which is why Unity provides you a standard path there.
It automatically changes to corresponding save paths on other platforms.
Well... I for some reason don't have "appdata"
02:33
You're on a version of Windows from sometime this decade?
there's only one this decade, windows 10. ;)
(My point is that every recent version of Windows going back pre-2010 has used %AppData%)
yeah :)
Where should I be saving in appdata
persistentdatapath will go to the right place to save
your app name will probably be there
just save a text file and see what it looks like
02:46
Okay. But now the loading does nothing. What I'm doing is I am saving before I get the KeyCard, then getting it, and then loading and seeing if KeyCard1 is set back to false, which it doesn't.
But It is running the code because it says "Reading Data..."
I notice that your code creates a new SaveData instance called data,
loads some data into this instance,
...then throws it away? Did you plan to store it somewhere?
Similarly, your save routine creates a new default save, does nothing to put your game's actual in-memory state into that object, and saves that default version.
Oh.
How do you expect the data to get to, or get read from, other parts of your game?
Eh... Could you ah, help me with that? All this save/load stuff is really a whole lot more confusing than other simple stuff...
I don't even know what you need help with. I think your problem is more fundamental than saving/loading, down to just understanding how the language you're using works.
02:52
well, maybe that. But what I meant by help was the things you said weren't going right.
I mean, if you need the entire script, I can paste it here.
This isn't a small thing like "Oh, just turn on Telepathy Mode so the compiler can read your mind and figure out where the data you wanted to save is" - you're going to have to plan out how you want to put data into this object, and how you're going to take it back out after loading it.
yeah
Yeah I know I need something to put stuff in and take stuff out. But I'm not a pro like you, so I don't know what I need to put.
Meaning what I need to put to make the stuff go in, and then out
I don't know either, because it depends on your game, and I don't know your game.
Well if it helps, here's the script:
click "fixed font" when entering code. that will maintain its formatting
03:01
Okay
 using UnityEngine;

 using System.Text;
 using System.IO;
 using System.Runtime.Serialization.Formatters.Binary;

 using System;
 using System.Runtime.Serialization;
 using System.Reflection;

 [Serializable ()]
 public class SaveData : ISerializable {

   public bool KeyCard1 = true;
   public bool KeyCard2 = false;
   public bool KeyCard3 = false;
   public bool KeyCard4 = false;
   public bool KeyCard5 = false;
   public bool KeyCard6 = false;
   public bool KeyCard7 = false;
   public bool KeyCard8 = false;
:)
What you've shown us is the log book with spaces to write all the info your game cares about. Next you need to figure who in your game has the job of writing into that log book, and when.
What do you mean? I have a save/load button... (I probably sound like a dummy here)
I have a script that sets KeyCard1 to true when I touch the attached object
Show me that script.
03:05
alright
using UnityEngine;
using System.Collections;

public class KeyCard : MonoBehaviour {
    public GameObject target;
    public SaveData myScript;

    void OnCollisonEnter ()
    {
     if (myScript.KeyCard1 == false)
     {
         myScript.KeyCard1 = true;
     }
     if (myScript.KeyCard1 == true)
     {
         myScript.KeyCard1 = true;
     }
    }
    void OnCollisionExit ()
    {
     if (myScript.KeyCard1 == false)
     {
         myScript.KeyCard1 = false;
     }
     if (myScript.KeyCard1 == true)
Ah, sorry for the horrible timing, but I need to eat and then watch Star Wars because Yoda is less confusing than C#.
So If you want to see my save/load button script, here it is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System;
using System.Runtime.Serialization;
using System.Reflection;
using UnityEngine.UI;
public class SavBScript : MonoBehaviour
{
    public Button m_Button1, m_Button2;
    void Start()
    {
     m_Button1.onClick.AddListener(TaskOnClick);
     m_Button2.onClick.AddListener(delegate {TaskWithParameters("Saving..."); });
And I know I used waaaaaaay too many things (like System.IO) for that one
Bye! Thanks so much for the help! I progressed in defeating my compiler errors far faster with your help, and by that, I mean like 3 days faster! See you tomorrow guys :)
03:25
So, you've saved the information you want on this instance of the SaveData class called myScript - do you read that instance anywhere?
 
1 hour later…
04:38
To clarify, each and every instance of SaveData is its own separate log book. It won't do you any good if Joe writes in his log book and Sarah writes in hers, but when it's time to save you order a blank log book from the store and save that. You need to all be reading and writing in the same book.
So you'll want to put one instance of the log book somewhere where everyone can interact with it.
Or, just before saving, task someone to run around to everyone who might have data to save and jot down their info into one private log book, then save that.
 
9 hours later…
14:06
Can I get achievements for successfully flagging bad posts?
user92578
Yup, see Citizen Patrol, Deputy and Marshal: gamedev.stackexchange.com/help/badges
Hahaha, I was wondering if you might be badge-hunting, from handling recent flags. 😉
Thank you for helping tidy up our archives.
You're welcome, I'm just gonna keep on trying to help!
I hope I'm helping, or are my flags not leading to bad posts?
We might not act on every single one - in some cases it's OK to let sleeping dogs lie. But it's still good to flag them to do the check.
So far the flags I've handled have been helpful, so thank you for that.
You're welcome :)
user92578
14:21
The rarity of Marshal is somewhat interesting, I assume most people progress past the close vote limit so fast that their flag counts remain somewhat small
14:33
Could be. I'm still down in the 300s myself, despite being at it for 7 years.
15:27
I think a lot of our badge target numbers were tuned for different traffic expectations than what materialized on this site. 😉
user92578
16:01
Like our votes to close count limit ;)
This is cool. A colleague showed me this constraint solver for procedural generation in games, CatSAT.
Open source, permissive license, C#, plugs into Unity with a DLL.
It lets you define a set of rules for the generated object's attributes, and sample a random solution that meets those rules.
I just flagged like 5 bad questions lol
All I had to look up was "how to start", "where to find good", "what is good idea". It leads to a lot of bad questions.
@DMGregory I might have to use that for my enemy AI (if that's how it's supposed to work).
16:29
you know what' stough... unsung hero
I got it on SO
@DMGregory Very cool. One of the devs (Ian Horswill) name is familiar from academia, but I can't recall where the research intersection was from. Might have been proc gen mario?
As I recall, you only flag most bad things up to a point, after which the preferred solution is to vote to close instead of flagging.
@noobprogrammer it's probably not useful for most AI decision-making. It's more like ensuring you have some logical consistency in your random generator, so you don't produce a building with no doors.
Some of Ian's pubs have great titles:
[What’s the Worst Thing You’ve Ever Done at a Conference?
Operationalizing Dread’s Questionnaire Mechanic](http://ceur-ws.org/Vol-2282/EXAG_118.pdf)
@DMGregory Oh, ok, I figure I could probably make one myself anyway. It'd be a good learning experience.
sigh some days chat markdown code, some days
Oh nice!
I suppose some of it depends on funding. DoD probably wouldn't have appreciated that sort of thing. (read: opted not to renew funding for cheeky researchers)
@Almo I just tried your game, it tricked my mind!
Cognizer?
Yep that one.
It has an elegance that I've yet to emulate. Been a while since I've played though :(
16:58
@DMGregory Well, I don't think so. But I do save that there, that is correct. this myScript is the SaveLoad script. But I don't think I read it from anywhere.
A simple fix for your case is to just make all those variables static. That way you have one copy of the variable globally for your whole game. Anyone can write to it and anyone can read it.
@DMGregory as you said, "To clarify"... Well, you definitely clarified it for me :)
That makes the data flow problem easy. It also makes it easy to get bugs.
Okay. So I make the "public bool KeyCard1" into "public static bool KeyCard1"?
For that reason, public global mutable state - like a public static variable - is generally something we try to avoid. But for a small starter game, the consequences probably won't be too dire.
17:02
Okay...
But my game isn't going to be too small
so I'll start by switching the public KeyCard1 bool into a static bool?
Your first one will be. The next one you make after this might be a bit bigger. Don't expect your first pass will produce your dream game. Work up to it in steps.
Okay. That sounds like something a super-smart person would say, as you obviously are. Okay. But once I changed them to static, my KeyCard script is showing an error
KeyCard.cs(10,10): error CS0176: Member 'SaveData.KeyCard1' cannot be accessed with an instance reference; qualify it with a type name instead
So you followed the instruction, deleted the instance reference myScript... and replaced it with the name of the type SaveData. correct?
Well, now I have.
This is some fundamental C# syntax, so I'd recommend working your way through some more beginner tutorials to make sure you really have a foundational understanding of the language first. Then you can branch out and start implementing original game features with it, without getting snared on what to type.
17:11
okay.
but ah, not to leave my crumbly script hanging, could you point me in the direction of what I would do to read the data? As you said, my button reads the load data, and my KeyCard script writes into the data to be saved.... but I have nothing to get the read loading data to my KeyCard GameObject.
And, I've looked through Unity documents at ScriptingAPI, and I've been having trouble finding the keycode for 1 2 3 4 5 6 7 8 9 0
Alpha1 and so-on does nothing.
And where should I go to learn this foundational knowledge of c#?
17:51
Searching "beginner c# tutorial" is a good start, or "beginner unity tutorial" if you want to learn specifically in the context of Unity.
The Unity documentation for KeyCode lists the codes for numpad 0-9 and the 0-9 above the letter keys. Any trouble following that?
Re: reading, you have a couple of options.
You could do your file loading early on in the game, like on the menu screen before the game stats. Then the loaded values are in memory (say in the static variable you're using atm). When your KeyCard script is spawned (eg in the Start() function) it can look at the value of this static variable and configure itself accordingly.
Okay. Oh and... how long do you think this'll take?
I've been doing it for 14 years.
Wow.
So... It won't take 14 years for me to learn how to do this, riiiiiight...
I'm learning new things daily, 14 years in.
so...
uh.
17:56
It's not a "read these three books and you're done" kind of thing. Game development is a constant journey of learning and re-learning.
5
I mean, how long until I can seriously fix my saving/loading thing? My personality works like this: I don't like to leave things broken for very long...
Okay. So this isn't "read those books and you'll get it"
Depends on how quickly you pick it up.
You'll fix one thing then you'll find a new thing to fix.
7
Okay.
At some point you'll have so many things to fix that you'll need to decide what you fix first.
17:58
@Wasabi Don't worry. I've just started a couple of months ago, and I'm learning every day and getting better at something.
> You'll fix one thing then you'll find a new thing to fix.

Very much this. Well put.
@Vaillancourt I know, that's how I am now :)
Even when a project should be called "done", you'll know there are so many things left to fix. But you'll have to be in peace with yourself, and start a new project.
Confusing as is, it seems as though it'll be far easier at fixing stuff once I've learned the basics. I'll be back when I've learned the basics! (Or when my project breaks down with 999+ compiler errors)
This is why I recommend starting small. If you try to bite off too much at once, you'll end up in a very demoralizing position where nothing is working and it's a giant slog of work to get to the next milestone, and that makes it hard to make progress.
18:00
Then at some point, you'll get bored, you'll figure out something new to do, which will just be a pretext to fix more things.
“Nothing is ever finished and done with in this world. You may think a seed was finished and done with when it falls like a dead thing into the earth; but when it puts forth leaves and flowers next spring you see your mistake.” ― Elizabeth Goudge
2
Oooh, good line.
Alright. I've been fed a lot of Words of Wisdom, I think I get it now. :)
I consider my job like this: 5% make new and useful things, 95% fixing things with those new and useful things.
18:01
:)
There are lots of tutorials on saving and loading systems in Unity too. You might want to work through a few of those to get the sense of the strategies used. Then you can use what you've learned to build your own, if the ones in the tutorials don't work exactly the way you like.
Great. But the problem here is, I never quite understand video tutorials, and c# seems like the kind of thing that's going to need a lot of video tutorials.
I use text tutorials myself, and there are lots of those too.
This'll be great. Some while later, I'd have learned the basics, the right way. I mean, C'mon, it can't be harder than trying to control the force in Star Wars, right?
Comparable risk of being lost to the temptation of the Dark Side though...
18:06
I don't get video tutorials either. I prefer text.
user92578
Yup
I can skim through what I'm looking for much more easily.
But then I'm in the same boat as DMGregory. Been programming for errrr a long time so I'm usually more looking for how to use an API and a new language syntax stuff rather than "how to program".
Yeah... None of use want to end up with synthetic skin and 86% cyborg like Vader... And that reminds me... I've been watching Star Wars one-right-after-another, and I watched the part where Anakin is in pieces with 0 limbs (excluding his 1 remaining limb, because it was robotic and he lost it already anyways), and Obi-Wan Kenobi yells at him "YOU WERE THE CHOSEN ONE!!". lol
Maybe I should watch those before our subscription to Disney+ ends..
I'd skip the prequels, honestly. They don't really fill in anything the other movies didn't already establish more elegantly.
18:20
I disagree, only because the Space Battles between the Trade Federation and the Republic Cruisers are pretty rad.
I was thinking of Episodes I to Episode IX (if there is such a thing). In the order they were released. I've seen the "middle" trilogy once or twice, but not the first one (or I don't remember much about it).
I imagine there's a supercut of just the battle scenes. 😁
I've heard Machete order is also decent
And, the CGI is so incredibly better that they seem like different series. I started from 1 and am making my way up and just finished 5. I realize certainly that Movies 4-6 are from far before 1-3. I mean, the CGI is horrible if you really judge it, I mean they look like giant plastic models, and the CGI of the Millennium falcon is horrible inaccurate. I mean, when the Falcon zooms off into the distance, it's uncoordinated and the physics are messed up.
But it's still enjoyable! I mean, this was a feat in the 1970's!
But, 1-3 is so amazingly better. I mean, Yoda in 5 and 6 is a puppet or an animatronic of some kind, and it's obvious. In 1-3, he's CGI and it looks waaaaaay better.
And sadly, the sets of many scenes were poor in quality and detail and were obviously cardboard, which inadvertently gives me the feeling that I'm watching a play. And if I was a critic, I could go on about the poor lighting of Movie 4. But again, I can't blame it in George Lucas.
Remember: Jar Jar Binks was the first completely CGI character ever. Meaning, no other movie had completely CGI characters before then... and Binks was first introduced during the early-mid 1'st movie. (To be accurate: technically the 1'st movie was the 4'th movie).
@DMGregory okay, cool!
18:36
I'd be tempted to add Rogue One, though not quite sure where I'd stick it...
I'm not sure I'll watch too many of those. I've kept my distances because it's such a contract and there are so many movies...
user92578
Rogue One is probably my favorite Star Wars movie
@Wasabi Keep in mind that George Lucas made tons of money with that. Not sure you can compare Episodes 4-6 visuals with anything more recent.
agreed
I just got done with an ultra-basic tutorial!
Now I know some of the things!
Like: If I make my own class, I need to put [System.Serializable] above it to ask Unity to serialize it, and then define the Function below it inside of the curly brackets.
So... Where to next?
I'm at learn.unity.com, and it says "what do you want to learn?" and I think, "Well, what should I learn?
Whatever makes you curious. I find those are the things I pick up most easily.
18:43
Okay. What about: Starting Timeline Through a C# Script - 2019.3
Isn't this what I'd use to make someone like a Human Walk?
@noobprogrammer :)
I personally think that learning to program and doing it while making a game in Unity looks like a big contract and should be cut down into two individual task, but that's just me.
Sometimes you'll want custom classes that aren't serialized by Unity. Sometimes you're have a serialized class with no functions. So just be aware those don't make an absolutely universal recipe.
Because they won't be dragging across the ground without moving. They'd be doing the funky "Human Walk", which I'd assume would use an animation? Because if anyone has ever played "QWOP"... It's impossible.
Timelines are things you use to control the sequencing of stuff. Think like a cutscene, where you want the camera to follow this character coming into the room, then cut to the other character and play their line of dialogue, then...
18:46
@DMGregory Ah, I see. Like, the fancy stuff.
@Almo When did you make that game anyways? I've never seen a Unity splash screen like that.
Star wars Episode 4 and 5, original theatrical releases. Skip everything else.
Not only fancy stuff. But, it's not what you'd use to make a walk cycle, usually. That's something you'd usually create in a dedicated modelling and animation program, then just import to Unity as an asset.
@noobprogrammer it's been built more recently with version from... 2018 or something? originally it was 2015 version.
Ah ok, that makes sense.
18:48
I wouldn't recommend a game in Unity being someone's introduction to programming
starting with stuff like "tic tac toe in python" is a better place to begin
So... not for me yet? I'm thinking that'd be in a more advanced-game-thing.
@Almo I already know how to use Python.
I made a Gravity Simulator in which you take a rocket and blast it off of Earth and hope you'll go up and make it out of the atmo, and then not burn up on re-entry into, say, mars.
@Wasabi I agree with Almo. I learned some of my C# from Codecademy, and some from experimenting, some from YouTube, etc.
how long would it take you to implement tic tac toe, with no AI, but a text display of the game state
I imagine getting something like that done in a half hour or less.
so the basics of game state, whose turn is it, move input, etc are all things I would not have to worry about
@DMGregory If I'm not to use a human, what should I use?
I'd hate to have a cube drag itself across the floor.
Myself, I like teaching fundamentals of object oriented programming in Unity, because it gives you an interface where you can see the objects. That helps folks develop intuition about the idea of instances of a class.
What do you want to use?
18:51
Agreed. Definitely
@Wasabi Here's a list of some of animators, free and paid: filmora.wondershare.com/animated-video/…
I'm not sure. Something that doesn't need to walk, but can get into car, go up stairs, and fit through a doorway.
@noobprogrammer is it the software you're saying?
That sounds like a human. I don't know many other things that can walk and get into a car.
Yep, that's animation software you could use for making basically any 3D model.
For your purposes, I'd recommend using a free example asset. There are lots of basic humanoid character models with animations ready to use on the Asset Store and other sources.
18:54
@DMGregory I don't know, I'm pretty sure aliens can do that too lol.
I've never seen one do it.
The guy in coneheads did it.
Pretty sure that was a human with a funny hat.
Hmm. The Asset store is broken for me, which is inconvenient.
I don't know man, seems kinda alien-like to me.
18:55
You mean assetstore.unity.com isn't loading for you?
Nope.
@Wasabi Is your wifi down?
Definitely human in a funny hat
How about Adobe Animate?
18:58
For 2D animation, like sprites?
I have Paint 3D and SketchUp
3D
Wait does AA not do 3D?
Oops...
I would not want to mess with animation system problems in my first game. But I'm a very conservative person when it comes to setting goals for myself, since my goal is usually a "publishable polished product". So that might not be appropriate for you.
Ya, I'm working on a 2D game first, because it's more my speed.
Well, I want a walking human. Also, I like 3D better because I feel like 2D is lacking something important... (a third dimension is very useful)
I will get to bigger stuff later, after I am finished with my first game and understand C# and Unity better.
19:02
@Wasabi You can have depth in 2d... (sorry for the double ping)
19:15
@noobprogrammer Just after you asked this, mind dropped. XD
I'd say work with simple sprites first. Make Space Invaders or Asteroids or Angry Birds. Then work up to animated characters.
I agree with @DMGregory.
19:47
Okay. Maybe I'll stick to a creepy noface stick for my player until I can figure out the walking stuff... But for now, what should I do? I have multiple things I want to do, but I can't decide what: Make a Car (more like a Military AAV) in Paint3D; Learn how to make an AI npc; Learn how to make my in-game computer screen type letters when I click the in-game computer keys (if it is even possible); Learn how to script a car; or Learn how to make a screen display a mini-clip that I make.
Which one?
And can somebody tell me if my computer-key goal is even possible? What I mean is that i have a computer that I custom-made in Paint3D. I want to make it so that the screen of the computer in Unity will type stuff when I click the keys; but type words and not just single-letters. Is this possible, or am I thinking too big?
What would make that impossible?
Does anyone know where I could find a filter like this for Unity?
I've been looking for a while, and haven't found anything except $30 plugins.
Searching "Unity CRT shader" turns up quite a few results.
Um... @DMGregory I just don't know if something so complex is possible. Is it?
It's a Goal I really want to achieve. What tutorial(s) should I learn to comfortably script this kind of thing?
19:52
Is your computer capable of detecting a key press? Yes. Is it capable of turning those keys into words? Yes. Is it capable of displaying those words on an image? Yes. Chat functions in games - or this very chat room - wouldn't work if those things were impossible.
No no no.
I mean the Computer In My Game
I made a computer In My Game
Hint: your computer IN YOUR GAME is running on THE REAL COMPUTER. You can use all the fantastical capabilities of your real silicon, because that's what your game is running on.
Wait what?
Anything a computer program can do, a computer in a game can do, because a game is a computer program.
woah wait. Are you telling me I can "script" a "Unity" on this "Game Computer"? I'm not quite getting that.
This is what I mean by "Computer in my Game"
19:57
Yes, I know. I'm just not understanding what step in this process you're in such disbelief could be possible.
The problem of drawing text on a browser window isn't fundamentally different from drawing it on a square that you position in the space where that 3D model's monitor is sitting.
Seriously?
What do you suppose would make such a thing impossible?
So... what do I need to do to get that to happen? (I mean what tutorials should I learn)
I don't even know what step you're having a hard time with.
I just didn't think that was... well, possible! It seemed a bit too complicated. But I guess you're right.
20:00
Unless you're trying to break a law of physics or solve the halting problem, it's usually safe to assume it's possible. Especially if you've seen it done in games before.
So then is it like I just "add letter" when I press a key (which of course switches to a blank screen like a Word Document on the first key type) and then "remove key" when I press "Backspace"? How would I do that? I don't mean "Teach me! Teach me!" Unless you could easily explain how I would do that. I just mean what kind of tutorial would cover that? I'm saying : "What am I supposed to be looking for?" for these tutorials so that I can actually do it.
It sounds like you're asking how to manipulate a string variable.
someText = someText + newText; will add the string contained in newText to the end of the string contained in someText, for example.
Huh.
This is one of those "you might want to learn the language" topics. Microsoft has lots of documentation about operations you can do on strings
Okay. Would you call this a difficult task, or is this easy for you? Just curious how difficult this seems to a pro.
20:07
Putting text on a screen is pretty simple - could have a proof of concept running in Unity in 15 minutes. But if you want fancy word processor features, that gets tougher.
Yeah. I mean "Click the Q key and have that "Q" show up on screen. Then click the W key and have that "W" show up on screen, but now as "QW"".
And I don't mean Q and W on my keyboard. I mean the Q and W keys in the game.
user92578
Oh man implementing text fields was while somewhat cool, also very challenging, especially when I got into multiline stuff
You can do that?
The QW example is not especially difficult, just a little fiddly. You'd have to set up colliders on each button on the keyboard, with a variable storing what letter each one represents.
user92578
I did the dumb, however teaching, choice of implementing my own game engine, so when I wanted multiline text fields for Steam Workshop integration, I ended up implementing those myself
user92578
20:12
In hindsight should probably have used like stb for that, I think it has a text field control utility header
Hmm...
So it shouldn't be as hard as my Saving script?
Your saving script isn't strictly "hard" either. Writing a saving script in a language you don't understand is what's hard.
Yeah.
Once you understand what all the keywords are doing, then expressing what you want with them becomes vastly easier.
Okay.
20:19
@Tyyppi_77 that must have been "fun"
user92578
:D
@DMGregory I can't use colliders because I want to click the keys with my physical computer mouse
Why would that forbid you from using colliders?
Because I click it. I wouldn't need a collider for the script then, now would I?
How do you think Unity determines which 3D object you clicked? (Hint: it uses colliders)
20:30
Oof
Try not to leap quite so quickly to "I can't". Chances are, you can.
Okay.
Yep
So when I click it, I make it create a char "Q"?
And then use the chars into a string to type?
That would work.
Then you can display the string on a text rendering component like a TextMeshProUGUI, and position that component inside your screen, or capture it to a texture and display that texture on your screen.
So do I make the Char public static so that I can access it with a different script which takes the chars and combines them into the displayed string?
I wouldn't recommend that, no.
What I'd do is have something like a Typing script that exposes a method like public void PressKey(KeyCode key)
20:46
So public void PressKey(KeyCode.Q){?
Then I'd have a Keyboard script that, when it detects a key has been clicked, calls PressKey(keyThatWasClicked)
Now the typing script can own the string of what's been typed, and doesn't have to know where that text came from (so you could later implement other ways of feeding it text, like copy-paste or AI characters that can also type, or speech-to-text if you wanted)
Oh.
So the typing script goes into... the key? And in each key?
No, the typing script should be in just one place. I'd attach it to the computer, myself.
So what about the key itself? Wouldn't I use if (Input.GetMouseButtonDown(0)){ and put that into the key, have the if-then part be making a new char that represents the key the script is attached to, and then have the typingScript detect the char and then put that into a string that accepts additional chars if any, and then displays that string as a TextMeshProUGUI?
I wouldn't recommend putting the mouse detection on every single key - because then you have ~50-100 instances all checking for input and firing rays every frame.
I'd make one script for the keyboard, that detects the click and fires a ray once. If that ray hits a key, it looks up which key that was, then calls PressKey with that information.
20:55
Ah, yes that sounds far better.
00:00 - 21:0021:00 - 00:00

« first day (3828 days earlier)      last day (1486 days later) »