Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Rotate Object with keyboard

    float smooth = 5.0f;
    float tiltAngle = 60.0f;

    void Update()
    {
        // Smoothly tilts a transform towards a target rotation.
        float tiltAroundZ = Input.GetAxis("Horizontal") * tiltAngle;
        float tiltAroundX = Input.GetAxis("Vertical") * tiltAngle;

        // Rotate the cube by converting the angles into a quaternion.
        Quaternion target = Quaternion.Euler(tiltAroundX, 0, tiltAroundZ);

        // Dampen towards the target rotation
        transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * smooth);
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: soundplayer c# take uri 
Csharp :: unity matchinfo 
Csharp :: return every digit on a string c# 
Csharp :: Package manager or PM cmd for dbcontext migration 
Csharp :: how to read reportview query string asp.net c# 
Csharp :: unity organize variables in inspector 
Csharp :: input string was not in a correct format convert to double 
Csharp :: in model add to give drop down message 
Csharp :: properties vs field c# 
Csharp :: An unhandled exception occurred during the execution of the current web request 
Csharp :: IdentityServer vs JWT vs OAuth? 
Csharp :: change color unity back and forth 
Csharp :: how to full screen login form using C# MVC 
Csharp :: create shortcut C# WPF 
Csharp :: internal static object ds 
Csharp :: leave two decimal in double c# 
Csharp :: c# changimg to one decimal place 
Csharp :: UnitType parameter revit 2022 
Csharp :: TTTTTTTTTTTTTTTTTTTTESTTT 
Csharp :: Delegate with parameter and return 
Csharp :: ? in c# 
Csharp :: unity Texture2D efficient performance draw pixels 
Csharp :: c# bitwise or 
Csharp :: dotnet DB context register 
Csharp :: how to get image from resource folder in c# 
Csharp :: c# windows service .net core 
Csharp :: c++ Write a program to reverse an array or string 
Csharp :: belgiumcampus 
Csharp :: unity add text to text field without deleting the old one 
Csharp :: forces the user to enter his password before submitting the form asp.net core 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =