I am currently making an endless runner game where the game spawns straight tiles and corners. As the player plays the game the tiles need to be spawned with various rotations according to the previous path and the corner generating the next tiles.
My problem is that even though the spawn point has an accurate rotation (yaw) when I use that rotation as part of a transform data to spawn the tiles, the rotation is never accurate.
90 becomes 89.99993, then 89.99987 and so on and so forth.
If you play the game for longer than 2-3 minutes the effect is very noticeable as the player is going more and more towards the side of the tile instead of straight ahead.
Does anyone know how to set the rotation of the tile actor to an accurate number? I have tried using round and ceil but still no luck
I tried sort of what you did but here is the result.
I am taking the yaw rotation of the spawn point set by the previous tile and rounding it then making it a float. Afterwards, I am inputting that float value to the transform rotation of the next tile to be spawned.
Then during play, I am printing the actor rotation and it results in this
Perhaps setting yaw directly isn’t the best idea. Possibly normalization kicking in. Try to use Combine Rotators node instead.
Another idea is to change directions by vector math instead and then use convert from X node to create rotator.
better yet use Find look at rotation to generate rotator.
Hm, those are indeed some alternative options that I can try out, I did try the create rotator from Z if I remember correctly, but the tiles were spawning in completely different directions so it’s possible that there’s something there but I just need to tweak it more to have it work out.
I don’t think the Find look at function will work as the tile literally will not have anything to look towards.
Nonetheless thank you very much for taking the time to reply to my answer, it does help to receive some input so that I can try out different approaches.
As for the Combine Rotators, can you please clarify for me or give me an example of how I would use that?