Search Maya Zest



Tuesday, November 30, 2021

Find the Playmaker FSM That is Turning Off a Game Object

 Issue: 

A Game Object is getting turned off by a Playmaker FSM somewhere, is there a way to find a reference to the FSM or Action doing it?


Answer:

There are a few ways to track down this kind of info.

If the deactivated gameobject has an FSM that's receiving an event to deactivate itself you can right click on the event in the Debug Log to see who sent the event.

If it's just an FSM deactivating an object it's a little more difficult. It's probably the result of an Activate Game Object action, so I would right click that action in the Action Browser to see everywhere that action is used. Then start using the log or breakpoints to narrow it down further.

You could also pause the game right after the object is deactivated and examine the FSM logs for likely candidates.


This was from: https://hutonggames.com/playmakerforum/index.php?topic=4425.0

Reposting here to be easier for myself to find and maybe could help others too as it took a while of searching to get the right keywords to answer this.



Monday, November 29, 2021

Send Event from Normcore Realtime component string to Playmaker FSM

This may look complicated but it's not as bad as it looks, let me break down the pieces it consists of.

1. The realtime Component model script (That contains a string we want to sync to all players)

2.The "sync" script that reads the model string value, updates the realtime model if you or the other player updates it and then communicates that change to the other players.

3.A FSM event script that contains the event we will send to playmaker. We will activate that FROM the sync script.

Let's get started!

We are going to create a way to send an event to a playmaker FSM to tell it when a realtime component string has changed. Normcore sends it's own events but currently I don't know how to get them to talk to playmaker FSM's.

First make the script that will be the model called SelectedResourceModel for the realtime component string. our string is called "selectedResource"

  using System.Collections;

using System.Collections.Generic;
using UnityEngine;

using Normal.Realtime.Serialization;
using Normal.Realtime;

[RealtimeModel]
public partial class SelectedResourceModel

{

    [RealtimeProperty(1, reliable: true, createDidChangeEvent: true)]
    private string _selectedResource;
}

Once that is created, you can compile that model script in the right of the inspector when you select that model script.


 

Now when that is compiled you can create the sync script that will talk to the model to sync the realtime component string. selectedResource. The script is called SelectedResourceScript

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Normal.Realtime;
using TMPro;


public class SelectedResourceScript : RealtimeComponent
{

    private SelectedResourceModel _model;
    //public RealtimeAvatarManager _avatarManager;
    private TextMeshProUGUI _selectedResourceText;
    public string selectedResourceCustom;

   

    //public ResourceStringUpdatedScript resourceStringUpdatedScript;
   

    private void Awake()
    {
            //get the reference to the selectedResource textygame object
        _selectedResourceText = GetComponent <TextMeshProUGUI>();
    }

    private SelectedResourceModel model
    {
        set
        {

            if (_model != null)
            {
                //unregister from events
                _model.selectedResourceDidChange -= SelectedResourceDidChange;
            }
        //store the model
            _model = value;

            if (_model != null)
            {
                //Update the selectedResource to match new value
               UpdateSelectedResourceText();
                // register for events so we'll nkow if the selectedResource chagnes later
                _model.selectedResourceDidChange += SelectedResourceDidChange;
            }
           
        }

    }

     private void SelectedResourceDidChange(SelectedResourceModel model, string value )
     {
            UpdateSelectedResourceText();
         

     }

     private void UpdateSelectedResourceText()
     {
         _selectedResourceText.text = "" + _model.selectedResource;
     }

     public string GetSelectedResource()
     {
         return _model.selectedResource;
     }

 

        public void SetSelectedResource(string selectedResourceCustom)
    {
        _model.selectedResource = _model.selectedResource = selectedResourceCustom;


    }    

   
}

So in this script you can see the method  private void SelectedResourceDidChange

Inside this method where we can run a method in another script to send the FSM event when it detects that the realtime component did change.

Now we need to create the textmeshproUI text for this script to go onto. The script above will sync the value of the realtime string model and update the text to the value of the model. This will let both players see the same string. 

