Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: tcmeric on April 21, 2017, 01:20:41 PM

Title: Example Actions that Listen to Events with Return Arguments? [Solved]
Post by: tcmeric on April 21, 2017, 01:20:41 PM
I am trying to create a custom action that listens for a c# delegate event and returns an event argument (event payload). Unfortunately I am having some difficulty here. This is my first time working with unity delegates and events. If there are some playmaker actions that are already do this, maybe it will help me work it out.

This is the documentation here: https://vrtoolkit.readme.io/docs/vrtk_destinationmarker

And I am trying to get the event payload "Vector3 destinationPosition".

Title: Re: Example Actions that Listen to Events with Return Arguments? [solved]
Post by: tcmeric on April 24, 2017, 06:55:45 AM
Nevermind, I think I got it to work. Example for others if they run across this:

From VRTK snap zone.

Code: [Select]
public override void OnEnter()
{
var go = Fsm.GetOwnerDefaultTarget(gameObject);

snapEvents = go.GetComponent<VRTK.UnityEventHelper.VRTK_SnapDropZone_UnityEvents>();
if (snapEvents == null)
{
snapEvents = go.AddComponent<VRTK.UnityEventHelper.VRTK_SnapDropZone_UnityEvents>();
}

snapEvents.OnObjectEnteredSnapDropZone.AddListener(ObjectSnapped);

}

private void ObjectSnapped(object sender, SnapDropZoneEventArgs e)
{
snapZoneObject.Value = e.snappedObject;

}