Orbit one object around another based on Input axis

In my 2D game, I’m trying to make an objects position (in this case a camera target) sit somewhere in an ‘orbit’ around the player based on the direction of input.getaxis. The target must always be 1f distance away from the player.

Eg. (when player is moving up-right)

2240279--149437--eg.gif

Can anyone give me some pointers as to how this can be done? I’m not too brilliant at maths equations and such which is what I guess it’ll need.

EDIT: Some further info. I change my characters direction with 2 animation floats ‘x_dir’ and ‘y_dir’ which are pulled from input.getaxis on the controller. So I’m not able to just set a child object so it rotates with the player.

(in a script on the camera)

transform.RotateAround(player.transform.position, Vector3.up, rotateSpeed);

where “player” refers to the player’s GameObject or Transform and rotateSpeed is the amount it’s rotating around in degrees (positive is clockwise, negative is counterclockwise). The exact distance will be maintained all on its own, unless you change it manually.

EDIT: Nevermind, misread it. In this example though, if the player is moving up-right and the camera is up-right, does that mean you always want the camera facing the character from head-on?

EDIT2: I think I see what you want. Just make an empty GameObject and make it a child of the player. Move it into the position you want (1f “ahead” of the player when he’s facing forward) in the inspector, and it’ll automatically rotate around to stay in that relative position whenever the character (the parent) is moving/rotating around. Make that empty GameObject the camera’s target and you’re set.

Thanks. Regarding your Edit2 though, I tried changing my x position of the child camera target to 1 but it doesn’t do what I want.

Is it because my object doesn’t actually rotate to turn in game? It’s kinda pokemonesque rather than top view. I change anim floats and animation sprites to set direction

Edited. And yes ^_^.