06 December 2018

3D Game Development.. Beware the Rotation!

Less serious post this time around, I just want to share the fun I had during the Game Engineering lecture.

A Little To Read Before...

So to get you on the same terms. I'm currently studying Games Engineering at the Technical University Munich and we have a Unity 3D platformer project as one of the practice tutorial things. We did an STG or Shoot 'Em up before the platformer that you might see in the future that's another story though. Anyways according to the tutorial we're supposed to make different kinds of platforms and we want but there's a list of possible options. There could be falling platforms, spinning platforms, etc.. I liked the idea of a spinning platform as it reminded me of Super Mario 64. Thus I tried to implement the spinning platform and that's where the fun came out of.

A Spinning Platform, Not So Hard, Right?

Oh, boy. I created the mesh in Blender since I wanted an octagon and it was a perfect opportunity to get into Blender. Created, imported, materialized, added the script to make it spin, tested, worked.

See, it is easy. After a week or two, we were supposed to make a box that can be pushed by the player. Simple. Our player has a Rigidbody, adds another to the box. Done. Added fancy normal map and height map to the box to make it look even better and programmed it to be able to swim in the water in which the player drowns. All nice a perfect.

I went to test it and pushed the box off into the water while testing the swimming as well. Seems good, but then something happened. The boxes changed their scaling. 
"Why the hell did they do that?", I was thinking to myself. After trial and error, I started to kinda realize what it has to do with.

The Culprit Was Found

Every time a box came near the spinning platform it's scaling was changed. There was no doubt about it, it was the spinning platform. After testing some more I finally also figured out the problem, sorta. So the issue was that the spinning platform works like so: if something collides with the platform it is considered a child of the platform and spins like the platform spins. Makes sense right? Unfortunately, if some Rigidbody actually rolls or rotates the two rotates interact with each other resulting in the scaling of the object to change. The result got me my own game idea and a lot of fun even though I just wanted to do a tiny little bit of debugging during the lecture.

What's So Funny About That?

Well.. imagine the player being pushed kilometers into the air, being shot out of the map outside of the death zone, like a homerun ending up soft locked, boxes resizing into all kinds of shapes and with a short amount of code change the player changing to weird kind of shapes, scales and sizes as well. Yeah, I had my fun with this.

Let's Get Serious Again

But, let's be serious. I haven't figured out how to solve this issue. As a reminder: we have a spinning platform and different game objects with Rigidbodies that are supposed to move with the spinning platform. How do I stop them from changing their scaling? I'm currently thinking about calculating the movement and then adding velocity to the Rigidbody without rotation... I don't know.




Liked the post? Noticed an error? Wanna discuss the content or leave a comment*? You can join or check into the discord to do so! (*Note: Comments are disabled to avoid saving user data on this website.)
>> Join Discord

About Me

My photo
I'm a B.Sc. Games Engineer and I created this blog to share my ideas, theorycrafting, thoughts and whatever I'm working on or doing.