playMaker

Author Topic: Mobile controls with Photon - All players firing with one button[SOLVED]  (Read 700 times)

OddButAwesome

  • Playmaker Newbie
  • *
  • Posts: 46
    • View Profile
Hi all,

Working on a multiplayer twin stick shooter. Single player controls (LJoy -move direction and RJoy- firing direction) working great with on screen mobile joysticks.

Connecting to Photon. Players spawn correctly and move individually with their corresponding left joysticks, but on pressing  the right joystick (directional fire) both players shoot (my phone and another device and Unity testing). I followed a tute that used PhotonView.isMine (true/false) to stop the movement controls controlling both players with the left stick. This worked great. I thought that bullets may come under the same thing. I am probably way off.

Can anyone help with individual player shooting across the Photon network? I have looked on their forums as well (and am still searching).

My player object is structured:

PlayerN           //Parent object
 Player            //Player ship mesh
 Bullet01Gen   //Bullet spawner
Camera


Should I be using Crossplatform input on the right stick to activate the firing?

Any advice would be awesome. Even if you could point to a tute that may have helped you if you had a similar problem.

Thank you.

« Last Edit: December 09, 2015, 06:01:52 AM by jeanfabre »

OddButAwesome

  • Playmaker Newbie
  • *
  • Posts: 46
    • View Profile
Re: Mobile controls with Photon - All players firing with one button
« Reply #1 on: December 01, 2015, 07:02:17 AM »
If I am using photonView.isMine to turn on/off components - is there a way I can specify which FSM to turn on/off if there are more than one on an object?

Example below is how players controls are turned on/off:
 
if(photonView.isMine){
         myCamera.SetActive(true);
         GetComponentInChildren <Move_n_Rotate>().enabled = true;
         GetComponentInChildren <AudioListener>().enabled = true;

      }
      else{
         myCamera.SetActive(false);
         GetComponentInChildren <Move_n_Rotate>().enabled = false;
         GetComponentInChildren <AudioListener>().enabled = false;




When making a similar script for bullets it auto completes 'PlayMakerFSM' but doesn't show how I can specify if there are more than 1 FSMs on an object.

Thank you.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12344
  • Official Playmaker Support
    • View Profile
Re: Mobile controls with Photon - All players firing with one button
« Reply #2 on: December 01, 2015, 10:57:52 PM »
Hi,

 Indeed you need to ensure that every fsm on your player prefab is checking for "is Mine" flag, including your firing system, without this, you won't be able to make a difference and you'll end up controlling both players.

to turn off fsm, have a "meta" fsm sitting on your player, that knows about the other fsm and can enable/disable them other fsm components based on the "is mine".

 also, since when you instantiate a prefab it will always be either mine or not, and never change, you can simply have this logic on each fsm and they disable themselves basically, that works too.

 Bye,

 Jean

markfrancombe

  • Sr. Member
  • ****
  • Posts: 337
    • View Profile
Re: Mobile controls with Photon - All players firing with one button
« Reply #3 on: December 02, 2015, 01:01:30 AM »
Hi @OddBut Awesome

You probably need something like Im doing here
http://hutonggames.com/playmakerforum/index.php?topic=11746.0

As you can read its not completely working yet, note Im NOT disabling the component for the network player, I'm enabling it on the users player. Im also not doing bullet firing, but just the character control..

...but surely YOU must be doing this as well? cant you copy it for bullets?



OddButAwesome

  • Playmaker Newbie
  • *
  • Posts: 46
    • View Profile
Re: Mobile controls with Photon - All players firing with one button
« Reply #4 on: December 02, 2015, 02:48:26 AM »
Hi guys!

Thank you for the replies.

I will try later tonight @jeanfabre.

Yes @markfrancombe I am enabling/disabling the move controls on the networked players ships as you can see in the copy/pasted script in the 1st post entry. This worked a charm. This is why I found the firing not responding to the same technique.


Thanks again guys I will let you know how it goes.

OddButAwesome

  • Playmaker Newbie
  • *
  • Posts: 46
    • View Profile
Re: Mobile controls with Photon - All players firing with one button
« Reply #5 on: December 08, 2015, 06:33:23 AM »
Got it working.

Thanks guys.

Check the pic for fix. So simple, yet elusive to me.

One thing I am not sure of was I was getting the '1000 loops limit' error on the bullet gen FSM. I removed the connect from the 'Is not mine event' which was looping back to itself or the first Init state. The error is gone so it appears fixed.

On to reducing network player lag now :)