- Home /
Smooth transform
I'm writing MMORPG game. Every seconds clients send their coordinates to my server and then server pushes it to another clients. So my problem is - how i can create smooth transform? Here is my client code:
transform.Translate(Vector3.forward * Time.deltaTime, transform.Find("Compas"));
It's totally okay for me. but when i tried to use that code for another players it doesn't work for me. Here is my code for another players:
anotherplayer = GameObject.Find(updatexml.players[i].username);
anotherplayer.transform.Find(anotherplayer.name + "_compas").LookAt(new Vector3(updatexml.players[i].x_coordinate, updatexml.players[i].y_coordinate, updatexml.players[i].z_coordinate));
anotherplayer.transform.Translate(Vector3.forward * Time, anotherplayer.transform.Find(anotherplayer.name + "_compas"));
p.s. that job is running as coroutine.
Answer by StephanK · Apr 18, 2010 at 09:32 AM
FIrst of all using Find() is supposed to be really slow, so using it in an update method (or coroutine) is not recommended. You should probably think about updating the positions of the client's more than once per second. In any case you'd have to use some kind of movement prediction for the frames between those updates. One way to do this is to determine the last known velocity of the player, move it accordingly and correct errors after the next position update.
what should i use ins$$anonymous$$d of Find() ? Create hashtable? Updating more that 1 time per second is a bad idea.
kThat's what i want, but i have no idea how to do it...ind of movement prediction for the frames between those updates.
As I said, simplest way of doing it would be to store the last known velocity of each object/player on the server and as long as you don't have a new position move the player with that velocity.
Answer by Xenland · May 14, 2011 at 04:34 AM
You could use the Lerp command or MoveToward commands to answer your question
Your answer
