Monster shadow

VIDEO

Rotate an object in Unity [2021 Tutorial for beginners]

Description:
A simple way to rotate an object in Unity. I show you a variety of ways including rotation via player input.
ADD A COMMENT

SFM Skye
how do can you make camera tilt when moving left or right in the z axis?
Walney moreira klein
hi, speak moviment tank and ship, gamers world of tank and world of warship ?
Matt Playz
I had been struggling with this for about 40 minutes, then after finally deciding on going to search it up, I watch some tutorials for about 30 minutes but they don’t help me then I find this! A 2 minute video, with extremely simple code that does what I want! Thank you so much man, this is a great video!
Tarodev
I'm here for you baby
Hasan KARAKOÇ
You are really amazing. You are really doing a good job! Please keep it!
İlyas Köse
Your content is so good.
Kevin Basel
This guy is amazing!! Clear and straight to the point. We needed a guy like him for some news Unity tutorial. Sub from me, GG!
Matthew Spencer
Thank you my guy :)
DurVids
You're knocking it out of the park with these tutorials. Short and to the point. Great stuff, thank yoU!!
srisrid multi purpose channel
Good opstical for 3d platform. I am also making a 3d platform so will help me :)
srisrid multi purpose channel
Thank you
Tarodev
A 3D platformer, aye? Good luck with it!
SEE ALL COMMENTS


Transcript:

all right let me show you how to rotate a shape in unity
all right let's create a new c script and call it rotator
open it up let's remove the start function as i
won't be using it let's serialize a new vector3
call it rotation now in the update function
access your transform and call the rotate function
pass in your rotation let's times it by time
dot delta time just to keep it consistent across all frame rates
and that's actually all you need for a simple rotate
script so let's just put the rotator on our shape
let's rotate it by 10 on the x 10 on the y per frame
and there you go and at runtime you can speed it up
you go really fast that but we can improve on this so go back to
your script let's serialize a float or
speed and now what we'll do is we'll multiply rotation
by speed by time dot delta time and
basically we'll keep this as a normalized
vector three so instead of instead of putting our speed in the
actual vector we'll put it in our speed um variable
here so now you can just speed it up from the
speed variable like that um
another thing you can do is actually rotate it by
input so you could say if input get k and we'll say a
what we'll do is we'll change our rotation equals to
vector 3 up else if we press d
down otherwise let's just set our rotation
to be zero and then we don't actually need the
serialized field here because we're not exposing it in the editor
back to unity speed up our rotation a little bit and there you go
left and right so if you learned something
leave a like subscribe and i'll see you next time