Rotate 3D Objects using Mouse with Input System (+Touch) in Unity 2024 - Simple

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

ความคิดเห็น • 5

  • @AnujChouhan-o7b
    @AnujChouhan-o7b 8 หลายเดือนก่อน +1

    Can you please tell me that how can we rotate our camera in unity with fixed touch input field. So that we can give input from mobile

    • @GameDevBox
      @GameDevBox  8 หลายเดือนก่อน

      the easiest way is to use a Cinemachine. Use the Unity Package Manager (in the top menu: Window > Package Manager) to select Cinemachine for installation. also, Cinemachine supports a number of 2D-specific features, including orthographic rendering and 2D framing, where you can compose, track and follow objects.

  • @thev01d12
    @thev01d12 6 หลายเดือนก่อน +1

    In this solution if your player is facing in the opposite direction of world's forward axis the mouse Y input will invert, to fix that you can use player's up and right axis instead of world.
    Basically the code will look like
    transform.Rotate(playerTransform.right, mouseYInput, Space.World);
    transform.Rotate(playerTransform.up, mouseXInput, Space.World);

    • @GameDevBox
      @GameDevBox  6 หลายเดือนก่อน

      Thanks for the information!

    • @diegospartano1550
      @diegospartano1550 22 วันที่ผ่านมา

      Thank you! I've been trying to implement object rotation in my first person game and I struggled to make the rotation relative to the player's orientation instead of just rotating the object around itself. This is exactly what I needed!