memoshwastaken
Hectopat
- Katılım
- 11 Temmuz 2021
- Mesajlar
- 377
- Çözümler
- 3
Daha fazla
- Cinsiyet
- Erkek
Merhaba, Unity 3D üzerinden geliştirdiğim oyunda kamera takip kodu yaptım fakat kamera karakteri takip ettiğinde karakter titriyor. Nasıl düzeltebilirim?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class kamera : MonoBehaviour.
{
public Transform target;
public float MouseSpeed;
float xrot, yrot;
public float minX, maxX;
// Start is called before the first frame update.
void Start()
{
}
// Update is called once per frame.
void FixedUpdate()
{
transform.position = Vector3.Lerp(transform.position, target.transform.position,10000f );
xrot -= Input.GetAxis("Mouse Y")*Time.deltaTime*MouseSpeed;
yrot += Input.GetAxis("Mouse X") * Time.deltaTime * MouseSpeed;
transform.GetChild(0).localRotation = Quaternion.Euler(xrot,0,0);
transform.localRotation = Quaternion.Euler(0,yrot,0);
xrot = Mathf.Clamp(xrot, minX, maxX);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class karakterkontrol : MonoBehaviour.
{
public float hiz = 10f;
public Transform Cam;
// Start is called before the first frame update.
void Start()
{
}
// Update is called once per frame.
void Update()
{
float xyon = Input.GetAxis("Horizontal") * hiz;
float zyon = Input.GetAxis("Vertical") * hiz;
zyon *= Time.deltaTime;
xyon *= Time.deltaTime;
transform.Translate(xyon,0,zyon);
if (xyon != 0 || zyon != 0)
{
transform.rotation = Quaternion.Lerp(transform.rotation, Cam.transform.rotation, 0.3f);
}
}
}