GoGoGadget Gurdy & A Battle with The Trait’rous GetComponent()

Boston FIG is in 3 Weeks!

Er… it was 3 at the beginning of this week, so… now it’s 2… but I like to think of weeks as discrete objects sometimes.

Anyway…

I’ve returned from teaching and so am back onto full-time development!

The course I was teaching, by the way, was a lot of fun! I’ve enjoyed teaching with MakeSchool before, but this time was even more fun — I enjoyed getting an opportunity to develop original curriculum, especially in such an open field, and, in general, find VR sooooo much more exciting than iOS.  Also, the students really blew me away with their final projects.  I can’t wait for the ones that aren’t yet up to hit steam so that I can show them to friends at home!

Now that I’m back, getting Floral Kombat ready for Boston FIG is my current priority.

If you’ll recall, oh Imaginary Reader, I received some great feedback from curators, which has given me good direction for which fixes to prioritize above others.

On the top of the list is making interactions meaningful.

A game I played while in SF that was very inspirational to me was a small-team-made local multiplayer game called Wand Wars.

It’s a lot like a game I’d seen earlier at a game night (but can’t remember the name of, so that’s not extremely helpful…) in which you hit a ball around, making it faster and faster, and try not to get hit if someone else hit it.

Wand Wars was more nuanced than the other game, however, with more varied courts, a top-down giving players more positioning options, and (most importantly) the ability to turn your opponents into chickens thus disabling them temporarily.

Wand Wars felt clean, polished, and well-balanced in terms of interactions. Everything I did to my opponents felt strategic. Even doing nothing and just moving felt strategic.

Inspired by this, I started this week by reevaluating the interaction options I’ve given the players in Floral Kombat.

I decided to try what I implement something a lot of people had been asking for — a dash, which I dubbed “Gurdy Movement” because it helped me to look to Gurdy Jr. or Lil’ Gurdy for inspiration.

I worked primarily in a sandbox scene and got something that felt pretty good.

Aug-25-2016 21-54-09

The idea is that this will replace the burst or movement altogether. Rather than walking up and bursting an opponent, you need to aim yourself, similar to the hexes in Wand Wars.

If you attract while you are jetting past someone, you can steal bees, and if you hit an opponent directly with a fully charged gurd, you’ll create a burst.

Aug-25-2016 21-57-39

Something that really bothered me about the way stealing bees was working in previous versions was how it forced players to be stationary for the most part.  Stealing involved walking up to a player, getting bees in-range of your area of influence, attracting, and then running away, BUT because you couldn’t move while attracting, the other player could just walk up and re-attract the bees.  The player could do the same back, and then you would both end up pretty much stuck in the same spot or in a slow chase.

Bursts had a similar problem. Bursting was too easy. You could walk up to a player and burst ad infinitum. I tried implementing burst juice, but even I couldn’t keep track of my juice level. Perhaps a conveyance thing, but I really wanted a way to get players to have to very visibly strategically time bursts.

I like the potential of Gurdy Movement to get players moving and to make 1 v 1 more strategic.

I’ve also reduced the size of attraction radii and decided to reduce the number of Bugs in each stage.  Resources should be limited to encourage competition, and radii should be small enough that Bugs can be owned, but outside the attraction radius.

The other big change this week is still underway: a battle against the once-friend GetComponent<T>().

But first…

SOME HISTORY

Or at least backstory.

Whenever I learn a new engine, I like finding ways to optimize flow.

A way of doing this I was really proud of in Unity was via a Utility function I wrote called Utilities.GetComponent.  It looks a little like this:

public delegate void GetComponentCallback<T>(T component) where T : Component;

public static void GetComponent<T>(GameObject go, bool doForceToExist, GetComponentCallback<T> callback) where T: Component {

    if (!go || callback == null) {return;}

T component = go.GetComponent<T>();
if (!component) {
if (!doForceToExist) {return;}
go.AddComponent<T>();
component = go.GetComponent<T>();
}
callback(component);
}
}

Aside from the fact that I could really just say component = go.AddComponent<T>() this method’s not great…

See, what I was trying to do was save myself the time of aaaaalways having to call GetComponent and then check whether or not that component even exists, which means checking whether the object is non-null in some cases… but I starting using this everywhere.

I mean, like, EVERYWHERE.

Rather than passing specific components into slots of my other components, I started getting in the habit of passing in GameObjects and then using my handy Utilities.GetComponent method.

This was great, because my code didn’t rely at all on the GameObject existing at all.  Like, if I wanted to unhook something, I just needed to empty a slot and my code didn’t really care about that.

The problem was that framerate wasn’t so happy…

GetComponent isn’t constant time, it’s O(N).

As mentioned in a previous post, teaching made me reconsider a lot of the ways I normally do things, especially things that help with frame rate (because that’s so important in VR, to prevent nausea/eye strain among other reasons).

Utilities.GetComponent was pretty much EVERYWHERE in my code, but I decided it was time to bite the non-violent projectile and do it.

Needless to say, there was a lot of this:

Aug-25-2016 21-59-29

And, well… there still is…

But… working in a sandbox scene, I can see that the work/tedium paid off!

BEFORE

Screen Shot 2016-08-25 at 10.08.15 PM

and…

❀✿** *✿:・゚✧*:・゚✧❀

AFTER

❀✿** *✿:・゚✧*:・゚✧❀

Screen Shot 2016-08-25 at 10.10.11 PM

W0000! Look at that FPS.

Beautiful.(*❁ω❁)

(I just noticed there’s one more batch in the older version than the newer version… I’m not sure what that is, but I doubt it’s eating, like 100 FPS).

Until next time,

~Zach

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s