rigidbody2d sync problem!

Hi.
I am working 2d running game.
In game, there are lots of obstacles which players get killed if they touch them.

but i have a sync issue.
while running and jumping, In my scene i look other player doesn't die if they touch obstacle (like passing through obstacles) or suddenly die even if they didn't touch obstacles. it looks tiny difference but really important in this game.

i searched but i can't get any answer. please help me to syncronization my game!

i am moving my character using rigidbody2d velocity.

======

here is parts of my movement script :


private void Update()
{
if (photonView.isMine)
{
InputMove();
InputJump();
}

flip();
}

void flip()
{
if (_rigidbody2d.velocity.x >0 )
{
transform.localScale = new Vector3(1f, 1f, 1f);
_canvas.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);


}
else if (_rigidbody2d.velocity.x < 0)
{
transform.localScale = new Vector3(-1f, 1f, 1f);
_canvas.transform.localScale = new Vector3(-0.01f, 0.01f, 0.01f);

}
}

void InputMove()
{


Vector2 movementVelocity = _rigidbody2d.velocity;

if (CnInputManager.GetAxisRaw("Horizontal") > 0.5f)
{
movementVelocity.x = _moveSpeed;

}
else if (CnInputManager.GetAxisRaw("Horizontal") < -0.5f)
{
movementVelocity.x = -_moveSpeed;
}
else
{
movementVelocity.x = 0;
}

_rigidbody2d.velocity = movementVelocity;
_anim.SetBool("isWalk", Mathf.Abs(_rigidbody2d.velocity.x) > 0.1f);
}

void Jump()
{
_rigidbody2d.velocity = new Vector2(_rigidbody2d.velocity.x, 0f);
_rigidbody2d.AddForce(Vector2.up * _jumpPower);

}

=====

then, in photonview
there are three onserved component.
Transform, rigidbody2d, animation.

In transform
only check syncronize position

interpolation : lerp
lerp speed : 10
Extrapolation : disabled

In rigidbody

only check syncronize velocity.


do i have to add some thing on my script? or do i have to change the setting of the photonview?
please help me!
Thanks for reading long question!

Comments

  • is it not recommendable to use character movement by rigidbody?

    if it is ok, then do i have to delete Transformview on the photonview observed component and add character movement script on it? i am so confused TT
  • Hi @Senma,

    there is a documentation page about that topic. Please have a look at Lag Compensation and see if this helps you.