Answer the question
In order to leave comments, you need to log in
Script not working on Unity3D camera?
I decided to write a script for the camera in C #, but when saving, these errors come out.
Here is the code itself, what's wrong?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CameraControll : MonoBehaviour, IPointerUpHandler, IPointerDownHandler
{
public float sensivity = 2;
FixedTouchField fixedTouch;
public Transform ComerafollowObj;
Vector3 pos;
CinemachineVirtualCamere cv;
public float limit = 9;
void Start()
{
cv = FindObjectOfType<CinemachineVirtualCamere>();
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
All wrong.
First, specify the using UnityEngine.EventSystems directive to use the IPointerUpHandler, IPointerDownHandler interfaces.
Secondly, you did not implement the interface methods, without them the code will not compile.
Third, FixedTouchField and CinemachineVirtualCamere are not used to create variables,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question