x


How do I make a simple, 3rd person RPG-type camera behavior?

Hello! I'm a graphic artist, long time gamer excited and anxious to get into game development. Art and design are totally my thing but I hardly know squat about code and programming.

I'm putting together a 3rd-person RPG type of game and I want my camera to behave like an ordinaly, common 3rd person RPG type camera. How do I accomplish that?

A great example of the type of camera behavior I am looking for could be Legend of Zelda:OOT, Conker's BFD, Ninja Gaiden, GTA:Vice City, True Crime, etc, I am sure I could dig up a lot more if that is not helpful.

Otherwise the only way I could describe it is by referring to real-world mechanics. Imagine an elastic tether connecting the camera to the character. The camera stays fixed on the character but only moves when the characters runs away and tugs on the tether.

The SmoothFollow script would be okay except that it snaps behind the character. Lowering the damnp rotation fixes that, but then the camera hardly rotates at all. I'd like the camera to rotate to track the character and only move when the character moves away, but then only move near the character again, not snap to the back of the character as in the SmoothFollow script.

It is an insanely common and popular camera control style in RPGs but I am having hell finding the proper way to re-create it. Please, please do not respond with, "Google it." I have been googling it, youtubing it, UnityWiki-ing it, redditing it, I've probably tried a dozen different scripts not including my own butcher-coding of putting together the bits and pieces of script that I thought would get the job done and crossing my fingers for it to work.

Thank you in advance to anyone who can help me out! -Gyrant

more ▼

asked Mar 20 '11 at 05:30 PM

Gyrant gravatar image

Gyrant
1 1 1 1

Are you using UnityScript (JS) or C#?

Mar 20 '11 at 06:04 PM Statement ♦♦

All of the scripting I am using so far is JS, since it seems to be the most popular language for use in Unity3D.

Mar 20 '11 at 06:07 PM Gyrant
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

the closest i came to getting this working (from a quick try this evening) was to do the following ...

  1. add third person controller to scene
  2. select camera
  3. add mouse orbit script to camera
  4. drag and drop 3rd person controller on to "target" of mouse orbit script edit the mouse orbit script ...
function LateUpdate () {
    if (target && Input.GetMouseButton(1)) {
        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;

      y = ClampAngle(y, yMinLimit, yMaxLimit);
    }

    var rotation = Quaternion.Euler(y, x, 0);
    var position = rotation * Vector3(0.0, 0.0, -distance) + target.position;

    transform.rotation = rotation;
    transform.position = position;
}

That sort of does it ... the idea being that the camera now follows the player and when the right mouse button is held down moving the mouse rotates the camera.

It does this odd jumpy thing though (the camera acts like its constantly being nudged) a tiny bit each frame ... I get the impression theres a better way to do this or maybe smoothing might help but that's the idea right?

So close !!!

more ▼

answered Mar 20 at 11:48 PM

TehWardy gravatar image

TehWardy
16

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2992
x151
x90

asked: Mar 20 '11 at 05:30 PM

Seen: 1834 times

Last Updated: Mar 20 at 11:48 PM