Pointers on syncing animation?

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

User avatar
Whiskey
Posts: 45
Joined: 28 Oct 2010, 06:27
Location: The Netherlands
Contact:

Pointers on syncing animation?

Postby Whiskey » 04 Nov 2010, 08:54

I just started learning Unity and SmartFox and the tutorials provided are extremely helpful. So thanks for that (can't wait for the SFS2X demo :wink: ).

However, I am now playing around with the Island demo and have replaced the frog character with a standard Unity model (the construction worker). For the local player it works fine (3rd person), but the remote player animations are not happening. I couldn't find anything in the tutorials on this, so maybe someone here can give some pointers on what I need to do to get the animations for the remote players to play? Currently the remote player floats and flickers or disappears when idle. I'm using Unity3.
User avatar
Whiskey
Posts: 45
Joined: 28 Oct 2010, 06:27
Location: The Netherlands
Contact:

Postby Whiskey » 04 Nov 2010, 13:48

Just figured it out. Originally the demo works with the FPS walker script. Because I switched to a 3rd person view with the corresponding script, the "Sendmessage" commands that are in the FPS walker scripts were no longer being fired. After adding these to the 3rd person script, for example SendMessage("PlayAnimation", "walk"); the animations are playing :D

I still have a problem that when the remote player is idle, the model flickers "on and off", so any suggestions for that are still welcome.
lastowl
Posts: 36
Joined: 12 Aug 2010, 20:56

Postby lastowl » 04 Nov 2010, 15:21

what do you mean by on and off
User avatar
Whiskey
Posts: 45
Joined: 28 Oct 2010, 06:27
Location: The Netherlands
Contact:

Postby Whiskey » 04 Nov 2010, 15:47

That the remote player is mostly not visible if he is not moving
lastowl
Posts: 36
Joined: 12 Aug 2010, 20:56

Postby lastowl » 04 Nov 2010, 19:57

ahh, basically your only send transformations not the original position thats why its invisible, if i could see the code you've adapted from the fpswalker script i can help futher
User avatar
Whiskey
Posts: 45
Joined: 28 Oct 2010, 06:27
Location: The Netherlands
Contact:

Postby Whiskey » 05 Nov 2010, 06:38

I changed the "// ANIMATION sector" part in the script ThirdPersonController.js
I just added the SendMessage lines

Code: Select all

   // ANIMATION sector
   if(_animation) {
      if(_characterState == CharacterState.Jumping)
      {
         SendMessage("PlayAnimation", "jump");
         if(!jumpingReachedApex) {
            _animation[jumpPoseAnimation.name].speed = jumpAnimationSpeed;
            _animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampForever;
            _animation.CrossFade(jumpPoseAnimation.name);
         } else {
            _animation[jumpPoseAnimation.name].speed = -landAnimationSpeed;
            _animation[jumpPoseAnimation.name].wrapMode = WrapMode.ClampForever;
            _animation.CrossFade(jumpPoseAnimation.name);            
         }
      }
      else
      {
         if(controller.velocity.sqrMagnitude < 0.1) {
            _animation.CrossFade(idleAnimation.name);
            SendMessage("PlayAnimation", "idle");
         }
         else
         {
            if(_characterState == CharacterState.Running) {
               _animation[runAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, runMaxAnimationSpeed);
               _animation.CrossFade(runAnimation.name);   
            }
            else if(_characterState == CharacterState.Trotting) {
               _animation[walkAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, trotMaxAnimationSpeed);
               _animation.CrossFade(walkAnimation.name);   
            }
            else if(_characterState == CharacterState.Walking) {
               _animation[walkAnimation.name].speed = Mathf.Clamp(controller.velocity.magnitude, 0.0, walkMaxAnimationSpeed);
               _animation.CrossFade(walkAnimation.name);   
               SendMessage("PlayAnimation", "walk");
            }
            
         }
      }
   }
   // ANIMATION sector
User avatar
Whiskey
Posts: 45
Joined: 28 Oct 2010, 06:27
Location: The Netherlands
Contact:

Postby Whiskey » 05 Nov 2010, 14:10

Figured this one out now too. I had removed the FPS references and scripts a while back, thinking this was only used to show fps on the screen. But seems it is also used for the interpolation stuff. I put it back and the flickering is gone now.

Got something else now though: input from remote players is delayed. When the remote player moves around, the local client is still updating long after the remote player stopped moving. Also, as soon as the remote player stops moving (i.e. pressing a button), the walk animation in the local client stops, but the player object is still moving/floating around.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Nov 2010, 14:39

Units are moved with interpolation. This means that they are always lagging behind as an average of the last X transforms.

If you want super accurate movement of other players, you need to look into prediction and extrapolation.

Not that simple - so unless you are making a FPS, then you dont need these things. For most chat worlds and RPGMMO type things, interpolation is good enough.
User avatar
Whiskey
Posts: 45
Joined: 28 Oct 2010, 06:27
Location: The Netherlands
Contact:

Postby Whiskey » 06 Nov 2010, 08:52

Thanks for the explanation. I don't need super accurate movement, but I still think something is wrong.

Ill try to explain. The longer the remote player moves, the longer it will take for the local client to update his position after he stops moving. For example, if the remote player would run 3 circles around the local player and then stops moving, the local player would only have seen him make one circle. The other two circles are then completed without walk animation and will continue for seconds after the remote player stopped.

I have never seen this with the island demo and the delay seems way to big to be normal. FYI, I have written down my first steps with Smartfox and Unity in thistutorial. I'll try to put an example online, but something crashes the webplayer.

Update: I think the crash is related to Unity3, because after compiling with Unity3, the Island demo crashes also (even with prefetching the socket policy).

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 1 guest