Created
July 3, 2015 10:56
-
-
Save johro/cbcc78163ac4ac8cc3f6 to your computer and use it in GitHub Desktop.
PUN 移動
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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