Problem with the physics of the Ball
Options
A beginner's doubt!
I hace a ball and a player 2. When player 2 kicks the ball it does not move.
A ball has: PhotonView, TransformView, Rigidbody2DView.
With the player 1 the kick work.
What is missing? Is there an example with a ball?
I hace a ball and a player 2. When player 2 kicks the ball it does not move.
A ball has: PhotonView, TransformView, Rigidbody2DView.
With the player 1 the kick work.
What is missing? Is there an example with a ball?
0
Comments
-
Hello,
In my game to share the ball's movement on the network i add a script to it.
And in this script i have the "OnPhotonSerializeView" and you use it like how you manage your player movement.
in my game:
OnPhotonSerializeView :Vector3 syncPositionBall = Vector3.zero; Vector3 syncVelocityBall = Vector3.zero; if (stream.isWriting) { stream.SendNext(transform.position); stream.SendNext(rigb.velocity); } else { syncPositionBall = (Vector3)stream.ReceiveNext(); syncVelocityBall = (Vector3)stream.ReceiveNext(); syncTime = 0; syncDelay = Time.time - lastSyncTime; lastSyncTime = Time.time; syncEndPosition = syncPositionBall + syncVelocityBall * syncDelay; syncStartPosition = transform.position; }
and in the FixedUpdate() :if (!GetComponent<PhotonView>().isMine) { syncTime += Time.deltaTime; transform.position = Vector3.Lerp(syncStartPosition, syncEndPosition, syncTime / syncDelay); }
and of course add this script and the rigidbody component to the PhotonView.1 -
Thank you so much. A doubt, doing this code do I have to keep the TransformView and Rigid2d View?
I'll follow this code. However, is this the only way to do it?
I attached the form I was making. That way it should not work?
0 -
If you use the script you don't need to put the component because they should do the same work.
But i dont exactly know how work the component because i had trouble with the rotation of my players while using them.
the other way would be with the component like you did , but like i said earlier I don't really know how they are working.
0