Main Menu

y rotation

Started by 9kaywun, October 15, 2012, 11:08:54 PM

Previous topic - Next topic

9kaywun

Tryin to setup a 12 directional movement system in a game I've been developing..

When I walk around in the game, let's say I am going east.. my character rotates in a circle the entire time instead of JUST face east.. I've read the javadocs for Object3D and I'm still very lost as to how I can do this properly.. I need a way to either reset rotation before each directional face update, or something because it increments the new rotation request into the old one, and over rotates..

Here's a snippet:

      switch (direction) {
      case 2: // north west
         rotateY(-45f);
         rotateMesh();
         translate(new SimpleVector(-3.2, 0, +5.55));
         break;
Developing a 3D multiplayer engine using jPCT:
Deleted, will return soon..

EgonOlsen

Two things:

This...

rotateY(-45f);

...most likely isn't what you want. You have to give the angle in radians, not in degrees. In this case, -PI/4.

This...

rotateMesh();

...is not needed here and actually hurts. It's meant to make the rotation permanent to the mesh. You don't want that here. It's actual purpose is to setup your mesh after loading, in case the orientation isn't correct. It's not meant to be used or needed at runtime in almost every case.