Game Development Community

Fixed angle and position camera

by Eric South · in Torque 3D Professional · 12/29/2011 (9:42 am) · 7 replies

Forgive me if this question is more obvious than I am making it seem. I'm currently working my way through my first project and trying to learn about T3D.

The project will be using a camera style similar to what you would have in games like Diablo and Mu online where it is essentially fixed on the player at a fixed angle and isn't adjustable by the user.

Looking through the documentation a little bit, I believe I've got an idea of what type of camera I'd be using, but would like to get some input as I'm not entirely sure. The camera mode I'm thinking of using would be OrbitObject, but I'm thinking it will have to be modified somewhat heavily to function properly. Would it be easier, or possible to just use a stationary camera and fix it to the player object in third person?

Any hints or tips to point me in the right direction would be greatly appreciated.

#1
12/29/2011 (11:27 pm)
You're doing what I did when I started using Torque; You have an idea in mind and just need X to work like Y, without realising that if you learn about the camera object in general, you won't even have to ask here.

The camera you want already exists. I know this because it's used in the editor. All you have to do is find it and start looking at what's using it and how. Then just write a script that uses the datablock/s you need and incorporate that into your project.

Start looking at those camera.cs files.

Hope that helps. If not, there are RTS camera resources around here if you look.

Dan
#2
12/30/2011 (5:14 pm)
I think I've found what is needed as far as the camera settings and type, but I'm now stumped on how to actually set this as the default camera and mount it to the player.

I've tried following the steps in the camera modes documentation and I can get the camera to start in these different modes, so that doesn't quite seem to be what I need. It also doesn't solve my problem of getting the camera to remain fixed on the player.

I've found the player spawning function in /game/scripts/server/spawn.cs that creates the player when they connect, but it doesn't seem to let me determine what to do with the camera.

Is there a way to create a camera object in the world editor that "mounts" to the player? I've found the mount section in the inspector panel and it asks for a persistentID. I'm not sure how to assign one or even if that's what I'm looking for.

Would it be necessary to create a new camera object in the ::spawnPlayer() function and somehow tie it to the player? I've been at this for several hours and can't seem to get anywhere on it.
#3
12/30/2011 (9:28 pm)
I'd say that creating a new script for a new camera object is exactly the right approach. After all you might need that default camera in a later level. I'd start by looking into player.cs and camera.cs and see what that leads you to. I'm sorry I can't offer more help in this regard, but I haven't even started messing with the camera yet. Although I do plan to. I'm sure others here can point you in the right direction. In the meantime I'd suggest working on other aspects of your project to save frustrating yourself.

I'm all for mounting the new camera you create to the node that the default camera is attatched to. The only issue I can foresee here is that if your player has an animation that moves on the z axis your camera is going to look weird. What I'm guessing you want is for the camera to maintain a height above the terrain.

I'm curious about this now. I'll have a peek and share my thoughts when I have something first hand.
#4
12/30/2011 (10:15 pm)
Camera.cs doesn't seem to give much information. Player.cs doesn't exist in a blank project, at least not as far as I found. Still looking for a way to get that working and marry the two. Spawn.cs seems to be the only thing "creating" the player and holding player settings. There doesn't seem to be anything in there about assigning a camera though.
#5
12/31/2011 (12:27 am)
Look through the RTS Prototype example here under Scripting/Advanced. When you work through it, try this - clean out the datablock for boombot except for the shapefile definition and the bounds definition. I did this and got the example to work on one machine and I'd like verification....

Anyway, it covers a few different camera modes and such, and should get you started down the right path.
#6
12/31/2011 (3:21 am)
That tutorial series that Richard kindly linked is a goldmine of knowlege! I keep forgetting about it, which is a shame because everything we need to know is in there. Of particular interest to you Eric, would be the Overhead camera scripts. The only caveat is that it requires/assumes you are clicking the terrain to set waypoint markers for your player, leaving the WASD keys for the camera. You'll want (I assume) to work out a method of combining the two so that they both move as one.

It occurs to me, though, that T2D would be much more efficient in this regard. Or at least that's my presumption. Okay I hear coffee calling out to me again. Have fun and good luck!
#7
12/31/2011 (11:21 am)
@Richard Thanks for the recommendation. I'll check it out and see if I can get it to work.