Archive for General Information

Website Getting an Update

My website that this blog is attached to (codersplayground.net) is getting an update. If you want to see what I am doing with it you can go to the dev section. Be aware that not all the content will be present.

The Thing About Raycasts

Raycasts are extremely versatile. With raycasts you can see if there is something under the mouse, in the path of a straight shooting object, or just about anything else regarding something being in the path of something else. As far as calculations go, raycasts are probably one of the most expensive (in terms of computational time) things that you can do. But how expensive are they? Well, let's put things into perspective about just how expensive raycasts are. We'll look at the basics of raycasting and how it is used with great frequency in a standard setting.

Raycast Basics

What exactly is a raycast, how does it work, why is it so expensive? A raycast has an origin and a direction, like any vector, and is literally cast, or thrown if you will, into the scene. The process basically involves going through every object, then checking ever vertex, face, and edge, for an intersection. Even with rigorous optimization this can be checking against hundreds of elements, and this is what makes it computationally expensive.

How it's Used

While it is relatively expensive, it is exactly how the scene is rendered. On my desktop that means 1680 x 1050 = 1,764,000 raycasts per frame just to display what is going on. On my tablet it's 1920 x 1200 = 2,304,000 raycasts per frame and 960 x 540 = 518,400 for my phone. So while it is an expensive calculation, remember that it is happening half a million to two million times a frame just to render, so doing it another 30 or so times is no worse than a 6 x 5 grid of extra pixels.

Unity Android Key Mappings

If you are using Unity to develop for Android platforms, you may be wondering what keys the different buttons map to. I happened to find the answer in a location unrelated to Unity, but the information is still valid. In order to make touch devices generally compatible, touch and key inputs are directly mapped to mouse and keyboard buttons respectively. Below is a short table snagged from a Google Group

  • One finger tap = left mouse button
  • Two finger tap = right mouse button
  • Menu key =
    • Middle mouse
    • Windows key
  • Home button = HOME key
  • Back button = ESC key
  • Power button = END key

Note:

After testing with my tablet, I could not confirm any other keys besides the back button. The menu key did not even show up.

The Importance of Humor

Many people say that having a good sense of humor is beneficial. This is the case with coding as well. Having a good sense of humor will make your code more readable as it will provide a little chuckle here and there, as well as keep you in a good mood. Working while happier is a great way to avoid lots of little errors. Not only that but, since you are in a good mood, you will be less tempted to distraction making you more efficient. Who doesn't want to complete "8 hours of work" in 5 or 6? Below is a little snippet of some good humor that I put in my code that may or may not be funny, but is of non-detrimental nature, and gave me a bit of a smile.

Coding Humor

Why yes, public health is important.

Quick Update

I haven't had time to make any posts this week for a number of reasons, but I plan to resume next week with a series on Object Oriented Programming as well as what Aspect Oriented Programming means.

Unity Docs Design Updated

I would just like to make note that the Unity Scripting Docs have been updated. You may be wondering what exactly was updated, it seems to function the same as before. Force a refresh (Ctrl + F5 or Shift + F5) and look at the navigation bar at the top. See the new colors and layout? This is actually a significant improvement. The navigation buttons are now all on the left side above the other navigation bar, not only this but the bar below the main navigation bar is a different color which matches the currently active tab. The text color has also changed. The consistency, layout, and contrast provided by this update actually make the docs more usable. Doubt it? Well, for starters, I didn't even realize that on the sub-bar there was a link to switch from the script documentation of a class to its component documentation until after this change. Did you know that link existed?

Unity Docs Design Updated

I would just like to make note that the Unity Scripting Docs have been updated. You may be wondering what exactly was updated, it seems to function the same as before. Force a refresh (Ctrl + F5 or Shift + F5) and look at the navigation bar at the top. See the new colors and layout? This is actually a significant improvement. The navigation buttons are now all on the left side above the other navigation bar, not only this but the bar below the main navigation bar is a different color which matches the currently active tab. The text color has also changed. The consistency, layout, and contrast provided by this update actually make the docs more usable. Doubt it? Well, for starters, I didn't even realize that on the sub-bar there was a link to switch from the script documentation of a class to its component documentation until after this change. Did you know that link existed?

Moving Things

Just a quick note, I will be moving all my posts over from http://codersplayground.tumblr.com/ to here and eventually removing that blog just to keep things nice and clean.

print('Hello World!');

Alrighty, here we are starting things off. I have been meaning to integrate my blog into my site for a while, and here it finally is. Right now I am working on a pretty interesting game project that has brought about a large number of problems already for which I will be providing solutions for. Check back to see what all you can learn regarding general coding practices, memory management, vector mathematics, Artificial Intelligence, system simulation, and more!

#include "commonsense.h" (or .hpp)

danielsaucen:

Though I’ve only been a programmer for around five years; I do have some tips to throw at those who decide it is elite to post nonsense about programming. This list also applies quite well to those who have no experience in programming.

  1. Creating a “Hello World” program does not entitle you to regard yourself completely fluent in a programming language. (Much like knowing the word “Si” does not make you a master at Spanish)
     
  2. Being unable to grasp a fundamental syntax (such as using 2-D arrays) does not mean it is poorly implemented. It simply means you have not done your homework.

Read More

Read more