Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

rigidbody2d sync problem!

$
0
0
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!

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>