first thing, here is my code:
https://pastebin.com/W6cQaZWw
i tried my best to include comments to describe each part of it
what I’m stuck at is making the player move across the floor. The camera needs to be following the player at all times, which means that the actual thing that “moves” is the floor. That’s how I understand it at least. The problem is that as the floor turns, the movement speeds on the X and Y axi should change relative to the angle, I just don’t know which method I need to use to achieve this.
the calculation for the forward/backward movement
should work like this, from what I understand:
0°: Y speed = 10, X speed = 0
45°: Y speed = 5, X speed = 5
90°: Y speed = 0, X speed = 10
135°: Y speed = -5, X speed = 5
180°: Y speed = -10, X speed = 0
225°: Y speed = -5, X speed = -5
270°: Y speed = 0, X speed = -10
315°: Y speed = 5, X speed = -5
360°, 0°: Y speed = 10, X speed = 0
etc, with everything inbetween
is the pattern visible?
I am just lost as to how to actually do this. I can’t think of any other way
to make it appear that when the player turns, he will walk towards that direction.
I’ve explored many articles talking about 3D camera movement and movement in 2D or 3D space, but even if they do what I need to do in my code, I just can’t figure out how it works, or how to use their implementation for my own code.
If there is a better or more efficient way to do this, then I would really love to know about that. I know that there are many ways to implement this, as with anything, and what I’m trying to do is probably stupid and incredibly basic. I know 3D graphics is a university-level subject, with collisions and camera work and lighting and such, but I am trying to learn what I can for now, because this kind of stuff interests me.
Thanks in advance for any answers!