Sorry about the mouthful title, but basically, trying to make a RTS camera, similar to the ones used in Paradox Interactive games (Crusader Kings, Europa Universalis, Hearts of Iron, ect.) I took a look on the internet, but nothing seemed to use the Unity Input System (the package).
I made a Input Actions asset, putting in PanMap (Pass Through, Vector2), binding it to the middle mouse button, and a ZoomMap (Pass Through, Axis).
Created a C# Script, and put:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Requiem
{
public class Controls : MonoBehaviour
{
GameControls controls;
float PanSpeed = 20f;
float ZoomSpeed = 2f;
float Zoom;
Vector3 CameraPosition;
private void ZoomMap()
{
Zoom = controls.Default.ZoomMap.ReadValue<float>();
CameraPosition.y += Zoom * ZoomSpeed * Time.deltaTime;
}
private void Awake()
{
controls = new GameControls();
controls.Default.ZoomMap.performed += ctx => ZoomMap();
}
private void Update()
{
CameraPosition = transform.position;
transform.position = CameraPosition;
}
private void OnEnable()
{
controls.Enable();
}
private void OnDisable()
{
controls.Disable();
}
}
}
Loosely following the Brackeys tutorial. I am not sure what to do from here, and I’m not sure what to put in the controls.Default.ZoomMap.ReadValue<>(); section, so I put float.
Anyone have any ideas/can help?
