playMaker

Author Topic: Press any key  (Read 9072 times)

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Press any key
« on: October 15, 2011, 04:10:16 PM »
There is this script
// Detects if any key has been pressed down.

function Update() {
    if(Input.anyKeyDown)
        Debug.Log("A key or mouse click has been detected");
}

Who can make it ready to use in PlayMaker?
Thanks for any help
Bye

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Press any key
« Reply #1 on: October 15, 2011, 07:17:59 PM »
There is an Any Key action that ships with playmaker:
https://hutonggames.fogbugz.com/default.asp?W29

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #2 on: October 16, 2011, 04:25:04 AM »
Thank you Alex
Just for I know what I need for put my scripts in PlayMaker?
Bye

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #3 on: October 17, 2011, 05:10:18 PM »
Can somebody help me?

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Press any key
« Reply #4 on: October 19, 2011, 10:46:13 AM »
Are you asking how to put a new action into Playmaker or how to use the Any Key action that is already there?

Q

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #5 on: October 19, 2011, 10:49:48 AM »
I am question how to put a new action into Playmaker.
Thanks for any help

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Press any key
« Reply #6 on: October 19, 2011, 10:58:10 AM »
Well what i do is use MonoDevelop that comes with Unity and i paste the code from the website into it and then save the file into the \Assets\PlayMaker\Actions\ folder... I actually put a folder in there called Custom for all my home made or down loaded ones..

Make sure you call the file the same as the Public Class name in the file.. I think it will throw an error if you do not but i cant remember.. Anyway it helps regardless..

And you can not have two Actions with the same Public Class name. So if you have a custom version of something that already exists then i usually just call it something else that tells me what i changed.. And that way when you update PlayMaker you do not loose your changed version.. I had that happen to me once too.

Does that help?

Q

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #7 on: October 19, 2011, 11:00:23 AM »
I am go try

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #8 on: October 19, 2011, 11:33:26 AM »
I tried this
Code: [Select]
public class AI : FsmStateAction;

var turnSpeed : float = 5;
var speed : float = 10;
var distanceToGo : float = 5;
var leftOrRight : boolean = true;

function Update () {
if(Input.GetKeyDown(KeyCode.E)){
if(leftOrRight)
leftOrRight = false;
else
leftOrRight = true;
}

var hit : RaycastHit;
var fwd : Vector3 = transform.forward;

if(Physics.Raycast(transform.position, fwd, hit, distanceToGo)){
if(leftOrRight)
transform.Rotate(Vector3.up, 90 * turnSpeed * Time.smoothDeltaTime);
else
transform.Rotate(Vector3.up, -90 * turnSpeed * Time.smoothDeltaTime);
}
else{
transform.Translate(Vector3.forward * speed * Time.smoothDeltaTime);
}
}


qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Press any key
« Reply #9 on: October 19, 2011, 12:46:25 PM »
And did it work?

Q

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #10 on: October 19, 2011, 01:29:29 PM »
No, it´s not working

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Press any key
« Reply #11 on: October 20, 2011, 01:14:35 AM »
HI,

 the best way to start is to study the actions shipped with playmaker. understand how the "template" for cusotm work and then you'll be able to build your own , very, very easily.

 So for example in your attempt, you miss the namespace declaration "namespace HutongGames.PlayMaker.Actions "  and the "using UnityEngine;" that needs to be declared prior that


 I leave you do some research a bit more :) shout when you're stuck again and I'll make a working example of your script.

Bye,

 Jean

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #12 on: October 20, 2011, 04:48:12 PM »
Hi Jean thanks for reply
I thought the Playmaker can read my scripts easily
But I very very noob on scripts and I can´t write
If you can make me a example of this script I´am very appreciated and thanks
Bye  

qholmes

  • 1.2 Beta
  • Hero Member
  • *
  • Posts: 509
Re: Press any key
« Reply #13 on: October 20, 2011, 10:11:45 PM »
Well i learned from nothing by looking at the existing scripts... Everything you need is there. If you took an existing script that was close and attempted to implement your own code in it that would be a great step then someone can help you fix any issues with it.

Q

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Press any key
« Reply #14 on: October 21, 2011, 12:48:52 PM »
Thanks by the tip qholmes
Yes you are right about "took an existing script that was close and attempted" thanks again
Bye