playMaker

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kropcke

Pages: [1]
1
Hi Jean.

Per your suggestion, I'm applying my player/collider script to the green rectangular trigger, and rewrote it to account for 'GetMouseButtonDown/Up'. It almost works...

When I click the trigger on the server, the red box turns green on both the client and the server. Hooray! This part is working  :) However, when I click the trigger on the client - nothing happens and both boxes stays red.

I would like the box to turn red on both the server and the client, regardless who clicks it.

Here's my code:

Code: [Select]
using UnityEngine;
using UnityEngine.Networking;
using HutongGames.PlayMaker;

public class MouseDownYes : NetworkBehaviour
{


    void Start()
    {
    }

    [ClientCallback]

    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            RpcMouseDownYes();
        }

        if (Input.GetMouseButtonUp(0))
        {
            RpcMouseDownNo();
        }
    }

    [ClientRpc]

    public void RpcMouseDownYes()
    {
        Debug.Log("Pressed primary button.");

        FsmInt globalVar = FsmVariables.GlobalVariables.FindFsmInt("var_tr_1a");
        globalVar.Value = 1;
    }

    [ClientRpc]

    public void RpcMouseDownNo()
    {
        Debug.Log("Pressed primary button.");

        FsmInt globalVar = FsmVariables.GlobalVariables.FindFsmInt("var_tr_1a");
        globalVar.Value = 0;
    }

}

I'm not sure if my Playmaker setup is screwy, or if the scripting to support it is. I feel like I'm really close, but I'm not sure how to tackle the problem. Any advice would be really appreciated. Thanks so much already for all your help.

Sincerely,
kropcke

2
Hi Jean.

Thank you so much for your response.

The global variable is definitely propagating across the network when I update its value using colliders. However, what you point out is interesting with regards to both clients listening for the mouseclick, and that there might be conflicts there.

The object that responds to 'mouseclicks' is the same spawnable prefab that the colliders interact with. Its just that colliding with it will update the global variable across the network, but 'mouseclicking' it will not.

The movement script that handles the orange ball (which collides with the spawnable prefab) uses CLientCallback and Command to handle network behaviors. I guess this might be the difference?

Will keep looking.

Thanks again!
-Scott

3
PlayMaker Help / Networking global variables via collisions VS. mouseclicks
« on: December 04, 2018, 09:37:02 AM »
Hi All.

I have a question about networked global variables, and setting them ingame via collisions VS. mouseclicks.

For my network test, the LAN Host is running inside my Unity Game window, while  a build of that scene is connected to it using LAN Client. The orange ball on the left is controlled by the LAN Host (on the left), and the orange ball on the right is controlled via the LAN Client (on the right). (see below)



When I move either ball into the green rectangular trigger, the global variable var_tr_1a is set to '1'. The red box at the bottom turns green whenever var_tr_1a is set to '1'. The global variable var_tr_1a is responding to collisions via the 'Trigger Event' Action in an FSM within the orange ball. (see below)



I also have the green rectangular trigger set to respond to Mouse Pick Events, specifically Mouse Down and Mouse Up. This is also achieved through an FSM in the green trigger. In the screenshot below, I'm mouseclicking on the green rectangular trigger in the LAN Client to the right. The global variable var_tr_1a only gets set to '1' here. You can see the value of var_tr_1a is still '0' on the LAN Host to the left. (see below)



At this point, I feel like I'm heading a bit too far down the rabbit hole and am losing track of what changes I'm making really matter in helping to resolve this: updating global variables across the network using both collision (which is working) and mouseclicks (which is currently not working).

  • the orange ball, the green trigger, and the red/green square are all prefabs that I'm spawning
  • they all have a network identity (that has been set and reset to every combination of local and server authority I can think of)
  • my network manager is spawning the orange ball as the player prefab
  • the green trigger and red/green square are both registered spawnable prefabs
  • the eventMouseUp and eventMouseDown events on the green trigger are global events, and I Broadcast All using a Send Event action in its FSM
  • the orange ball prefab has a player script attached to it that is not associated with an FSM. It has some ClientCallback and Command calls that I'm not familiar with, but am wondering if this is affording the orange ball something that the other two prefabs are missing out on?

Please let me know if you have any ideas, or if there's something else I haven't yet considered that you think I should give a shot. I really appreciate any advice you might be able to share.

Sincerely,
kropcke

Pages: [1]