- Home /
Question by
eslam980XD · May 25, 2020 at 11:48 PM ·
c#2d2d game2d-platformer2d sprites
My 2D Player Can't Move (2d Photon Game) :(,My Player Don't Move (2d Character Controller
I am new in unity , and i am working in Online 2d game with Photon I was following a online Course but I stuck with my 2d player controller heres the code *using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using System;
public class MyPlayer : MonoBehaviourPun, IPunObservable { public PhotonView pv;
public float moveSpeed = 10;
public float jumpforce = 800;
private Vector3 smoothMove;
void Updata()
{
if (photonView.IsMine)
{
ProcessInputs();
}
else;
{
smoothMovement();
}
}
private void ProcessInputs()
{
var move = new Vector3(Input.GetAxisRaw("Horizontal"), 0);
transform.position += move * moveSpeed * Time.deltaTime;
}
private void smoothMovement()
{
transform.position = Vector3.Lerp(transform.position, smoothMove, Time.deltaTime * 10);
}
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.IsWriting) { stream.SendNext(transform.position); } else if (stream.IsReading) { smoothMove = (Vector3) stream.ReceiveNext(); } }
}
there are a problem the character doesn't move or even do anything plz help me ,
Comment