So create a textmeshUI pro gameobect (if it's not UI then you will have to modify the script above for NOT UI textmeshpro)

Now drop the SelectedResourceScript.cs onto that textmeshproUI.

Now we need to create a little script that will actually send an FSM event WHEN the script we just made updates the text. Called ResourceStringUpdatedScript.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PlayMaker;

public class ResourceStringUpdatedScript : MonoBehaviour
{




     public PlayMakerFSM myFSM;

    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    public void ResourceUpdateString()
    {
          myFSM.SendEvent("ResourceStringUpdated");
    }
}

This will send an event to the FSM called ResourceStringUpdated. Now drop this script onto the text mesh pro game object as well. 

We created a method called ResourceUpdateString

We can now RUN this method in the SelectedResourceScript when the text is updated, and it will ALSO send our FSM event upon updating.

Add a playmaker FSM to the textmeshpro object also. What you have should look kind of like this.

MAKE SURE YOU ALSO HAVE A REALTIME VIEW on that textmeshproUI as well or the realtime component WILL NOT WORK PROPERLY.


Drag the FSM into the FSM field on your ResourceStringUpdatedScript slot for MyFSM

Now all that is left is to add the Method called ResourceUpdateString from our ResourceStringUpdatedScript. To get to the method in the other script we just add this line of code.

GetComponent<ResourceStringUpdatedScript>().ResourceUpdateString();

This shows how we add it to the DidChange Method

   private void SelectedResourceDidChange(SelectedResourceModel model, string value )
     {
            UpdateSelectedResourceText();
            GetComponent<ResourceStringUpdatedScript>().ResourceUpdateString();

     }

Now in the FSM that is on that TextmeshProUI game object. You can create and event that will fire.

Add an event with the same name as the event in the script ResourceStringUpdated


That's it! Now when your realtime changes it will automatically also fire the event in your playmaker FSM!


Friday, November 26, 2021

Setting up VRIF with Normcore in Unity

Basic idea to set up VRIF interaction framework to work with normcore goes like this.

You need the Realtime + VR player prefab which comes with the normcore install dropped into your scene and the XR rig Advanced which comes with the VRIF install.

1. Now that they are in your scene expand out the XR rig advanced so you can see the hand anchors.



2. Then the Normcore Realtime + VR player should be in the main scene with it as well.

3. Now click on the Realtime + VR player so you can get to it's Realtime Avatar Manager script in the inspector on the right.

4. Now drag the items from the XR rig advanced in the hiarchy to the Realtime Avatar Manager like so ( The script should be active, not Deactivated like in my screen grab)


The VR player is the normcore Prefab Avatar that will get instantiated automatically when you connect to a normcore room. Basically that local XR rig "puppets" the Normcore prefab Head and Hands using the transforms you linked in that Realtime Avatar Manager script.

Anything in the Normcore VR player prefab is what other players will see when you connect to a room, anything that is in the XR rig will just be visible to you locally.

Now we need to put a copy of the VRIF hands into the VR player prefab so that the other players can see them.

1. Open up the VR player prefab. 

2. From your project drag the XR rig prefab into your VR player so that you can get to some items that are inside of it. UNPACK that XR rig prefab that you have pulled in so you can reparent items. 

3.  Once you have UNPACKED that XR rig prefab and it's sitting there for you to work with. expand the hiarchy  
XR Rig Advanced>PlayerController>CameraRig>TrackingSpace

4. You should see the Right hand anchor, select that and drag it ( and of course all it's children are coming with it) and place it under the Right hand hiarchy of your VR player. 


5. Now do the same with the left handanchor.

6. You would place any head models you want the other players to see under the head game object in the VR player and a torso would go as a child of the head (with a script or playmaker to cause it to follow the head)



Note with this setup when you grab you will see the other player grab as well because VRIF doesn't know it isn't you grabbing. To fix this you need to disable the grabber game object in the VR player if the grabber isn't on your local computer. We will get into that more in a future tutorial.





Monday, November 15, 2021

50% OFF playmaker and VRIF right now!

 This sale only happens once or twice a year so it's worth grabbing these if you have been interested in them before!

Playmaker is a MUST if you want to learn game development, even if you know some programming it will make your life SOO much easier and can work hand in hand with your programming scripts. 


1. PlayerMaker ($60 for $30!)

Thursday, November 4, 2021

Three free unity assets! Till November 8th

 



I just bumped into this myself might as well grab it while you can!
Love hate, fingers and resize pro for free till November 8th!