About Store Forum Documentation Contact



Post Reply 
Make character look up/down from net input
Author Message
mystara Offline
Member

Post: #1
Make character look up/down from net input
Hi,

I want to make a character model look up/down (like by using Chr.input.turn.y = 1) based on input from a server.

The MMO does something similar to make a character turn when it does:

Code:
Matrix matrix;
matrix.orn().setRotateY(ANGLE_X_RECEIVED_FROM_SERVER);

I tried transmitting Chr.angle.y and using that to do:

Code:
Matrix matrix;
matrix.orn().setRotateY(ANGLE_X_RECEIVED_FROM_SERVER).rotateX(ANGLE_Y_RECEIVED_F​ROM_SERVER);

However, that rotates the entire model rather than just the character's head and seems to move it on a weird axis.

Any clues? It feels like it should be fairly simple, but I haven't a clue what I'm missing.
I actually managed to get something a bit closer by doing this:
Code:
Orient &head = cskel.getBone("body").orn;
head *= Matrix3().setRotateX(ANGLE_Y_RECEIVED_FROM_SERVER);

But it's not quite the same, and requires me to call updateMatrix twice (once after setRotateY and once for the body rotation). How does the engine do it?
(This post was last modified: 07-05-2011 10:07 PM by mystara.)
07-05-2011 09:56 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Make character look up/down from net input
engine does that like the "SDK/tutorials/animations/manual editing"

full character animation is in the Game::Chr class, so you can do:
1) experiment on your own
2) use Game::Chr for animating your character
3) use Game::Chr sources from the company license
07-07-2011 05:57 AM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #3
RE: Make character look up/down from net input
Well, using angle.x and angle.y, I got another step closer:

Code:
angle.x = angleXInterpolator(ANGLE_X_RECEIVED_FROM_SERVER);
angle.y = angleYInterpolator(ANGLE_Y_RECEIVED_FROM_SERVER);

Flt stop_move = stop_moveInterpolator(time);
Flt walk_run = walk_runInterpolator(time);
Flt idle_time = Time.time();
Flt move_time = Time.time()*0.68f;

cskel.clear()
.animate(stand, idle_time, (1-stop_move))
.animate(walk, move_time, (stop_move)*(1-walk_run))
.animate(run, move_time, (stop_move)*(walk_run))

cskel.updateVelocities();

However, whenever the character is walking or running, he seems to look up/down less than when he's standing still. The result is that when he stops walking or running the characters jerks around a bit.

My guess would be that the blend values aren't quite right, since he looks up/down more when he's standing still than when he's being animated. Not sure what these should be though. Is it just a matter of trial and error?
(This post was last modified: 07-09-2011 10:23 AM by mystara.)
07-09-2011 10:14 AM
Find all posts by this user Quote this message in a reply
mystara Offline
Member

Post: #4
RE: Make character look up/down from net input
Gaaaaaaaaaaaahhhhh!

Another 6 hours later, and I've finally found the bug.
It turns out that the default 'stand' animation for Warrior is stand2.anim.
I was manually loading stand.anim.

Hence why the character appeared to be bouncing when it walked/ran while looking up or down. It was using one animation when it was "nearly standing still" and another animation when it was "actually standing still".

For anyone else who's looking to solve this problem, the code I mention (above) should be fine, provided that you load the correct animations <groan>.
07-09-2011 04:32 PM
Find all posts by this user Quote this message in a reply
Post Reply