- Home /
This question was
closed Apr 05, 2020 at 05:32 PM by
GGWP-senpai for the following reason:
Got New Update
Question by
GGWP-senpai · Apr 05, 2020 at 12:03 PM ·
photonnetworkplayer
PhotonNetwork Position, rotation is not sync after force of other client.
i have tried to move a player using movement script, it was fine. but if other client collide or force the other client, it makes the gameobject is not sync.
public class PlayerMovement : MonoBehaviour
{
private PhotonView pv;
private CharacterController myCC;
public float walkSpeed = 2;
public float runSpeed = 4;
public float rotationSpeed;
float speed;
public FixedJoystick leftjoystick;
public FixedButton button;
Quaternion targetRotation;
// Start is called before the first frame update
void Start()
{
pv = GetComponent<PhotonView>();
myCC = GetComponent<CharacterController>();
leftjoystick = (FixedJoystick)FindObjectOfType(typeof(FixedJoystick));
button = (FixedButton)FindObjectOfType(typeof(FixedButton));
}
// Update is called once per frame
void Update()
{
if (pv.IsMine)
{
if (button.Pressed)
{
speed = runSpeed;
}
else
{
speed = walkSpeed;
}
BasicMovement();
BasicRotation();
}
}
void BasicMovement()
{
Vector3 targetDirection = new Vector3(leftjoystick.input.x,0, leftjoystick.input.y);
myCC.Move(targetDirection * Time.deltaTime*speed);
if (Input.GetKey(KeyCode.W))
{
myCC.Move(transform.forward * Time.deltaTime * speed);
}
if (Input.GetKey(KeyCode.A))
{
myCC.Move(-transform.right * Time.deltaTime * speed);
}
if (Input.GetKey(KeyCode.S))
{
myCC.Move(-transform.forward * Time.deltaTime * speed);
}
if (Input.GetKey(KeyCode.D))
{
myCC.Move(transform.right * Time.deltaTime * speed);
}
}
void BasicRotation()
{
//targetRotation = Quaternion.Euler(0, angle, 0);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
}
}
im using observe component and observe Photon Transform View but still not sync any movement by force (Only input from client is observed).
302400.jpg
(299.7 kB)
Comment
Answer by GGWP-senpai · Apr 05, 2020 at 04:28 PM
Should i using photonSerialization and CharacterController is the stream?
Follow this Question
Related Questions
Can't see other player over the network 0 Answers
OnPhotonSerializeView sync is so lag 0 Answers
Problem with networking in photon 0 Answers