Skip to content

Instantly share code, notes, and snippets.

@johro
Created July 3, 2015 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johro/cbcc78163ac4ac8cc3f6 to your computer and use it in GitHub Desktop.
Save johro/cbcc78163ac4ac8cc3f6 to your computer and use it in GitHub Desktop.
PUN 移動
using UnityEngine;
using System.Collections;
public class PlayerController : Photon.MonoBehaviour {
private Rigidbody rb;
private float speed = 100;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
if(photonView.isMine){
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
Vector3 move = new Vector3(x,0,z).normalized*Time.deltaTime*speed;
this.GetComponent<PhotonTransformView>().SetSynchronizedValues(speed: move, turnSpeed: 0);
rb.velocity = move;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment