Posts Tagged ‘Programming’
Programming related posts.
Unity3D: Programming a machine gun – Part 1
Posted by Dimitri | Filed under Programming
This is the first of two posts that will explain how to program a machine gun at the Unity3D game engine. This post will focus on coding the element that defines a weapon of this type: continuous automatic firing. It will show two different ways to achieve this behavior: one based on the Invoke() method call, and the other based on Unity3D’s coroutines. As any other post series in this website, a Unity3D project with all the source code will be available at the last post of the series.
All code in this post will be in C#, but for those who don’t use it, a JavaScript version of the code will be available for download at the end of the post.
Game Programming Basics: Moving an element
Posted by Dimitri | Filed under Programming
This post explains some of the most basic game programming techniques: how to move elements on the screen. If you already know this, please skip it, or add something to this post in the comments. Since these lines of codes are trivial to game programming, it may be one of the reasons why it is so hard to find a post or a website explaining them. The code presented on this post isn’t the only way to move objects in a game and certainly there is a lot more information out there. The intention of this post is to serve as a starting point.
Unity3D: JavaScript vs. C# – Part 5
Posted by Dimitri | Filed under Featured, Programming
As the end of the year draws close, so is this post series. Here, the differences between JavaScript and C# when casting a ray in Unity3D will be pointed out. Don’t forget to read the first, second, third and forth parts of the series for a better general understanding of what is being discussed here.
Let’s start from the basics: What is ray casting? As the name describes, it is basically a program that simulates a ray being cast, much like a laser pointer in real life. It is very useful for game programming, as Raycast classes are programmed to return the distance a ray collided with something (and sometimes, even the name of the object). Unity3D doesn’t have one single Raycast class, instead its functionality is scattered across the Physics, RaycastHit and Ray classes.
Unity3D: JavaScript->C# or C#->JavaScript access
Posted by Dimitri | Filed under Featured, Programming
When programming for Unity3D, there are some cases where we need to access a script written in another programming language that isn’t the one we are currently using. Although it is highly recommended to convert all scripts to the same one, it is useful to know how to access a C# script from a JavaScript class and the other way around.
The first thing to do is place the scripts in the correct folders in your Project tab. The script you want to have access must be inside the Standard Assets or the Plugins folder. The other script has to be placed outside these folders. After this step, just call the GetComponent() method as any other Component. Here’s a JavaScript example: (more…)
Android Manifest File for a Game
Posted by Dimitri | Filed under Programming
Android was designed to see every application as a collection of Activities united by intents. It also relies on the Activity stack to determine what Activity will be launched after the user finishes it by pressing the ‘back’ button. While the stack system is helpful for users and for some applications, this default behavior isn’t a necessarily a good thing for games.
That is mainly because of two things: a game use a lot of hardware resources from the device that runs it, meaning that having other activities in the same stack as the game Activity can have an impact on its performance. And the stack default behavior could lead to multiple instances of the same game running in the same stack.