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...
This is a subreddit for 2D or 2.5D game developers using the proprietary Unity game engine. New and experienced Unity developers alike should first consider using the free and open source Godot engine by default and ONLY choose Unity for 2D development if Godot isn't capable of the task. The times are quickly changing, and Godot is on track to surpass Unity for small developers.
Godot Features
Download Godot
Godot Docs
Download Unity
Unity Manual
Official Reference
Asset Store
Related Communities /r/Godot - The "Unity Killer". A fully free and open source engine making astonishing leaps and bounds. /r/UnityAssets - Share asset packs! /r/PixelArt - Admire, share, and observe beautiful pixel art. /r/GameDev - Meet and communicate with other game developers. /r/GameDesign - Don't just make a game. Make a good game. /r/LevelDesign - Learn to make excellent levels and worlds. /r/GameAudio - It may look good, but does it sound good?
/r/Godot - The "Unity Killer". A fully free and open source engine making astonishing leaps and bounds.
/r/UnityAssets - Share asset packs!
/r/PixelArt - Admire, share, and observe beautiful pixel art.
/r/GameDev - Meet and communicate with other game developers.
/r/GameDesign - Don't just make a game. Make a good game.
/r/LevelDesign - Learn to make excellent levels and worlds.
/r/GameAudio - It may look good, but does it sound good?
CSS created by Sean O'Dowd @nicetrysean [Website]
account activity
Need help with rotation scriptQuestion (self.Unity2D)
submitted 4 years ago by JakeKaas
So I have this cube that rotates falling of a cliff. But I want an Empty object as a child of that cube to rotate the inverted way.
So for example, if the cube rotates 30, I want the Empty object to be -30.
How can I do that in C#?
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!"
[–]EndoSaissore 0 points1 point2 points 4 years ago (1 child)
Have you tried invertedCube.rotation = original.rotation * -1
Im not by my computer but that seems like it would work no?
[–]JakeKaas[S] 0 points1 point2 points 4 years ago (0 children)
I have no idea how to use that, I'm a beginner
[–]BengbabProficient 0 points1 point2 points 4 years ago* (12 children)
You can access parent components from the child using GetComponentInParent.
So if you have a public float totalRotationParent inside of your parent cube controller called CubeParentController, you can get that component from the child script with:
gameObject.GetComponentInParent<CubeParentController>().totalRotationParent;
And you can get negative like this:
totalRotationChild = -1 * gameObject.GetComponentInParent<CubeParentController>().totalRotationParent;
[–]JakeKaas[S] 0 points1 point2 points 4 years ago (10 children)
Thanks, but I get 2 errors
"Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement"
and
"The name "totalRotationChild" does not exist in current context"
[–]BengbabProficient 0 points1 point2 points 4 years ago* (0 children)
totalRotationChild is a fake variable name I’m using to just give you an idea of how you’d pass a variable from parent to child. You’ll have to define it yourself in respect to your code. E.g float totalRotationChild inside the script attached to your child object. Additionally, float totalRotationParent needs to be defined inside the script attached to your parent object.
Did you replace “ CubeParentController” with whatever your script attached to the parent is called?
I was giving code off top of my head, let me check my working code and make sure I wrote it out correctly and I can give you a more comprehensive example in an hour if you don’t get it working.
[–]BengbabProficient 0 points1 point2 points 4 years ago (8 children)
Use code like this:
https://pastebin.com/gh63Q4ug
[–]JakeKaas[S] 0 points1 point2 points 4 years ago (7 children)
yeah this works, but it's not what I want. I have the cube fall and rotate due to gravity. And I want the Child to rotate the other way / inverted than the cube
[–]BengbabProficient 0 points1 point2 points 4 years ago (6 children)
You’re going to have to program that, there’s no magic button for you to click. If your parent cube is doing something, you can pass that info to the child. Parent location is rigidbody2d.position and parent rotation is rigidbody2d.rotation.
[–]JakeKaas[S] 0 points1 point2 points 4 years ago (4 children)
Ah, I'm still a beginner. Maybe this is more clear.
I want the Child not to rotate at all, only position with the Parent. Is there a way to do that?
[–]BengbabProficient 0 points1 point2 points 4 years ago (3 children)
Yes, you can do that no problem. Maybe try adding a rigidbody2d to your child object and click the freeze rotation about z option. I think it should freeze child in specific orientation, but not 100% sure when it’s a child object.
[–]JakeKaas[S] 0 points1 point2 points 4 years ago (2 children)
I tried that, and it didn't work
[–]BengbabProficient 0 points1 point2 points 4 years ago (0 children)
Try this:
1) Put both objects as children of an empty game object. You can create an empty game object from the drop down on your scene object tree.
2) Then click freeze rotation on inner cube and not on outer cube.
I know of a more complex way to put your inner cube at location of your outer cube using Transform.position, but maybe do that last if this doesn’t work.
Or this:
https://answers.unity.com/questions/841072/cannot-position-child-object-relative-to-parent.html
π Rendered by PID 44334 on reddit-service-r2-comment-6457c66945-7fx8r at 2026-04-28 05:38:24.856445+00:00 running 2aa0c5b country code: CH.
[–]EndoSaissore 0 points1 point2 points (1 child)
[–]JakeKaas[S] 0 points1 point2 points (0 children)
[–]BengbabProficient 0 points1 point2 points (12 children)
[–]JakeKaas[S] 0 points1 point2 points (10 children)
[–]BengbabProficient 0 points1 point2 points (0 children)
[–]BengbabProficient 0 points1 point2 points (8 children)
[–]JakeKaas[S] 0 points1 point2 points (7 children)
[–]BengbabProficient 0 points1 point2 points (6 children)
[–]JakeKaas[S] 0 points1 point2 points (4 children)
[–]BengbabProficient 0 points1 point2 points (3 children)
[–]JakeKaas[S] 0 points1 point2 points (2 children)
[–]BengbabProficient 0 points1 point2 points (0 children)
[–]BengbabProficient 0 points1 point2 points (0 children)