How strange..

When I first started to look at strangeioc, I felt a little bit like I was headed down the all too familiar path of learning something new just because it’s there. It’s not like I have a huge history of successfully completing.. well.. anything. So it was entirely possible that altair was doomed..

It turns out however that strangeioc is not only really cool, but highly functional as well.

Strange (see how I dropped the ioc? It’s because we’re friends now.) lets me code in a style that I am more accustomed to seeing in enterprise grade business applications rather than game development; the MVC development pattern.

The beauty here is just how natural a fit this actually is. My views get to be whatever they need to be to get the pixels onto the screen and intercept user input. Then they get nicely translated into the appropriate events by way of a mediator object before getting routed to an appropriate controller/command to actually make things happen. And all of this happens by way of an easy to follow binding process.

If you’re working in Unity and haven’t given strangeioc a try (The ioc is back. Things got weird. People were beginning to talk.), I recommend you check it out.

My latest efforts have seen me refactoring (for some very loose definition of refactoring) my movement arc into its own game object so that I can easily put it on.. anything.

I’ve bumped into some interesting scenarios with using the default object picking functionality built in to Unity. Specifically, there’s a beautiful little method called OnMouseUpAsButton which fires off the appropriate events on an object that you’ve clicked on. It however relies under the hood on simple raycasting which has the undesired effect of having objects get in the way of my mouse clicking.


In this image you’ll note the green box is the clickable region used by the movement arc. There’s some logic in there to ensure that it only actually uses clicks that fall within the designated movement space but that bounding box is a Unity collider. This is a really easy way to leverage the built in click functionality. However, note the asteroid in the lower right corner and how it overlaps with our bounding box. Its collision mesh actually ends up coming first along the y-axis so it intercepts clicks in that corner.

How annoying..

The quick fix is quite simply to move the asteroid on to the Ignore Raycast layer. This layer is ignored when doing the built in mouse click raycasting. This of course has a caveat, you can’t put your object on another more meaningful layer. I suppose you could use tags to help organize things but the physics system leverages layers so I’m certainly losing something.

This solution seems good enough for me for now as I don’t intend to ever have a player click on an asteroid. We’ll save that for my next game, asteroid clicker.

Also, blogger was terrible so I’ve migrated to WordPress in the hopes that it is slightly less terrible. Let’s see how it goes!

Leave a Reply