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

Поділитися
Вставка
  • Опубліковано 27 жов 2024

КОМЕНТАРІ • 4

  • @AnujChouhan-o7b
    @AnujChouhan-o7b 5 місяців тому +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  5 місяців тому

      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 4 місяці тому

    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  4 місяці тому

      Thanks for the information!