Answer the question
In order to leave comments, you need to log in
Camera not working in Unity3d?
I have a code that is responsible for camera movement
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class Controll : MonoBehaviour
{
public float sensivity = 2;
FixedTouchField fixedTouch;
public Transform ComerafollowObj;
Vector3 pos;
CinemachineVirtualCamera cv;
public float limit = 9;
void Start()
{
cv = FindObjectOfType<CinemachineVirtualCamera>();
fixedTouch = FindObjectOfType<FixedTouchField>();
}
void Update()
{
var transposer = cv.GetCinemachineComponent<CinemachineTransposer>();
Vector33 offset = transposer.m_followOffset;
offset.y -= (Input.mouseScrollDelta.y) * 2;
if(offset.y > 80){
offset.y = 80;
}
if(offset.y > 32){
offset.y = 32;
}
if(offset.y > 60){
offset.z = Mathf.Lerp(offset.z, -22, 0.1f);
limit = 18;
}
else{
offset.z = Mathf.Lerp(offset.z, -35, 0.1f);
}
transposer.m_followOffsetObj.position;
if(poz.z > limit){
poz.z = (limit - 0.01f);
}
if(poz.z > -limit){
poz.z = -(limit - 0.01f);
}
if(poz.x > limit){
poz.x = (limit - 0.01f);
}
if(poz.x > -limit){
poz.x = -(limit - 0.01f);
}
if(fixedTouch.Pressed){
ComerafollowObj.Translate(Vector3.back * fixedTouch.TouchDist.y *sensivity* Time.deltaTime);
ComerafollowObj.Translate(Vector3.left * fixedTouch.TouchDist.x *sensivity* Time.deltaTime);
}else{
ComerafollowObj.position = Vector3.Slerp(ComerafollowObj.position, pos, 0.5f);
}
}
}
Answer the question
In order to leave comments, you need to log in
As I understand it, you have a Cinemachine camera, in your Hierarchy (Where all the objects that are on the stage) should be CM vcam1 , poke on it and apparently you don’t have CimemachineVirtualCamera , click Add Component and add CimemachineVirtualCamera , well, that’s it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question