Unconfigured Ad Widget

تقليص

إعـــــــلان

تقليص

رثاء

‏خالص العزاء والمواساه في وفاة العضو القدير الأخ ياسر ياسين رحمه الله

https://www.maxforums.net/node/3676654
شاهد أكثر
شاهد أقل

طلب تحريك الكامرة بواسطة الماوس برنامج يونتي 3d

تقليص
X
 
  • تصفية - فلترة
  • الوقت
  • عرض
إلغاء تحديد الكل
مشاركات جديدة

  • طلب تحريك الكامرة بواسطة الماوس برنامج يونتي 3d

    شباب انا جديد بهاذا المجال و محتاج كود بلغة #c لتحريك الكامرة بواسطة الماوس لان الدورات التعلمتهة على اليوتيوب ما بتتكلم
    عن هذا السؤال ولكم جزيل الشكر ولا تبخلو على

  • #2
    السلام عليكم اخى

    هذا هو الكود

    using UnityEngine;
    using System.Collections;

    public class CameraController : MonoBehaviour
    {
    public Camera myCamera;
    public Transform cameraTarget;

    public float distance = 1;
    public float hight = 10;
    public float minDistance = 1;
    public float maxDistance = 5;
    public float zoomSpeed = 10;

    public float cameraSpeed = 300;
    public float rotateSpeed = 2;

    private float cameraRotationX;
    private float cameraRotationY = 50;

    void Start()
    {
    //myCamera = Camera.mainCamera;
    //cameraTarget = GameObject.Find("Car").transform;
    }

    void Update()
    {
    //AutoCamera();
    ManualCamera();
    }

    void AutoCamera()
    {
    myCamera.transform.position = cameraTarget.position + (cameraTarget.rotation * new Vector3(0, 5, -distance));
    myCamera.transform.LookAt(cameraTarget);
    }

    void ManualCamera()
    {
    if (cameraTarget != null)
    {
    if (Mathf.Abs(Input.GetAxis("MouseCamera")) > 0)
    {
    cameraRotationX += Input.GetAxis("Mouse X") * cameraSpeed * Time.deltaTime;
    cameraRotationY -= Input.GetAxis("Mouse Y") * cameraSpeed * Time.deltaTime;

    //cameraRotationX = Mathf.Clamp(cameraRotationX, -360, 360);
    cameraRotationY = Mathf.Clamp(cameraRotationY, 1, 90);
    }
    if (Mathf.Abs(Input.GetAxis("Horizontal")) > 0)
    {
    cameraRotationX += Input.GetAxis("Horizontal") * rotateSpeed * Time.deltaTime;
    }
    if (Mathf.Abs(Input.GetAxis("CameraZoom")) > 0)
    {
    distance += Input.GetAxis("CameraZoom") * zoomSpeed * Time.deltaTime;

    if (distance < minDistance)
    distance = minDistance;
    else if (distance > maxDistance)
    distance = maxDistance;
    }
    else
    {
    myCamera.transform.LookAt(cameraTarget);
    }
    RotateCamera();
    }
    else
    {
    Debug.LogWarning("We don`t have a target for the camera");
    if (cameraTarget != null)
    {
    cameraTarget = GameObject.Find("Car").transform;
    Debug.LogWarning("We Found the target for the camera");
    }
    }
    }
    private void RotateCamera()
    {
    Quaternion rotation = Quaternion.Euler(cameraRotationY, cameraRotationX, 0);
    Vector3 position = rotation * new Vector3(0, 0, -distance) + cameraTarget.position;

    myCamera.transform.rotation = rotation;
    myCamera.transform.position = position;
    }


    }
    -:| My Games |:-
    AfterEarth Online SOON

    -:| Contact Us |:-
    Facebook Page :- NTStudio

    تعليق


    • #3
      بارك الله فيكم

      تعليق

      يعمل...
      X