Posts Tagged ‘JavaScript’

These posts contain JavaScript code or are somehow related to JavaScript.

Unity: How to create a speech balloon

Click here to read Unity: How to create a speech balloon

This Unity tutorial explains how to create a speech balloon, like the ones featured on comic books, in Unity3D. For any game, objects move around the screen, and in order to make the speech bubbles work, they have to follow the movement of these objects. However, the balloon can’t be translated in the 3D space, or else it will look like a regular billboard sign over the character’s head. So, it has to follow the character on the two dimensional screen space. The elongated edge of the balloon must also follow the character’s movement, stretching and shrinking accordingly.

To solve these two issues, a script is necessary, which will treat the round part and the triangular tip of the balloon separately.

Speech balloon division

The script will create a speech balloon by rendering these two parts separately. They must have the same color to create the illusion that it's a single element.


Unity: Raycast Reflection

Click here to read Unity: Raycast Reflection

As any person that has already used Unity’s Ray class knows, there’s no support for reflection, which could be useful for some specific cases. This post will try to offer a solution to that, explaining how to create a script which casts a ray that gets reflected when it hits a surface. Not only that, but the script also allows to set the number of times the cast ray should bounce. An example project with a scene and the code explained below is available for download at the end of the tutorial.

Before looking how the reflection script works, a scene must be set with some walls to reflect the ray. Additionally, a game object will be required to act as the source of the ray . To create the ray’s source, just select GameObject->Create Other->Cube: (more…)

Embedding the Unity Web Player with jQuery

Click here to read Embedding the Unity Web Player with jQuery

This post explains how to use jQuery to embed the Unity Web Player on a page. This post was inspired by GFX47, after reading this tweet. Here, you will find a step-by-step explanation on how to load the script on a HTML file. This will be achieved by using a jQuery plugin.

Unity3D already comes the tools to export a HTML file with all the code needed to embed the player. With that, one might be wondering what are the advantages of using jQuery to embed the Web Player. Here’s a list of advantages:

New Project: ‘Interactive Squares’

Click here to read New Project: ‘Interactive Squares’

Finally, a new project! It’s been a while since a post was published in this section of the website.

This is a project I’ve being developing, and will be called ‘Interactive Squares’ for now. It’s basically a interactive piece that is being created using the openFrameworks toolkit.

I have started this project using ActionScript, but thought it could be much more interesting if the user used a webcam for the input.

The application consists of a group of gray squares that are repelled each time the element that is controlled with the mouse collides with one of them. A gray square only returns to its original position after the black one is at a certain distance from it.

So, here’s a working prototype made with Flash: (more…)

Unity3D: Programming a machine gun – Part 2

Click here to read Unity3D: Programming a machine gun – Part 2

This is the second and last post of this series that explains how to code a machine gun in Unity3D. The first post explained how to make the automatic firing mechanism, and this one will focus on how to set-up the machine gun, the bullet and explain the code that makes it all work. Also, a Unity3D project with all the source code discussed on the series is available for download at the end of the post.

So, let’s start by setting the machine gun. The 3D model of the gun can be any one, you don’t even have to create a 3D model at all, it is possible to use Unity3D’s cubes and other primitives. The only thing that one must know is that the muzzle of the gun must be a completely separate element. This is crucial when making the gun at an external 3D modeling application such as 3D Studio Max, Blender or XSI. (more…)