About Store Forum Documentation Contact



Post Reply 
[SOLVED] How to stop character model from turning 45 degree
Author Message
tipforeveryone Offline
Bronze Supporter

Post: #1
[SOLVED] How to stop character model from turning 45 degree
When moving Forward and Right (or Forward + Left, Backward + Left/Right), the character model rotate 45 degree, how can I prevent that ?
(This post was last modified: 05-20-2021 10:43 AM by tipforeveryone.)
07-15-2020 02:42 AM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #2
RE: How to stop character model from turning 45 degree
Modif by PI ?
07-15-2020 03:02 AM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #3
RE: How to stop character model from turning 45 degree
Thanks for quick reply but I don't get it. I open Game.Chr and don't find any clue
Take a look at this video, I just don't want character turning like that, it is default behavior of Game.Chr
https://youtu.be/A0oFZYNJm_0
(This post was last modified: 07-15-2020 03:18 AM by tipforeveryone.)
07-15-2020 03:18 AM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #4
RE: How to stop character model from turning 45 degree
I use my own custom class so don't know much but look into angle or turn_angle
07-15-2020 04:58 AM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #5
RE: How to stop character model from turning 45 degree
It is no-use, sadly,
07-15-2020 06:39 PM
Find all posts by this user Quote this message in a reply
Houge Offline
Member

Post: #6
RE: How to stop character model from turning 45 degree
If you are using default character you get default behavior. If you need custom behavior you need to create your own class. Try to dig into Game::Chr class source code, try to create your own class with the same code and change some things, see how it works.
07-15-2020 07:45 PM
Visit this user's website Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #7
RE: How to stop character model from turning 45 degree
ye i normally start from the animatable class, and work from there with what i need, the char class is just too broad.
Have you tried to do the char update then set turn_angle=0 every frame ? It seems to be public and should normally be it
(This post was last modified: 07-16-2020 05:02 AM by RedcrowProd.)
07-16-2020 04:07 AM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #8
RE: How to stop character model from turning 45 degree
@Houge: Thanks for your advice

It took me too much time to understand and learning on myown, RedcrowProd, can you give me a look of your code which implemented from Animatable ?
07-17-2020 06:09 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #9
RE: How to stop character model from turning 45 degree
Do you still need help with this ?
07-21-2020 03:07 AM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #10
RE: How to stop character model from turning 45 degree
Yes I do I do, give me any example which I can learn, thank you so much !
07-21-2020 06:12 PM
Find all posts by this user Quote this message in a reply
RedcrowProd Offline
Member

Post: #11
RE: How to stop character model from turning 45 degree
okay,

my char class is a bit too complicated, and don't want to spend 2 hours cleaning it, so i will instead talk about the class Animatable : Obj

this class has a base object, including actor, mesh and skel.

once you have used create(Object &obj); with your object, you will have the class populated with all proper var according to that object ( meaning, skel of the object, meshes of the object, base actor... )

I normally have my main class, containing an animatable obj ( you could use it as parent as well but i believe that to avoid unexpected behavior like return false in a update to not make my whole class delete itself, it is better to separate them)

all you need to do is call the virtual Bool update(); and return true as long as you want it to exist. it should do all the behaviour by itself, as expected.

using the
// get / set
virtual Vec pos ( ); // get position
virtual void pos (C Vec &pos ); // set position
virtual Matrix matrix( ); // get matrix , returned matrix is normalized
virtual void matrix(C Matrix &matrix); // set matrix , 'matrix' must be normalized

function, you can change its position, or matrix, its as easy as it sounds.

here is an example on how to move the pos and rotate of the actor using the matrix:

obj.matrix(Matrix().setRotateY(angle+PI).move(pos())); // my model is facing off, so i add PI to make it straight

all you need is a way to handle the angle, which normally you would use mouse input in a FPS, else it could be a direction if you use point and click. obviously in a fps, you want X and Y to be rotated.

for the position its the same idea, you can register key, have your var speed * time.rd() according to your camera.orn matrix.


Now the animation:

AnimationFlt += time.rd(); // this can add slow or w.e you want
obj.skel.updateBegin(); // begin update
obj.skel.clear();

obj.skel.animate(SA_Idle, AnimationFlt, 1.0f , true);
obj.skel.animate(SA_TurnRight, AnimationFlt, flt_Turn_Right , true);
obj.skel.animate(SA_TurnLeft, AnimationFlt, flt_Turn_Left , true);
obj.skel.animate(SA_Walk, AnimationFlt, flt_Walk , true);
obj.skel.animate(SA_Run, AnimationFlt, flt_Run , true);
obj.skel.animate(Mot_Ability, true); // for combat animation

obj.skel.updateMatrix(obj.matrix()); // update skeleton animation matrixes
obj.skel.updateEnd(); // end update

there all you need is populate the correct SkelAnim, and flt blend anim ( this is to avoid jitter in the animation, normally i blend 0 to 1 with Lerp, i normally do the most static to most animated animation, as blend will work on previous set animate i believe.


hope that helps smile
(This post was last modified: 07-22-2020 11:53 PM by RedcrowProd.)
07-22-2020 11:50 PM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #12
RE: How to stop character model from turning 45 degree
@RedcrowProd
Hey, thank you so much for your explaination, it is clear like daylight, here is what I got, now I can control animation well in esenthel.! Cheer!

https://youtu.be/CyjMqi5BM7w
07-24-2020 04:58 PM
Find all posts by this user Quote this message in a reply
tipforeveryone Offline
Bronze Supporter

Post: #13
RE: How to stop character model from turning 45 degree
A final fix for anyone read this and have the same problem
put this in virtual update function to avoid character model from turning 45 degrees on moving Left/Right Forward

anim.strafe_yaw = Lerp(anim.strafe_yaw, 0, 1);
05-20-2021 10:42 AM
Find all posts by this user Quote this message in a reply
Post Reply