View Full Version : Tutorial Simple keypress detection in UDK using Kismet
CreativeCoding
04-28-2010, 12:07 AM
Well, there are a lot of tutorials here, I thought I would donate one of mine. It's up on my blog, but being nice, here it is:
1. Close UDK.
2. Open C:\UDK\(version)\UTGame\Config\UTInput.ini
3. ctrl+F, enter the key you want to edit. (in my case, it was the E key)
4. You should find something like this:
Bindings=(Name="E",Command="GBA_Use")
whereas the Name is the key you want,
5. Append the Command text with " | causeevent somethingyouwillremember" (I used epress for that)
6. It should look like this:
Bindings=(Name="E",Command="GBA_Use | causeevent epress")
7. In kismet, right-click on the grey area. Scroll over Misc and click on "Console Event"
8. Under console event's settings, check "Client Side Only?"
9. Replace the None in console event name to the "somethingyouwillremember" (so I put, epress there.)
10. Connect out with what you want done once the key is pressed.
Done. Now when you build, it should do what you connected it to once you press the key.
Troubleshooting:
Q: There is no binding thing for my key
A: Create one in this format:
Bindings=(Name="KEYLETTER",Command=" causeevent Thatlongassvariable")
Q: Nothing happens:
A: 1. Make sure you close UDK and open the UDK after saving the .ini file.
2. make sure you saved the .ini file
3. Make sure the letter is correct (try other things, such as E)
4. Make sure what the Console Event is connected to actually does something. Test this by connecting the level load event to it.
Mogget
04-28-2010, 01:01 AM
Awesome, thanks :D I am going to go try this out next time I get the chance
adityagameprogrmer
04-28-2010, 02:26 AM
would be more informative to change the topic name to reflect " In Kismet"
vixez
04-28-2010, 05:14 AM
Nice.
How would I append the keypress in UnrealScript, instead of Kismet?
CreativeCoding
04-28-2010, 06:50 PM
Nice.
How would I append the keypress in UnrealScript, instead of Kismet?
You mean have it do something within the script?
I have no idea. I don't know a lot about UnrealScript. Just the UDK in general.
*update*
We should sticky a thread with all of these tutorials... (and credit)
3Dforlife
05-04-2010, 12:20 AM
But it happens and dont stop .Ex : if i config the "E" key ,and in kismet i put the "E" key press output to turn on a light the light will be on forever. I want know how to press the key and stop when it is not pressed?
someone?
Psilocybe
05-04-2010, 12:29 AM
If you want to access a keybind in unrealscript, you define it just like he does here. For example:
Bindings=(Name="LeftShift",Command="Test")
In this example, this would bind the left shift key to a function "Test." So in your script, you would need to define a function "Test" by declaring "exec function Test()" and writing your code for what you want the key to do in there.
Thank you so much for posting this! I had no idea how to access keybinds from kismet.
Sweet :D
[edit] If you want a key to do something when it's released, you need to add the "OnRelease" keyword preceded by the pipe operator (|). eg, Bindings=(Name="LeftShift",Command="Test | OnRelease TestAgain").
CreativeCoding
05-04-2010, 01:46 AM
But it happens and dont stop .Ex : if i config the "E" key ,and in kismet i put the "E" key press output to turn on a light the light will be on forever. I want know how to press the key and stop when it is not pressed?
someone?
Simple. Just use toggle with the light as the target and connect the event to the 'toggle' in the toggle. That way, it will turn off of it's on, and on when it's off.
Do you get it?
h3ndy
05-04-2010, 09:33 AM
Thanks for the tutorial ^^
In this example, this would bind the left shift key to a function "Test." So in your script, you would need to define a function "Test" by declaring "exec function Test()" and writing your code for what you want the key to do in there.
Which script? Can any class use it?
Psilocybe
05-04-2010, 04:27 PM
I've only used it on scripts extended from gameplayercontroller so far, but I don't see why it would be a problem accessing keybindings from other scripts. I'm guessing that the core functionality for this is implemented in one of the base scripts such as object. The best way to find our is just test it though."`Log("Your text here");" to see whether your keybinding is working in the log.
3Dforlife
05-05-2010, 01:32 AM
Thatīs not what i mentioned , another example: If i keep the "W" key pressed will call a matinee animation but the animation only stop when i release the button (w key),and any moment that the w key isnt keeping pressed nothing happen. i try the onrelease stop but i failed. so teach me the right way (of onrelease)
CreativeCoding
05-05-2010, 08:50 PM
Thatīs not what i mentioned , another example: If i keep the "W" key pressed will call a matinee animation but the animation only stop when i release the button (w key),and any moment that the w key isnt keeping pressed nothing happen. i try the onrelease stop but i failed. so teach me the right way (of onrelease)
causevent wpress | onrelease causeevent wstop
That should work.
Now, connect the wpress event to the play of the matinee and wstop detector to the stop of the matinee...
So then, while you hold the W key, it will play the animation and when you release, it will trigger the onrelease that will stop the matinee...
robin64bit
05-06-2010, 05:20 PM
can you set this to left mouse click too?
CreativeCoding
05-06-2010, 06:51 PM
can you set this to left mouse click too?
Hmm... I'm not too sure. You will have to look around for what makes the gun shoot, then attach the causeevent to that.
Btw, they have weird names.
LMB = Left mouse button
MMB = Middle mouse button
RMB = Right mouse button
omegabluestudio
05-18-2010, 06:24 PM
This is great, i've been trying to figure this out for a while now. I need it to when pressed open a UIScene asking the player "do they want to quit" and pesent a few options. Its been driving me nute while testing my levels to go back to the main UDK UI.
CreativeCoding
05-19-2010, 06:17 PM
This is great, i've been trying to figure this out for a while now. I need it to when pressed open a UIScene asking the player "do they want to quit" and pesent a few options. Its been driving me nute while testing my levels to go back to the main UDK UI.
I know there is a topic that answers that floating around somewhere. I think it does something just like creating a menu so that when you press the button, it will open that level (aka, the exit menu) or switch back to regular gameplay.
taz1004
05-19-2010, 07:07 PM
Been looking for ways to do this and this opens up a whole new door for me. Works like a charm. Thanks.
CreativeCoding
05-20-2010, 12:13 AM
Been looking for ways to do this and this opens up a whole new door for me. Works like a charm. Thanks.
No problem...
I should probably rewrite that.
Look up how to create a menu.
DELUXEnized
05-30-2010, 09:10 AM
hello,
my kismet doesn't trigger any action i connect to the console event.
If I just add ONE console event, it prints the console event name and the event description on the screen, but doesn't trigger the connected action.
As soon as I add another (second) console event in kismet, it even doesn't show the event infos on the screen anymore.
In the log I can see that my commands are called when I press the binded button.
any suggestions?
CreativeCoding
05-30-2010, 03:12 PM
hello,
my kismet doesn't trigger any action i connect to the console event.
If I just add ONE console event, it prints the console event name and the event description on the screen, but doesn't trigger the connected action.
As soon as I add another (second) console event in kismet, it even doesn't show the event infos on the screen anymore.
In the log I can see that my commands are called when I press the binded button.
any suggestions?
Hmm... Are you using the new May version. Apparently, some things got moved arround. Try using the March version from now on until I post a fix.
tyrone70
06-14-2010, 09:17 PM
If you want to access a keybind in unrealscript, you define it just like he does here. For example:
Bindings=(Name="LeftShift",Command="Test")
In this example, this would bind the left shift key to a function "Test." So in your script, you would need to define a function "Test" by declaring "exec function Test()" and writing your code for what you want the key to do in there.
Thank you so much for posting this! I had no idea how to access keybinds from kismet.
Sweet :D
[edit] If you want a key to do something when it's released, you need to add the "OnRelease" keyword preceded by the pipe operator (|). eg, Bindings=(Name="LeftShift",Command="Test | OnRelease TestAgain").
sorry, just noticed your quote. thanx for this tut. i figured out how to do what i needed in kismet.
THANX!! 1 question though: how would you make it so that that button has to be held for a certain amount of time in Kismet itself?
Winwarproductions
06-21-2010, 02:26 PM
tyrone70
That's something I would like to figure out as well. Maybe you can add a delay or timer for if a key is pressed. It's just the way you set it up. Pretty much finding a node depicting an if statement, but connecting that if statement to the if key pressed node. Or a used statement. If this key is being used for 3 seconds then play etc. I just pondered this, and I might try it to see if it works later on. Kismet has a lot of useful things, I'm figuring out.
Everything is "if" to me. If this then that, so this only if this and that plays or stops. It's getting fun to me strangely, but I'm sure it an be done with the timing keys. You might have to script, but explore some more in kismet before you resort to that.
tyrone70
06-21-2010, 02:50 PM
i kind of figured it out. i'm not using a button press, but basically, the player has to stand in a spot for 3 second. if they movie from that spot, the timer gets set back to zero. however, if they stay there the whole 3 seconds, the next part will happen. i have a screenshot somewhere:
http://forums.epicgames.com/showthread.php?t=733137
Winwarproductions
07-02-2010, 08:46 AM
Hi. How can you cancel an event in UDK? Pretty much make it inactive at will. I'm talking about a console event. Is there anything in kismet I can hook up to it?
Winwarproductions
07-02-2010, 10:30 AM
Never mind, I figured it out. Whoohoooooooo! lol. Moving on.
tegleg
07-05-2010, 08:13 AM
hello thanks for this tutorial
how can i stop it from printing 'console events' on the screen?
taz1004
07-05-2010, 01:34 PM
hello thanks for this tutorial
how can i stop it from printing 'console events' on the screen?
Not sure if this is a proper way to fix it but it works. In UDKEngine.ini
[Engine.Engine]
bOnScreenKismetWarnings=true
Set it to false. Same value is also in "DefaultEngineUDK.ini" Change it as well if you want it to work when you package the game.
Rhodan
08-04-2010, 09:13 AM
Was there a way to do console events in the new builds of UDK?
I have the latest one, and I can't find a "console event" command in Kismet anymore (Ive used this method before, so i know it used to exist and used to work as per your method) and can't find a new way to do the same idea
onurbz
08-04-2010, 11:40 AM
Very Nice O.O
EnderFX
01-17-2011, 06:17 PM
Hi. How can you cancel an event in UDK? Pretty much make it inactive at will. I'm talking about a console event. Is there anything in kismet I can hook up to it?
Please could you post how you solved it?
Im trying to implement a HL-Style "use" key to open a door with a switch by using kismet.
I use a Trigger so when the player stands in the trigger area and presses the E key the door opens:
Bindings=(Name="E",Command="GBA_Use | causeevent PRESS_USE_KEY | onrelease causeevent UNPRESS_USE_KEY")
In Kismet, i use a boolean variable which is set to true with the console event press_use_key and then to false with unpress_use_key. However, as these events are not "dispatched", after releasing the E key this variable is always set to false, and never set back to true by pressing the E key, so i can only use the door switch once, which is not what i want :(
Jason Amstrad
03-04-2011, 02:43 PM
This,for example,worked for me:
Bindings=(Name="A",Command="GBA_StrafeLeft | causeevent DoSuperMove")
Bindings=(Name="D",Command="GBA_StrafeRight | causeevent DoBlastWave")
But there is a certain problem.
What if I wanted to have a causeevent for when I move my mouse to the left or right or up or down ?
udaya
03-18-2011, 06:45 AM
it's very nice and usefull,: but when i tried it in kismet i have been getting the following warning
[[kismet warning: obj StaticMeshActor_0 has no handler for UTseqACT_Move Actor]]:mad:
what i intended to do is move an actor when a key is pressed, i hav change the configuration but i guess there is something wrong in the way i have connected the event keypress with the other event.
It would be very nice if somebody helps me on that.
Jason Amstrad
03-21-2011, 06:00 PM
Static Meshes can not move.
Only InterpActors and KActors can move.
tomacmuni
04-20-2011, 08:53 AM
Never mind, I figured it out. Whoohoooooooo! lol. Moving on.
About canceling a console command at will, can you reiterate what you found out ... it seems useful. I'm lazy to try it myself I have to admit. If it is added to this thread it would be a nice way to tie it off.
joesan
05-23-2011, 06:03 AM
Since in May-2011 UDk already UTGame nor UTInput.ini exist I did the changes using UDKGame and UDKInput.ini.
I followed estrictly the tutorial including closing and re-starting UDk but I cannot seem to toggle a static mesh (hidden) that I had put in my map, however using a Touch Trigger did unhide the Mesh.
joesan
06-02-2011, 02:30 AM
I found out why id doesn't work changing the UDKInput.ini with the keyboard keys. YOU MUST MAKE THE CHANGES in DefaultInput.ini then save, then quit UDK running, relaunch and then the keys you program with CauseEvent work and also automatically males these changes in UDKInput.ini.
Dids5
10-07-2011, 06:18 AM
I followed the instructions and it worked :) Tyvm for that.
However I can't get it to work for the numeric keypad. I can't find what are the key names for these.
Does anyone know?
Dids5
10-09-2011, 03:58 PM
Found it :) : NumpadZero, Numpadone etc...
gosh it's hard to get started
ffejnosliw
10-09-2011, 04:04 PM
I followed the instructions and it worked :) Tyvm for that.
However I can't get it to work for the numeric keypad. I can't find what are the key names for these.
Does anyone know?
Found it :) : NumpadZero, Numpadone etc...
gosh it's hard to get started
All mappable key names are listed here:
http://udn.epicgames.com/Three/KeyBinds.html#Mappable%20keys
nemirc
10-24-2011, 05:37 PM
Set it to false. Same value is also in "DefaultEngineUDK.ini" Change it as well if you want it to work when you package the game.
I set that to false but I'm still getting the console event messages printed on the screen. Is there anything else that needs to be changed?
LucasWalter
12-05-2011, 12:52 AM
I am very new to kismet scripting and sorry if this is a stupid question, but is it possible to set this up in kismet.
I want a Matinee animation to play on a keypress, but I do not want it to be able to play on any part of the map, can I set it up so the trigger only works when the pawn is in a certain volume, or when the cross hairs are fixed on a certain location? Would this require Uscripting?
Lastly, instead of just the Matinee animation playing (Elevator Animation) How can I set it up to play an animation from the player (Pressing a button on the elevator, or pulling a lever instead of a lever just moving by itself)
In the lever instance, would I have to create an animation for the player that was synced with the lever being moved, or is there any other way I could do this?
Not trying to dwell on the lever animation questions, but is it also possible to lock or align the player directly in front of the lever when the key is hit so when the animation is played, it looks correct.
Lastly, if I am wanting to set up multiple interactive objects throughout my game, will I have to create a different "causevent" for each separate thing I want or can I make a function through Uscript that will determine what the action is, and then plays the correct animation and other stuff.
I apologize for all the questions, but I am pretty new and I know this is advanced stuff, but I like to dive head first into things. I am not asking on complete tutorials on how to do this, I would just like to be pointed in the right direction so I could figure out the rest.
nemirc
12-05-2011, 01:02 AM
Hi, I will try to answer your questions, but I don't know all of them.
1. You can create in UnrealScript an exec function (in your playercontroller class) that you can map to whatever key. The command to execute when the function runs would be something like "consolecommand (CE nameofaconsoleevent)" (not sure about the sintaxis here). Then you create in Kismet a "console event node" and it will fire every time you press the key, and thus executing the exec function. I hope this made sense... You can detect where your player is looking at, but I don't know how so I can't answer that.
2. You can, if you setup your custom character, animtree, and create the animation. You can use a "play anim" node that calls your custom animation (for example, the lever pulling animation) and sync that with the actual lever. You do need to set up (in UScrit) an animation handler that will get the Kismet stuff to work, though.
3. Yes, you can make the character move to the correct location (like when you tell Lara Croft to pull a lever and she kinda side steps or whatever). I tried a much simpler setup once, though, making the trigger small enough that you really need to be in certain position, and then "teleport" the character to the correct position, while doing a "cinematic camera move" at the same time, and playing the animation. The combination of those three actually hide the "popping teleport" just fine :)
The thing is you do need at least some basic UScript knowledge for this (as well as some knowledge on character setup and stuff). There are some nice tutorials here about custom characters, and also I'd really recommend you checked Geodave's tuts on custom characters, and UDKCentral's tutorials on AnimTrees.
LucasWalter
12-05-2011, 07:42 AM
Thank you very much for your help I am really happy that you showed me gave me some advice. It was very useful.
I think I have a solution for the crosshair thing I mentioned. I know you can do traces and I saw a video where he setup tracing from the eyes in third person. So I will have to look into that.
raycornea
08-31-2012, 05:39 PM
Hello,I have the July 2012 version and it dosen't work here..
Tried with letters words,placed the new keybiddings in defInput,then deleted the UdkInp,and relaunched UDK.When i press the key nothing happens.Tried the same thing directly in the kismet created a console cmd and named it,then in game,taped in the console"ce Z"(Z was the used letter),yet nothing happened.
Seems like the signal's lost in the console event itself
Oh,and just to mention,in each case above i was getting in console the suggestions with my comands(ex.:"ce H,ce L...")
--------------
EDIT:
Ok,figure'd it out,everything works as assumed,and i'm very pleased with this technique,just what i needed
Solution: Players Only should be disabled ...(probably cause i'm doing a freecam game)
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.