On Apr 25, 2012, at 10:35 AM, Vaibhav Vaidya wrote: > I have a character moving to-n-fro (along the Z-axis) in the scene. I have > written the following script for this. When I choose the run mode to server, > the script doesn't execute but when I switch to both (client and sever), > animation runs smoothly with the single client but when I connect multiple > clients, the animation is jerky. Am I missing anything simple?? or Is there > anything wrong with the
With this setup all the clients run it individually on the client side, and have their own opinion about the exact position, which they all communicate to the server which then replicates the changes to all the clients .. so it gets jerky. Correct is to do the modification only in one place, and have that replicate over the net. Either on the server or one of the clients. With this code you disable it on the server - don't do that, if you want to run it on a server :) > if (!server.IsRunning() && !framework.IsHeadless()) > { > StartAnimation(); > } ~Toni > var entityNameToFind = "UrbanMale."; > var animationNameToStart = "Walk"; > var availableAnims=0; > var delta = -0.005; > var s = 1; > > function StartAnimation() > { > var objectToAnimate = scene.GetEntityByName(entityNameToFind); > if (objectToAnimate != null && objectToAnimate.animationcontroller != > null) > { > if(availableAnims<=0) > > frame.DelayedExecute(1.0).Triggered.connect(StartAnimation); > > > availableAnims = > objectToAnimate.animationcontroller.GetAvailableAnimations(); > > var animFound = false; > for(var i=0; i<availableAnims.length; i++) > { > if (availableAnims[i] == animationNameToStart) > { > animFound = true; > break; > } > } > if (animFound) > { > > objectToAnimate.animationcontroller.EnableAnimation(animationNameToStart, > true); > > objectToAnimate.animationcontroller.SetAnimSpeed("Walk","0.6"); > } > > var trans = me.placeable.transform; > trans.pos.z = -5; > > trans.rot.x = 0; > trans.rot.y = 180; > trans.rot.z = 0; > > me.placeable.transform = trans; > frame.DelayedExecute(0.5).Triggered.connect(updatePosition); > > } > else > { > frame.DelayedExecute(1.0).Triggered.connect(StartAnimation); > } > } > > > if (!server.IsRunning() && !framework.IsHeadless()) > { > StartAnimation(); > } > > > function updatePosition(dt) { > var tm = me.placeable.transform; > > if(tm.pos.z >= -24 && tm.pos.z <= 2) > { > tm.pos.z += (s*delta); > } > else > { > tm.rot.y += 180; > tm.pos.z += (s*2); > s *= -1; > tm.rot.y %= 360; > } > me.placeable.transform = tm; > frame.DelayedExecute(0.01).Triggered.connect(updatePosition); > } > > > I have used the RigidBody component for the character (as well as terrain), > but I see the character legs getting into the terrain in high areas. How can > I make character clamp on the terrain?? > > Regards, > Vaibhav > > -- > http://groups.google.com/group/realxtend > http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org