Thank, it is an interesting way of doing the character movement direction from left to right. I got rid of all my code happening in FixedUpdate() fonction and use your solution. I did a test with just a moving cube and it is moving smoothly. My character with Rigidbody still have a little weird motion only when the second character Join, but it does look a lot better than before. Should I always use TNSyncRigidbody script with Rigidbody object? Currently I use it on my GamePlayer with Update Per Second at 1 only.
I am confuse about why you use if (!tno.isMine) instead of if (tno.isMine) and why we do move the target using the mDir value outside of if(tno.isMine) ? I understand the use of tno.isMine for Player but for Enemy should I use this as well if I don't want them to spawn in double.
I have to think differently about my jump code. What will be the best to sync for the jump? Should I sync the key Input.GetKeyDown, the position.y or the rigidbody velocity? What will happen if the character start to jump and the position is being sync in the middle of the jump, will the jump stop syncing? Should I sync as well the grounded and doubleJump state as well? I use something like this:
if(Physics.Raycast(thisTransform.position, raycastDir, 1f)) {
if(!grounded){
grounded = true;
doubleJump = false;
}
}else{
grounded = false;
}
if(Input.GetKeyDown("space")){
if(grounded)
rigidbody
.velocity = new Vector3
(0f,jumpHeight,0f
); if(!grounded && !doubleJump){
doubleJump = true;
rigidbody
.velocity = new Vector3
(0f,jumpHeight,0f
);}
I tried this solution and it seem to work
[RFC]
void SetPosY(float jumpHeight){
rigidbody
.velocity = new Vector3
(0f,jumpHeight,0f
); }
Tutorial 2 was very great to explain TNet, it would be great to do a video tutorial about the key press sync for character movement since it is a very different approach when we have to consider networking.
Thank!