Jeez, spent the longest time trying to figure a bug in Unity where 'spawnpoint' wasn't defined. Didn't quite figure out it was a transform value I'd set up in the thing I was trying to instantiate - I kept thinking I hadn't set up the instantiate properly and was going through all sorts of hoops and variations trying to figure what I did wrong!
Eventually clicked and had to figure a way to plug the player value into the instantiated object.
Now I can have the ghosts spawn after a certain position is passed, for a bit of a 'Argh!' effect - which the characters dialog is set up to give as well!
Philosophy in life. Philosophy in life spent gaming. Table top RPGs, mmorpgs, video games, and more.
Friday, August 31, 2012
Thursday, August 30, 2012
Unity: Counting substrings inside a string
Tying into the previous post, it seems unity has no actual command for counting the number of instances of a substring in a larger string. I've been hunting around for ages and having found no actual command, I've decided to show some code that does it. The code is about as tight as you can get it without it actually being a command!
As with the last post, I'm using /n instead of \n. This is because when the interpretor looks at \n it decides to ignore the n part, making the search only one character in length. The previous post lists the way you can easily convert /n to \n. I know, it sounds annoying - if I were reading this, I'd think it was annoying. But given that unity gets uppity if you try to enter strings into the inspector (ie, it just wont do line breaks if you do so), you're probably gunna have to end up switching /n to \n anyway. It's just a simple replace command anyway (okay, fine - if you don't want to look at the other post replace is as simple as: guimessage = guimessage.Replace("/n", "\n"); )
But I make excuses like a man! Now, onto the search code!
As with the last post, I'm using /n instead of \n. This is because when the interpretor looks at \n it decides to ignore the n part, making the search only one character in length. The previous post lists the way you can easily convert /n to \n. I know, it sounds annoying - if I were reading this, I'd think it was annoying. But given that unity gets uppity if you try to enter strings into the inspector (ie, it just wont do line breaks if you do so), you're probably gunna have to end up switching /n to \n anyway. It's just a simple replace command anyway (okay, fine - if you don't want to look at the other post replace is as simple as: guimessage = guimessage.Replace("/n", "\n"); )
But I make excuses like a man! Now, onto the search code!
var stringtosearch = "this is the test string /n with several /n line breaks in it";
var searchingfor = "/n";
var substringspresent=0;
var searchextent=stringtosearch.Length-searchingfor.Length; // makes sure we don't search past the end of the string!
for (i=0;i<=searchextent;i++)
{
var sectionscanned=stringtosearch.Substring(i,searchingfor.Length);
if (sectionscanned==searchingfor) substringspresent++;
}
print (substringspresent);
Unity: Getting new line in inspector entered strings to work
It's weird - in a script I had some text defined with \n to create a new line and that worked out.
But when I defined an array of strings and filled them in in the inspector, it'd just show the \n instead of creating a new line!
So here's a solution:
But when I defined an array of strings and filled them in in the inspector, it'd just show the \n instead of creating a new line!
So here's a solution:
guimessage = guimessage.Replace("/n", "\n");In your strings, have /n instead of \n. It'll replace them and for some reason, they then start working! It puts the special magic back in!
Gimp Layer Transparency Tip
It's something I get hooked on occasionally. If you want to make a layer overall have some transparency, in the layers dialog box itself there is a slider near the top for opacity. Once again I was hunting through menus trying to find that option!
Wednesday, August 29, 2012
Reward Systems: One vote, one party
There's something that bothers me about the reward structure for a summer class, described over at play this thing.
I'm not quite sure what it is. I'm thinking that it's the complete lack of choice - that point systems can act like voting - and you vote/collect points for what you want. But a 'set' system - it's like a one party system, but the more you vote for them the better off you are.
Not sure I like game systems that promote monomaniacle behaviour. It really is all or nothing. You can't sway the sysem - your either a devote, or you leave it entirely.
Not commenting there, so as to reserve the cynicism a bit.
I'm not quite sure what it is. I'm thinking that it's the complete lack of choice - that point systems can act like voting - and you vote/collect points for what you want. But a 'set' system - it's like a one party system, but the more you vote for them the better off you are.
Not sure I like game systems that promote monomaniacle behaviour. It really is all or nothing. You can't sway the sysem - your either a devote, or you leave it entirely.
Not commenting there, so as to reserve the cynicism a bit.
Subscribe to:
Posts (Atom)