Camera target-focus like Retro Affect, Nuclear Throne and Dungeon Souls! Need your help :)
Hi Guys,
im pretty new in C# coding. I wanna make a camera script for my Top-Down-Shooter. Im using WASD for moving my player and my pointer (mouse) for aiming. Now im using a easy smooth follow camera but i wanna make a camera like in Retro Affect, Nuclear Throne or Dungeon Souls.
For example: When my pointer is in the center of the screen the player will be too. When im going in the left upper corner with my pointer, the player will be in the right lower corner.. I mean Camera is always in the average of the player and the pointer. I hope u can understand me :D I coded a camera like that in Javascript but i cant do in C#
Here some links: https://www.youtube.com/watch?v=1FhB1w_7Qp0 https://www.youtube.com/watch?v=1rY1GrLWANU https://www.youtube.com/watch?v=I-N4eXJ-V04 https://www.youtube.com/watch?v=qTTVkvuJars
var MousePos : Vector3;
var CharObject : Transform;
function Update () {
MousePos = Camera.main.ScreenToWorldPoint(Vector3(Input.mousePosition.x, Input.mousePosition.y, -transform.position.z));
transform.position.x = ((MousePos.x - CharObject.position.x)/2.0)+CharObject.position.x;
transform.position.y = ((MousePos.y - CharObject.position.y)/2.0)+CharObject.position.y;
}
}
Your answer
Follow this Question
Related Questions
Messed up sprites flickering over whole screen on multiple machines while moving 0 Answers
How can I transition between areas on the tilemap in a top-down RPG type of game? 0 Answers
Camera doesnt scale GameObjects when approaching and smudges them 0 Answers
Network Multiple Cameras 4 Answers
survival shooter camera problem 0 Answers