Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 airbagnr1 · Feb 15, 2018 at 03:52 PM · networkingphotonjoystickvirtual

Photon Virtual Joystick won't work after another player has joined the network...?

But basically for the movement for my players im using a virtual joystick but for some reason it only works when there is only 1 person on the network. But the person can still move around with the WASD keys. So im really not sure what is going on with it? Bearing in mind that the first player can still move around with the virtual joystick just now any other player but the joystick image does update when the other players move the joystick, just the movement is being applied for some reason? Any help would be amazing!

Here is my code for the joystick positioning but i dont think it is an error with that:

 public virtual void OnDrag(PointerEventData pointerData)
     {
         Vector2 position = Vector2.zero;
         if (RectTransformUtility.ScreenPointToLocalPointInRectangle
             (backgroundJoyStickImage.rectTransform, pointerData.position,
             pointerData.pressEventCamera, out position))
         {
             //Sets the position of the joystick
             position.x = (position.x / backgroundJoyStickImage.rectTransform.sizeDelta.x);
             position.y = (position.y / backgroundJoyStickImage.rectTransform.sizeDelta.y);
 
 
             ///<summary>
             /// If the joystick is positioned on the right then times the postion and add,
             /// if its on the left then times 2 and minus 1
             /// </summary>
             float x = (backgroundJoyStickImage.rectTransform.pivot.x == 1) ? position.x * 2 + 1 : position.x * 2 - 1;
             float y = (backgroundJoyStickImage.rectTransform.pivot.y == 1) ? position.y * 2 + 1 : position.y * 2 - 1;
 
             inputDirection = new Vector2(x, y);
 
             inputDirection = (inputDirection.magnitude > 1) ? inputDirection.normalized : inputDirection;
 
             joyStickImage.rectTransform.anchoredPosition = new Vector2(inputDirection.x * (backgroundJoyStickImage.rectTransform.sizeDelta.x / 3), inputDirection.y * (backgroundJoyStickImage.rectTransform.sizeDelta.y / 3));
         }
     }

and here is the code when im applying it to the player movement script:

    void MovementControls()
     {
         float inputHor = Input.GetAxis("Horizontal");
         float inputVer = Input.GetAxis("Vertical");
 
         Vector2 movement = new Vector2(inputHor, inputVer);
         float angle = Mathf.Atan2(inputVer, inputHor) * Mathf.Rad2Deg;
 
         if(playerJoyStick.inputDirection != Vector2.zero)
         {
             print("ad i here?");
             movement = playerJoyStick.inputDirection;
             print("This is movement" + movement);
         }
 
         playerBody.velocity = movement * speedAmp;
         currentVelocity = movement * speedAmp;
     }


So yea, im really unsure why the other players who join the network cant move using the joystick. Any help would be greatly appreciated!

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by airbagnr1 · Feb 16, 2018 at 02:31 PM

Actually solved my self and was so obvious and simple, forgot to use If(photonview.isMine) when I was Instantiating the canvas piece...

Comment
Add comment · Show 3 · 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 sjaavik1 · Aug 01, 2018 at 05:00 PM 0
Share

@airbagnr1 I have the same issue, seems like when player enter the network, they share the same canvas? and virtual joystick. seems to be ok in the editor, but on the iPhone its controlling both players in a weird way. So how do you Instantiate the canvas on if(photon view.is$$anonymous$$ine) and stil both players can use the canvas... :-0 maybe a stupid question, i don't know.. thanks.

avatar image Mbahri58 · Sep 11, 2018 at 02:59 PM 0
Share

Can you write the script

avatar image Sriram360 · Dec 05, 2020 at 01:58 PM 0
Share

could you attach the script plz

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

120 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Photon Virtual Joystick Problem HELP???? 1 Answer

Unity PhotonNetwork globally enable a component 1 Answer

[Photon]Player vs. Player Collision 0 Answers

how do i apply damage to objects other that the player 1 Answer

Photon - character not moving after next Scene Load 0 Answers


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