Playmaker Forum

PlayMaker Feedback => Action Requests => Topic started by: Dev_Sebas on October 15, 2011, 04:10:16 PM

Title: Press any key
Post by: Dev_Sebas 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
Title: Re: Press any key
Post by: Alex Chouls 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
Title: Re: Press any key
Post by: Dev_Sebas 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
Title: Re: Press any key
Post by: Dev_Sebas on October 17, 2011, 05:10:18 PM
Can somebody help me?
Title: Re: Press any key
Post by: qholmes 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
Title: Re: Press any key
Post by: Dev_Sebas on October 19, 2011, 10:49:48 AM
I am question how to put a new action into Playmaker.
Thanks for any help
Title: Re: Press any key
Post by: qholmes 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
Title: Re: Press any key
Post by: Dev_Sebas on October 19, 2011, 11:00:23 AM
I am go try
Title: Re: Press any key
Post by: Dev_Sebas 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);
}
}

Title: Re: Press any key
Post by: qholmes on October 19, 2011, 12:46:25 PM
And did it work?

Q
Title: Re: Press any key
Post by: Dev_Sebas on October 19, 2011, 01:29:29 PM
No, it´s not working
Title: Re: Press any key
Post by: jeanfabre 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
Title: Re: Press any key
Post by: Dev_Sebas 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  
Title: Re: Press any key
Post by: qholmes 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
Title: Re: Press any key
Post by: Dev_Sebas 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