Summer Work (Day 17)
Off The Beaten Path
Today I have decided to take a little break from following the tutorial verbatim. Instead I have decided to give some attention to two things that I have wanted to fix for a while now. These two things are planet rotation and a bug where the planet is not rendered at it's actor location in the scene.
First thing first, I wanted to get the planets showing up in the right part of space. The problem was, when I put a new planet in the scene the procedural mesh part of the actor would always snap to the world origin. Then if I moved the planet in the scene the meshes would always have the offset from where it was initially placed. I suspected that this was due to the root component being created at 0, 0, 0. To combat this, in the constructor I tried resetting this value, but that didn't work. What did end up working was setting the root component as a UPROPERTY then manually editing its transform. Yet another compromise that works for now, but that I will ultimately end up fixing later.
Next thing I wanted to do was getting the planets to rotate. I played with the idea of also adding a tilt to this rotation for more variety but this will come later. Instead I added a variable for the rotation rate and one extra line to the UpdatePosition() function that sets the relative rotation of the root component. Now with all that I have done, this is the result:
Now in doing this I realized some limitations of my planet generator. Most of which have to do with instancing. While trying to create the two different planets in that video, when I changed a setting on one planet it would apply to the other if it got reinitialized. Most of these setting changes could and will be solved by changing the UPROPERTY specifier of those variables from EditAnywhere to EditInstanceOnly. But other variables, like the noise settings for instance, might need more than just that.
Code changes can be seen here: https://github.com/setg2002/CppGame
Comments
Post a Comment