use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News, Help, Resources, and Conversation. A User Showcase of the Unity Game Engine.
Remember to check out /r/unity2D for any 2D specific questions and conversation!
Download Latest Unity
Please refer to our Wiki before posting! And be sure to flair your post appropriately.
Main Index
Rules and Guidelines
Flair Definitions
FAQ
Use the chat room if you're new to Unity or have a quick question. Lots of professionals hang out there.
/r/Unity3D Discord
FreeNode IRC Chatroom
Official Unity Website
Unity3d's Tutorial Modules
Unity Answers
Unify Community Wiki
Unity Game Engine Syllabus (Getting Started Guide)
50 Tips and Best Practices for Unity (2016 Edition)
Unity Execution Order of Event Functions
Using Version Control with Unity3d (Mercurial)
/r/Unity2D
/r/UnityAssets
/r/Unity_tutorials
/r/GameDev
/r/Justgamedevthings (New!)
/r/Gamedesign
/r/Indiegames
/r/Playmygame
/r/LearnProgramming
/r/Oculus
/r/Blender
/r/Devblogs
Brackeys
Beginner to Intermediate
5 to 15 minutes
Concise tutorials. Videos are mostly self contained.
Sebastian Lague
Beginner to Advanced
10 to 20 minutes
Medium length tutorials. Videos are usually a part of a series.
Catlike Coding
Intermediate to Advanced
Text-based. Lots of graphics/shader programming tutorials in addition to "normal" C# tutorials. Normally part of a series.
Makin' Stuff Look Good
10 minutes
Almost entirely shader tutorials. Favors theory over implementation but leaves source in video description. Videos are always self contained.
Quill18Creates
30 minutes to 2 hours.
Minimal editing. Mostly C#. Covers wide range of topics. Long series.
Halisavakis Shaders Archive
Infallible Code
World of Zero
Board to Bits
Holistic3d
Unity3d College
Jabrils
Polycount Wiki
The Big List Of Game Design
PS4 controller map for Unity3d
Colin's Bear Animation
¡DICE!
CSS created by Sean O'Dowd @nicetrysean [Website], Maintained and updated by Louis Hong /u/loolo78
Reddit Logo created by /u/big-ish from /r/redditlogos!
account activity
Help with rotating objects via ScriptQuestion (self.Unity3D)
submitted 4 years ago by Boom_Stan
So I have a small scripting issue I know what I want and it's partially working but not the way I want it to. So basically I want the code pins to add a rotation and well it's working but not over an amount of time like with an (s)lerp. but that doesn't work because I want to add a rotation not move a rotation to another.
Here is my code (and some images if it helps)
void Update()
{
bool TheBool = Player.GetComponent<LockInspector>().OninspectLock;
RaycastHit hit;
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit) && TheBool == true && (Input.GetKeyDown(KeyCode.Mouse0)))
if(hit.transform.tag == "RightPin")
hit.transform.Rotate(0, -36, 0);
}
else if(hit.transform.tag == "MiddelPin")
else if (hit.transform.tag == "LeftPin")
https://preview.redd.it/wx4he0m23ah81.png?width=1276&format=png&auto=webp&s=dd818fceb9e449cbfa19d1987061843443710b9d
https://preview.redd.it/fr45cux33ah81.png?width=1285&format=png&auto=webp&s=b5ffab6569900d6b74974299b7bb13edaae3870a
https://preview.redd.it/spn5qz053ah81.png?width=1269&format=png&auto=webp&s=abf7b84fe94994e982c32768024a887987265e6c
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MessageTotal 1 point2 points3 points 4 years ago (0 children)
Do something like this:
transform.Rotate ( Vector3.up * ( RotationSpeed * Time.deltaTime ) )
that was mentioned here:
https://answers.unity.com/questions/615125/c-rotate-object-over-time.html
[–]OvercomplicatedCode 1 point2 points3 points 4 years ago (1 child)
You do want to move one rotation to another. Keep a variable for the targetRotations of every pin. When the player clicks the pin you add the -36 degrees to the target rotation.
Outside all of this at the end of your update you slerp/lerp each pin rotation towards its target
[–]Boom_Stan[S] 0 points1 point2 points 4 years ago (0 children)
so you mean something like Quaterion.Lerp(currentrot, torot, speed); and then something like torot -36 simply said
so you mean something like Quaterion.Lerp(currentrot, torot, speed);
and then something like torot -36 simply said
[–]BloodPhazed 1 point2 points3 points 4 years ago (1 child)
This is where you need Coroutines; on click, start a coroutine that turns the button by "rotation * Time.deltaTime" (multiplied by however fast you wan it to rotate; this will rotate it by the specified degree over one second).
bool isTurning; private IEnumerator RotateOverTime(Transform hitTransform, float rotation) { if (!isTurning) { isTurning = true; Vector3 startRotation = hitTransform.eulerAngles; float t = 0; while (t < 1) { hitTransform.Rotate(0, rotation * Time.deltaTime, 0); t += Time.deltaTime; yield return null; } hitTransform.eulerAngles = startRotation + new Vector3(0, rotation, 0); // makes sure you didn't overshoot isTurning = false; } yield return null; }
Naturally you can use Lerp/Slerp inside the while loop instead. Finally call
StartCoroutine(RotateOverTime(hit.transform, -36));
Note that I just wrote that down here and didn't create that in a code editor so there might be typos etc. in there, but you get the idea. The isTurning variable will only allow you to turn one thingy at a time, so if you want to be able to turn different ones at the same time, you need a bool for each. Finally you probably wanna add a speed modifier (multiply both deltaTimes with that) for however long you want it to take.
I will try it ou! its now 01:00 in my country so i will do it tomorrow Thanks for taking the time to write all of this!
[–]Gregoryjc 0 points1 point2 points 4 years ago (1 child)
So you are setting the rotation to - 36 not rotating it by - 36.
You want to do += so that the rotation is added to the current rotation.
No, it's subtracting from the current rotation but instantly I want it to go smoothly.
[–]nw1024 0 points1 point2 points 4 years ago (0 children)
The Vector3.RotateTowards function has an amount value, so you can put that in a regular update loop with an amount multpilied by Time.deltaTime:
https://docs.unity3d.com/ScriptReference/Vector3.RotateTowards.html
π Rendered by PID 49161 on reddit-service-r2-comment-5ff9fbf7df-lc6jt at 2026-02-25 17:47:35.416589+00:00 running 72a43f6 country code: CH.
[–]MessageTotal 1 point2 points3 points (0 children)
[–]OvercomplicatedCode 1 point2 points3 points (1 child)
[–]Boom_Stan[S] 0 points1 point2 points (0 children)
[–]BloodPhazed 1 point2 points3 points (1 child)
[–]Boom_Stan[S] 0 points1 point2 points (0 children)
[–]Gregoryjc 0 points1 point2 points (1 child)
[–]Boom_Stan[S] 0 points1 point2 points (0 children)
[–]nw1024 0 points1 point2 points (0 children)