Learn how to rotate!
The pivot point is a component in Unity that determines where the object will be scaling or rotating. You can change it with a parent object! But how do you change the pivot point of an object in Unity?
If you add a new 2D object to the scene, a problem that you might have every time is that you cannot modify the pivot point in the way you would like. Instead of having a pivot point positioned in the center, and your object is positioned above, you will face this issue.
To fix that, you need to do this: Create an empty parent object and add a box collider. Make sure to move the triangle object above the center. Now you should add a box collider 2D.
Lastly, if the empty parent has a box collider, that will make sure that the child object is on a different position. It needs a rotation around the parent object. An easy way to make the object rotate is by adding a simple C# script: Add a public float variable that will be called Speed.
Gallery
What is rotationSpeed?
Rotation speed is a value will be used in determining how fast will the object move. To make the object rotate around the center, you need to add a transform.Rotate() line of code. It will be cool to make a space shooter with this triangle! But that will be explained in the next video. The point of this tutorial is in rotating the parent object, not the object that is inside it. Although this video is not part of the 2D platformer series, it belongs to a specific section of Unity tutorials that will only cover some elementary things.
No responses yet