- Home /
Multiple Camera Angles, Choseable
So, i am creating a MOBA game with the "mouse to border" camera movement.
I Want to make 3 cameras total, one viewing from the West, one from South, and one from East. I then want players to be able to switch between them, giving them an option to veiw all angles, one at a time. I was thinking about putting the switch buttons on F1-3, so they are easily accessable.
But i dont know how to accomplish this. Anyone?
Answer by DankGameGenerator · Nov 10, 2017 at 08:53 AM
using UnityEngine;
using System.Collections;
namespace Camera
{
public class CameraModule : MonoBehaviour
{
public float scrollSpeed;
public float topBarrier;
public float botBarrier;
public float leftBarrier;
public float rightBarrier;
void Update()
{
if (Input.mousePosition.y >= Screen.height * topBarrier)
{
transform.Translate(Vector3.forward * Time.deltaTime * scrollSpeed, Space.World);
}
if (Input.mousePosition.y <= Screen.height * botBarrier)
{
transform.Translate(Vector3.back * Time.deltaTime * scrollSpeed, Space.World);
}
if (Input.mousePosition.x >= Screen.width * rightBarrier)
{
transform.Translate(Vector3.right * Time.deltaTime * scrollSpeed, Space.World);
}
if (Input.mousePosition.x <= Screen.width * leftBarrier)
{
transform.Translate(Vector3.left * Time.deltaTime * scrollSpeed, Space.World);
}
}
}
}
This is my code so far :)
Your answer
Follow this Question
Related Questions
I need help to make the player go towards where the camera is facing. 1 Answer
How to make the player move where camera is facing? 1 Answer
Player movement based on camera? 1 Answer
Third-Person Camera keeps intersecting with terrain/buildings 2 Answers
Problem with camera and character controller (fighting game) 1 Answer