playMaker

Author Topic: Playmaker With Other Scripts  (Read 3306 times)

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
Playmaker With Other Scripts
« on: May 22, 2016, 06:59:25 PM »
I have been looking over videos and the various ways to use other scripts with Playmaker but I can't seem to get my scripts to do anything with playmaker. I have some scripts that allow me to pick up an object in VR. These scripts have functions that state the object is currently being grabbed or used. How would I use this to move through states in Playmaker? I am totally new to all of this so excuse my ignorance.

I can see how to make things happen with mouse buttons or keys but not my VR controller.

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • Online Playmaker Courses
Re: Playmaker With Other Scripts
« Reply #1 on: May 22, 2016, 08:09:58 PM »
Hey dude,

With your VR controller, you could create custom playmaker actions which send an event when the object is grabbed or being used.

The send event option is what you are after.

Do you have a copy of the code you are trying to turn into an action?
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Playmaker With Other Scripts
« Reply #2 on: May 22, 2016, 08:16:46 PM »
I have all the code but not sure if I want it to be an action or not? Could the code be easily converted into an action for playmaker?

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • Online Playmaker Courses
Re: Playmaker With Other Scripts
« Reply #3 on: May 22, 2016, 08:26:09 PM »
Depends on how your code is setup. But I create actions for all my code.
I just find it helps streamline everything.

But if you wanted to transition a playmaker state from code, you would need to send the FSM and event.

So you would create some custom events on your states. Then from your code, you would send those events to the FSM, which would trigger the states to move from one to the other.

This video should show you how to do what your after:
https://www.youtube.com/watch?v=g-C-6O10CNo&list=PLC759306A1E692A10&index=13
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Playmaker With Other Scripts
« Reply #4 on: May 22, 2016, 08:36:39 PM »
Thanks for the help. I have watched that video a dozen times now and I still don't get it. So is it possible to say make a cube, my current script knows when I am using this cube and then fire off some playmaker states?

I can have trigger presses from my controller do things like generate objects, but I can't seem to say, pull controller trigger on cube A and make cube B rotate in playmaker. I have done this in my own script by hacking pieces together but I would like to extend it a bit with timers and I can't seem to get that.

For instance, this code does the following. Pull trigger on cube, and four cubes move. Walls and a roof. This code was hacked together by me using some other code.

Code: [Select]
using UnityEngine;
using System.Collections;

public class activatecube: SteamVR_InteractableObject {
Transform rotator;
Transform rotator1;
Transform rotator2;
Transform rotator3;
Transform rotator4;
public float timer = 2;
private float yspeed = 0f;
public float timer1 = 3;

public override void StartUsing(GameObject usingObject)
{
base.StartUsing(usingObject);
yspeed = .003f;
}

public override void StopUsing(GameObject usingObject)
{
base.StopUsing(usingObject);
yspeed = .003f;
}

protected override void Start()
{
base.Start();
rotator = this.transform.Find("Capsule");
rotator1 = this.transform.Find("square2");
rotator2 = this.transform.Find("square3");
rotator3 = this.transform.Find("square4");
rotator4 = this.transform.Find("square5");
}

// Update is called once per frame
void Update ()
{
rotator.transform.Translate(new Vector3(0f, 0f, yspeed));
rotator1.transform.Translate(new Vector3 (0f, yspeed, 0f));
rotator2.transform.Translate(new Vector3 (0f, yspeed, 0f));
rotator3.transform.Translate(new Vector3 (0f, yspeed, 0f));
rotator4.transform.Translate(new Vector3 (0f, yspeed, 0f));
}
}

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • Online Playmaker Courses
Re: Playmaker With Other Scripts
« Reply #5 on: May 23, 2016, 12:45:25 AM »
Hey dude,

I made you a video. You can find it here:

http://jonathanoduffy.com/playmaker-forum-q-a-playmaker-with-other-scripts/

Hopefully it helps you out. You can also look at how Playmakers GUI proxy is setup. It shows how to go from a system into a playmaker friendly one. Might be helpful for your VR stuff.
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

stitchlips

  • Playmaker Newbie
  • *
  • Posts: 18
Re: Playmaker With Other Scripts
« Reply #6 on: May 23, 2016, 01:08:09 AM »
Wow! That was totally cool of you to go through all that effort to help me. Thanks a lot! I will dig into your video and try your suggestions with my project. Again, you went above and beyond. Thanks!

joduffy

  • Full Member
  • ***
  • Posts: 121
  • Here to help
    • Online Playmaker Courses
Re: Playmaker With Other Scripts
« Reply #7 on: May 23, 2016, 01:50:21 AM »
Anytime dude  :)
Glad I could help.

Let me know how you go with it.
- Jonathan

Online Playmaker Courses available at:
http://courses.jonathanoduffy.com

“I want the world to be a better place because I was here.”  -  Will Smith

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Playmaker With Other Scripts
« Reply #8 on: May 24, 2016, 09:36:30 PM »
While the video was not aimed at me, I did find it helpful as an easy solution to go between C# and Playmaker. Clear instructions.  Thanks for the contribution!