Posts Tagged "demo"

Arcing Projectiles in Unity

Joe Strout —

A frequently asked question in both the Unity forums and on Unity Answers is: How do I make a projectile arc to its target, like an arrow shot from a bow?  I've seen (and given) lots of different answers to this question, and honestly, most of them are unjustified hacks.

The right (and easy!) way to do this is: just add a bit of arc to your standard movement.  Objects in freefall (ignoring air resistance) follow a parabolic arc, and the equation for a parabola is very simple.  So, we can just use that equation to compute how must extra height we should have, and simply add it to our Y position, and the job is done.

read full post

Triangulating 3D Polygons in Unity

Joe Strout —

I'm currently doing a job where I need to take 3D polygon data and display it in Unity.  These polygons are planar, but oriented arbitrarily in 3D space.  Moreover, they can contain holes (possibly multiple holes).  Think of a building wall with window cut-outs, and you'll get the idea.

This turns out to be a surprisingly thorny problem in Unity.  There is a simple script on the Unity wiki called Triangulator, but it only works with Vector2D and doesn't support holes.  I found a blog post on Advanced Triangulation in Unity, but it was neither sufficiently advanced (only works in the XY plane) nor actually in Unity (it wrote each polygon out to a file, invoked an external command-line tool to do the triangulation, and then read the result back in).

The utility referenced in that blog post is called Triangle, which is widely regarded as a very good triangle library.  It's open-source C code, so one could make a Unity plugin out of it.  But it's not licensed for commercial use, which is a problem for this project.  Also, making a native plugin means setting up a build chain for every platform you want to support.  For both reasons, I kept looking — I really wanted something in pure C#.

read full post

2D Animation Methods in Unity

Joe Strout —

Unity has provided a built-in state machine editor for managing animations since version 4.  This is the officially recommended approach to animating a game character.  However, it often leads to game logic being divided between code and the animator state machine.  I would prefer to have all my game logic in one place, to simplify development and debugging.  Moreover, in some cases — especially simple 2D sprite games — the Animator can seem like more trouble than it's worth.

To help clarify the pros and cons, I built a 2D game character using three different approaches:

  1. A simple home-grown animation system that eschews Unity's built-in animation support completely.
  2. Use of Unity animations, but without using the Animator state machine; instead each animation is invoked directly from code.
  3. Full use of the built-in Unity components, with all game logic in the state machine, and only minimal supporting code.

For the rest of the story, see the full article on Gamasutra!

read full post

Hush For Now news

Joe Strout —

We have just posted a new demo video, this one introducing Hush For Now, our Android utility for automatically silencing and unsilencing your phone.

read full post
 

All blog posts