Hi! I'm trying to extend so I can spin the camera around the player when using the Isometric camera found on the Downloads section. For some reason my script doesn't seem to be working correctly. It rotates but doesn't keep the player on center.
Here's the code, I've tried both using the center of the Screen and the player as pivots, without success.
Any help would be appreciated.
using UnityEngine;
namespace AC
{
public class SpinCamera : MonoBehaviour
{
private Camera cam;
public UnityEngine.Vector3 centrePoint;
public void Start(){
cam = GetComponent<Camera>();
centrePoint = cam.ScreenToWorldPoint(new UnityEngine.Vector3(Screen.width / 2, Screen.height / 2, 0f));
}
public void Update ()
{
if (KickStarter.playerInput.InputGetButton("Fire3") )
{
Debug.Log("Rotating");
cam.transform.RotateAround(KickStarter.player.transform.position, Vector3.up, 10f * Time.deltaTime);
//cam.transform.RotateAround(centrePoint, Vector3.up, 10f * Time.deltaTime);
}
}
}
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
The Isometric Camera updates its own position each frame - so change you make via the above script will be overridden just after.
If you're looking to rotate the camera through input, however, you might be better off with the built-in Third Person camera, which does support such rotation. You should be able to set its Perspective to Orthographic, and tinker with the height values, to achieve a similar Isometric perspective.
Thanks, managed to configure the 3rd person camera and it's working nicely
Another question, I'm using the Straight to Cursor movement method.
When I enable the camera Spin to be Draggable, Straight to Cursor stops working since they both use the same Drag Input.
Is there a way to have a separate Drag Input for each action? Left mouse button would move the character and right mouse button would spin the camera for example?
Thanks
Got it to work, using this script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;