8 Dir Movement with turning
|
Something that kinda gets on my tits a bit is 8-directional movement where the character is facing left, then you move him right and he instantly faces right. In real life, a person would turn to face that direction, and in games it just makes things look smoother, more realistic and generally better.
There is an extremely easy way to pull this off, using default 8-Directional Movement and the sweet Direction Calculator. It's such an easy method, but the average user might not even think about doing it.
First off, it's best to have a hidden object which is gonna be the player. Assign a 8-Direction Movement to that object. I usually like to make this object an arrow which has 8 directions of animation, just good for testing the movement so you can see which way it's facing. For the purposes of this tutorial, we'll call the object 'Player.'
Now you need to make your actual player. Let's call the little dude 'Gary.' Give old Gary 8 directions of animation for all the animations you need.
Okay then, we need to be making Gary's position the same as Player, so do that with a simple Always event then Set Gary Position reletive to Player. Simple enough.
Now we need to use the Direction Calculator. Put one in your frame, and then we simply need to add to the Always event. With the Dir Calc's Rotate Object Toward Direction condition. Have Gary rotate toward the direction of animation of Player. And that's it, simple as that.
You'll need to make the animation of Gary change depending on whether Player's moving or not, so just have his animation Start when Player speed is greater than 0, and when Player is stopped, have Gary's animation stop.
Well that was easy enough, but not many people do it or even think about it.
For my game Monsters on Friday <plug> http://www.create-games.com/download.asp?id=4733 </plug> after people requested a strafing method, I simply used a method so Gary's direction would lock the way he's facing while a key is pressed, allowing him to walk backwards, left, right while shooting forward, and I think it works pretty well for the game. I used CTRL for the dir-lock key.
To do this, instead of the event of Gary's direction chaning happen Always, change the event to Repeat while CTRL is pressed, but negate it. So Gary will turn the direction only when CTRL is not being pressed. Easy, eh?
Well that's it. Hope this will click in people's minds as it adds a bit of a smoother feel to the controls.
NB: you don't have to call the character Gary for this to work, but I find you get better results if you do.
|
|
|