ID:2125987
 
Ok so I am working on a Gundam like Mech Game and what I am trying to do is make it so when a player gets onboard the mech, the camera view changes from the character being in the center of the screen to kind of like an over the shoulder type view were the camera view always shows the characters back and say I want to go right, instead of the map scrolling right as the character moves with the character in the center, the player would turn right and basically the camera view turns to, like I said like in most modern games I want like an over the shoulder view like say in most rpgs, not a first person view. I'm just curious if anyone here has experimented with this type of view or if anyone can point me in the right direction to a library or add-on or tutorial. Thanks in advance

The best way would probably be to use a 3D engine, such as Unity. BYOND has a 4-directional camera (client.dir) as well as isometric perspective (world.map_format = ISOMETRIC_MAP), but smooth third-person orbit cameras can only really be done with, basically, a 3D graphics engine.

If you're fine with the camera instantly snapping to one of 4 directions, you can use client.dir. Positioning the camera can be done with client.pixel_x/y, for keeping it ahead of the player.
well how bout if instead I decide to make it so say the mech is moving right, say the map is a 11x11 view, and if I move right, instead of centering on the player, the player would be a 1,6 instead of 6,6 and if I move say down the player would be at 6,11 and so on like if going up then 6,1 and 11,6 for left? is that possible?
I just want it so when the player is in the mech he can only see infront of him not behind you get what I am saying?
Positioning the camera can be done with client.pixel_x/y, for keeping it ahead of the player.

Have you looked it up yet?

If you want the camera to be in front of the player, you need to change those variables.

For example, if the player is facing east, client.pixel_x should be some positive number, and client.pixel_y should probably be zero.
I experimented with this idea on an old game of mine a while back -


As Kaio said, changing client.pixel_x/y is the way to do it. Thought I'd share how I managed to get mine to look through that method.
In response to Ishuri
man it took me a while to even notice you posted this, thanks for the assist guys a year later lol, i kept messing up and decided to just go back to working on my star wars game since i lack the necessary sprites for a mecha game
Well, here is what you wanted:

mob
Move()
..()
fix_camera(dir)
proc/fix_camera(direction)
if(client) client.dir = direction
thanks man
Or you could be a total badass and write a system that allows you to turn the map around your character.

It's kind of a whore to get to render properly, but it looks pretty cool when you can get it to work.
sounds like it, is this something that you have tinkered with and know is possible or just a concept that you have had?
I've seen it done before on much older versions of BYOND, pre-4.0 I think.

It rendered like dogshit, but worked as a single-player concept. I'm pretty sure you could get it to work a bit better on newer versions, but you'd probably still be doing a lot of the rendering yourself. It really just depends on how well the map can handle being turned dynamically.
obj/rotation_plane
plane = 1
appearance_flags = PLANE_MASTER
screen_loc = "1,1"

mob
var/tmp/obj/rotation_plane/rotation
verb/RotateScreen()
if(!rotation)
rotation = new()
client.screen += rotation
var/matrix/turn_matrix = matrix()
turn_matrix.Turn(90)
animate(rotation,transform=turn_matrix,time=10)


(Written off the top of my head, it might be pretty broken)
In response to Nadrew
obj/rotation_plane
plane = 1
appearance_flags = PLANE_MASTER
screen_loc = "1,1"
var/tmp/degrees

mob
var/tmp/obj/rotation_plane/rotation
verb/RotateScreen()
if(!rotation)
rotation = new()
client.screen += rotation
rotation.degrees += 90
if(rotation.degrees >= 360) rotation.degrees = 0
animate(rotation,transform=matrix(rotation.degrees,MATRIX_ROTATE))
That's much better, thanks for picking up the slack :)
In response to Nadrew
There's probably a cleaner way to do it in general, I just happened to notice that yours didn't actually do anything :p
Sure it did... once :)
proc/dir2angle(dir) // converts a direction to an angle -- credit to Rushnut for the original helper proc
. = 0
switch(dir)
if(NORTHEAST) . = 315 // this line
if(EAST) . = 270 // this line
if(SOUTHEAST) . = 225 // this line
if(SOUTH) . = 180
if(SOUTHWEST) . = 135 // this line
if(WEST) . = 90 // this line
if(NORTHWEST) . = 45 // and this line are reversed from the original

obj/master_plane // a plane master to control the screen
appearance_flags = PLANE_MASTER | PIXEL_SCALE
screen_loc = "CENTER,CENTER"

mob
var tmp
last_dir
obj/master_plane/master_plane
Move()
..()
if(dir != last_dir) AdjustCamera(dir) // calls AdjustCamera) if direction changes after movement

proc/AdjustCamera(dir)
last_dir = dir // sets current direction to last_dir
if(!master_plane) // if there's no current plane master
master_plane = new() // make a new one
client.screen += master_plane // add it the screen
// next we want to animate the plane rotating to the results of dir2angle over 3 1/10th seconds
animate(master_plane,time = 3,transform = matrix(dir2angle(dir),MATRIX_ROTATE))


OK, this will literally put the camera behind you at all times (rotating it around the player character like Kats described -- definitely not a whore now that plane masters are a thing). Just make sure to put all of your HUD objects on a separate plane. Two things to note:

1) This is a little disorienting. Just because your screen follows behind you doesn't mean your controls change. To actually have this feel natural, you would have to shift movement controls depending on player direction.
2) I would recommend setting your view higher than you want it to be, then scaling the plane_master in. Otherwise you're going to see the blackness outside of the view port both when rotating and when moving diagonally.

Edit: Working on this made me realize that since MATRIX_SCALE is really just matrix multiplication, this

transform = matrix(angle,MATRIX_ROTATE) * 2


is completely valid syntax. Seems really obvious in hindsight, but I had never considered it before.
right well thanks everyone for your help and idk if I ever explained what it was for cause maybe thatd effect how you code it, basically what I'm doing is making a gundam like game and I'm trying to make it so once you get in the cockpit of the suit it alters the camera view so you can see only infront of you just like an actual cockpit. I may incorporate something like a rear view mirror for seeing behind that way its somewhat realistic