playMaker

Author Topic: How to call a method? Got the code, don't know how to use in Action  (Read 1368 times)

Kubold

  • Junior Playmaker
  • **
  • Posts: 99
    • View Profile
Hi, I can't code at all, so I use PlayMaker. The downside is I can't really ask Valve support for help. Here's the situation:


There's this SteamVR_Controller script to get Haptics on Vive working. On the top of this script there's a warning:

"! no monobehaviour scripts in the file or their names do not match the file name". I can't attach this script to a game object. I asked how to use it and got this answer:


"SteamVR_Controller.Input((int)m_steamVRTrackedObject.index).TriggerHapticPulse(Convert.ToUInt16(duration* 1000f));

m_steamVRTrackedObject = the SteamVR_TrackedObject component on controller
duration = duration of hatic pulse (float)"



My best guess is this may be used with "Call Static Method" Action...? Because that is the only Action which accepts the scripts name. But from there, nothing I try works.

Can you help me with this and tell me exactly what do I do with it?



The script comes from SteamVR plugin: https://www.assetstore.unity3d.com/en/#!/content/32647

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: How to call a method? Got the code, don't know how to use in Action
« Reply #1 on: March 22, 2016, 11:48:59 AM »
Try using Invoke Method- the scripts methods should show up in the popups like this


You can also try Send Message or set/get property-

The action to use depends on what you are trying to do- send the script a variable? Run a function? Get a variable from it?
« Last Edit: March 22, 2016, 11:53:18 AM by mdotstrange »
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Kubold

  • Junior Playmaker
  • **
  • Posts: 99
    • View Profile
Re: How to call a method? Got the code, don't know how to use in Action
« Reply #2 on: March 22, 2016, 12:05:14 PM »
As I understand, I need to send this line of code:

"SteamVR_Controller.Input((int)m_steamVRTrackedObject.index).TriggerHapticPulse(Convert.ToUInt16(duration* 1000f))"

to this script:

SteamVR_Controller.cs


This script is NOT on any GameObject. It is in my Project, but I can't drag and drop it to any GameObject (and that is how it is supposed to be, as Valve told me). I can't select a Game Object that this Behaviour is on, becasue ...I don't know, it is not a behaviour or something? I need to send this line of code directly to the script that is in my Project, but not in my Scene, as I understand.

Same with Get/Set - it seems to work only on scripts that are MonoBehaviours and connected to a GameObject.


In attached .jpg you can see how this script looks like (or just download the SteamVR plugin form Asset Store to see). Please help!
« Last Edit: March 22, 2016, 12:10:31 PM by Kubold »

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: How to call a method? Got the code, don't know how to use in Action
« Reply #3 on: March 22, 2016, 12:43:02 PM »
Oh ok- seems you'll need a custom action for it most likely-
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Kubold

  • Junior Playmaker
  • **
  • Posts: 99
    • View Profile
Re: How to call a method? Got the code, don't know how to use in Action
« Reply #4 on: March 22, 2016, 01:38:12 PM »
Oh ok- seems you'll need a custom action for it most likely-

I was hoping maybe ScriptControl Actions could do something like that. Seems like it's easy as pie for everyone on Vive devs forum, so nobody really elaborates on how to do it. There is of course no documentation on this at all, you are supposed to get it from reading the scripts. :)

It's a bucket of cold water. Making games with PlayMaker is easy and fast for a non-programmer, until you run onto something like that.

mdotstrange

  • Hero Member
  • *****
  • Posts: 549
    • View Profile
    • Can't code? Who cares! Make games anyway!
Re: How to call a method? Got the code, don't know how to use in Action
« Reply #5 on: March 22, 2016, 01:43:24 PM »

It's a bucket of cold water. Making games with PlayMaker is easy and fast for a non-programmer, until you run onto something like that.

Yeh I know that feel- If you could get some of the C# code the other dev's are using to do what you are trying to do I could have a look and see if I can make an action for it- I'm VERY NEW to coding and making actions though  :)
Indie game dev and instructor at the Strange School. Learn Playmaker at the Strange School!

Kubold

  • Junior Playmaker
  • **
  • Posts: 99
    • View Profile
Re: How to call a method? Got the code, don't know how to use in Action
« Reply #6 on: March 22, 2016, 01:57:54 PM »

It's a bucket of cold water. Making games with PlayMaker is easy and fast for a non-programmer, until you run onto something like that.

Yeh I know that feel- If you could get some of the C# code the other dev's are using to do what you are trying to do I could have a look and see if I can make an action for it- I'm VERY NEW to coding and making actions though  :)

This I can do. I found an example project for Vive implementation. It works very well, and right controller vibrates constantly, when it is intersecting with a rigid body (pickable) object. I guess it is triggered by this script (if I turn it off it stops vibrating):

https://github.com/TomorrowTodayLabs/NewtonVR/blob/master/Assets/NewtonVR/NVRHand.cs


I examined this script and did not find anything that could be related to Haptics though, so I might be mistaken.