Dec 20, 2008

Making the AS3.0 VCam Follow Your Player

This tutorial is directed to people who know a bit about flash, I won't be explaining everything in detail.

Download the VCam from this site if you don't already have it.

Make a blank document, don't try this on a game you're working on right now, because if you mess something up then it could be a headache for you. Best to just learn it fast and then implement it afterwards.

So, add the vcam into your document. Go into the vcam's code (double click the vcam mc).
We need to do some editing to make this work right, find this line and delete it:

We are going to be calling the camControl function from our player after and before we move it, that way there should be no jitters.

Now make a player mc, I used a picture of Borat.
Before he moves, and after he moves, you want to update the camera. I found, for this example at least that if you also update it before the movement it takes the jitter away, if you don't do that then there's some jitter I'm not sure why.

The code is too long for a post, so look at the fla instead if you need an idea of how to do this.



bob said...

How did you get control of it?

Is there someway to map the control with something like this:

mc._x += Key.isDown(Key.UP);
mc._x -= Key.isDown(Key.DOWN);
mc._y += Key.isDown(Key.LEFT);
mc._y -= Key.isDown(Key.RIGHT);

Anonymous said...

Man... this code is so strange, you call camControl with this line:
"" but you never added "camera" as a child of "master", yet it works???
On the camera code you use events,display objects, geom objects(Point) without importing any of those?
So confusing :(


Kevin Stubbs, Ivan Alvarez Malo