If you push W the character will move up and face up.
If you push D the character will move right and face right.
If you push W and D the character will move up/right and face up/right.
etc
An eight direction walking system, I did figure out how to do this with logic bricks. The character has to rotate differently depending on what direction he is facing. But with eight directions, that is a lot of confusing work and while I think it’s possible to do with logic bricks I think my brain couldn’t handle it. Is there some faster way, to have the character face an axis depending on what button/button combinations you’re pressing.
I have no idea how to work the scripts, so basically what I’m asking for is a script that I can insert and with little effort have working on say a cube, thanks.
With Logic:
Add 8 empties parented to the player box in the directions you want. When you walk the right way use track to to face the empty you want. It might be good to use states, and only allign the skeleton of the player, not the player box, that remains invisible and only moves not rotates.
With Python:
make a dictionary of directions as vectors:
“east”:[1.0,0.0,0.0] etc…
Then object.alignAxisToVector() to get them to point in the right direction.
This is easier if you are using grid movement since you can get the vector from the direction to the desired grid square.
When I use that track to method the character seems to flip upside down for some reason, he faces the direction but he goes upside down hmm?
EDIT: I think I figured it out, the cube has to be parented to an empty that tracks the other empties.
EDIT2: Nope didn’t work, ahh these logic bricks are sooo logical.
You should have a cube, that’s the player. It moves only, it doesn’t ever turn. it has 8 empties parent to it. Use the track to actuator on the player’s skeleton which is parented to the cube. The skeleton (and visible mesh) will appear to turn to face the right direction. Since you can’t see the player box it seems that the player always faces the way that he is moving. You can use another state for attacking where he tracks to an enemy instead.
If you use python:
object.alignAxisToVector() has some issues when tracking on the y axis. The flipping you noticed.
I usually use my own script for that.