Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mmomaker · Feb 07, 2015 at 10:07 AM · movementplayerbugphoton

photon player movement

Hi guys my name is cuddle bunny and me and a few friends are working on a 2d top down social mmo like club pengrin but we have hit a wall and none of us can figure out how to fix it Here is are movement scrip

 using UnityEngine;
 using System.Collections;
 
 public class PlayerMovement :MonoBehaviour
 {
 public float speed = 1f;
 
 void Start()
 {
 
 }
 
 void Update()
 {
 if(Input.GetKey(KeyCode.D))
 transform.position += new Vector3(speed *Time.deltaTime,0.0f,0.0f);
 
 if(Input.GetKey(KeyCode.A))
 transform.position -= new Vector3(speed *Time.deltaTime,0.0f,0.0f);
 
 if(Input.GetKey(KeyCode.W))
 transform.position += new Vector3(0.0f, speed *Time.deltaTime,0.0f);
 
 if(Input.GetKey(KeyCode.S))
 transform.position -= new Vector3(0.0f, speed *Time.deltaTime,0.0f);
 }
 }

the problem we are having is wean some one move their player it move every one else on the person screen but on every one else screen that person dint mover every one and is moved to the rite place that they wanted to go the only way we have found to fix this is to have the other player move to up date the others screen but then that person get the bug how can we fix this were it doesn't do this any more

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mmomaker · Feb 09, 2015 at 08:00 PM 0
Share

we are using the photon cloud if that help out a biy

avatar image AevinGames · Feb 09, 2015 at 08:18 PM 0
Share

Have u added Photon View onto your player??? Photon View syncs the players screens with others. So they see what happens.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by ryan_unity · Feb 10, 2015 at 03:42 PM

Hey Cuddle Bunny,

Make sure there is a PhotonView attached to each player and use photonView.isMine to make sure you only control your own player.

 void Start() {
     enabled = photonView.isMine;
 }

OR

 void Update() {
     if (photonView.isMine) {
        // movement code
     }
 }

This is a common problem newcomers have when creating a multiplayer game: http://answers.unity3d.com/questions/313706/controlling-the-wrong-client-with-photon-cloud.html http://answers.unity3d.com/questions/289119/network-problem-moving-the-wrong-player.html http://answers.unity3d.com/questions/439600/photonview-controlling-multiple-fps-controllers.html

I hope this helps :)

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mmomaker · Feb 10, 2015 at 08:31 PM 0
Share

um thanks ther one more qretshon why is it saying that

Assets/playermovement.cs(10,27): error CS0103: The name `photonView' does not exist in the current context

her is my script

 using UnityEngine;
 using System.Collections;
 
 public class Player$$anonymous$$ovement :$$anonymous$$onoBehaviour
 {
     public float speed = 1f;
     
     void Start()
     {
         enabled = photonView.is$$anonymous$$ine;
     }
     
     void Update(){
         if (photonView.is$$anonymous$$ine) {
         if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.D))
             transform.position += new Vector3(speed *Time.deltaTime,0.0f,0.0f);
         
         if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.A))
             transform.position -= new Vector3(speed *Time.deltaTime,0.0f,0.0f);
         
         if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.W))
             transform.position += new Vector3(0.0f, speed *Time.deltaTime,0.0f);
         
         if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.S))
             transform.position -= new Vector3(0.0f, speed *Time.deltaTime,0.0f);
         }
     }
 }

avatar image ryan_unity · Feb 11, 2015 at 11:28 AM 0
Share

There are multiple ways to fix this, for instance changing the inheritance:

 public class Player$$anonymous$$ovement : Photon.$$anonymous$$onoBehaviour {

Or just declaring this and linking it in the inspector:

 public PhotonView photonView;

It seems you might be getting confused by some basic program$$anonymous$$g and Unity principles. I highly recommend checking out some tutorials and perhaps making some simpler games/projects before an $$anonymous$$$$anonymous$$O. It will make program$$anonymous$$g a lot easier :-)

Useful links: - http://www.3dbuzz.com/ - http://doc.exitgames.com/en/pun/current/tutorials/photon-unity-and-networking-links - https://unity3d.com/learn/tutorials/modules/beginner/scripting

avatar image
0

Answer by mast3rillusion · Feb 20, 2015 at 05:14 AM

  • This-

public class PlayerMovement :MonoBehaviour

  • needs to be this-

public class PlayerMovement :Photon.MonoBehaviour

  • also u need to add a new method-

void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (stream.isWriting) stream.SendNext(rigidbody.position); else rigidbody.position = (Vector3)stream.ReceiveNext(); }

here is a good tutorial so u can understand better.

http://www.paladinstudios.com/2014/05/08/how-to-create-an-online-multiplayer-game-with-photon-unity-networking/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Photon Network Movement Delay 1 Answer

Photon Networking Player Control Issue 1 Answer

Bug. Player can't move. 3 Answers

AI behaviour in 3D game, general help needed 2 Answers

Implement moveSpeed to this object script? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges