![]() |
|
|
#1 |
|
Registered User
Join Date: May 2006
Posts: 7
|
Hi
Im an artist (in the traditional sense of the word). My past work involved using UT's AI to draw portraits (link to pics) Im doing my best to understand Unrealscript but my head is literally throbbing trying to fix a problem, any help would be greatly appreciated! Heres what I got, I followed a tutorial that created a mutator and an interaction class. (the mutator , the interaction) At the moment when you press a particular key (like x) it will right "you pressed x" in the log file. What I want to happen is when you press (say x) the code will find movers with the tag "move 1" and make them move. Code:
Class keyinteract_inter extends Interaction;
Function Initialize()
{
Log("Interaction Initialized");
}
function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
{
local Mover M;
if ((Action == IST_Press) && (Key == IK_F))
{
Log("you pressed F");
foreach AllActors(class'Mover', M, move1)
{
Log("I at the very least found a mover with that tag");
}
}
return false;
}
DefaultProperties
{
bActive=True
}
what should I do? |
|
|
|
|
#2 |
|
Wicked Slick!
Join Date: May 2003
Posts: 778
|
ViewportOwner.Actor in Interaction is a PlayerController, you can use that as reference actor. E.g.
Code:
foreach ViewportOwner.Actor.AllActors(class'Mover', M, move1) |
|
|
|
|
#3 |
|
Registered User
Join Date: May 2006
Posts: 7
|
Thank you for the suggestion!
unfortunately I still get a compiler error saying: call to "allactors" bad expression or missing with the following code Code:
local Mover M;
if ((Action == IST_Press) && (Key == IK_F))
{
Log("you pressed F");
foreach ViewportOwner.Actor.AllActors(class'Mover', M, move1)
{
Log("I at the very least found a mover with that tag");
}
}
|
|
|
|
|
#4 | ||
|
<insert custom title>
Join Date: Aug 2002
Posts: 1,242
|
What is that "move1" in there?
__________________
Wormbo's Homepage Also visit Wormbo's Area on UnrealAdmin.org Got cheats you want to leak anonymously to the "Antis"? Submit them to the UTAN R-Team Share your editing knowledge: Unreal Wiki - The Unreal Engine Documentation Site Quote:
|
||
|
|
|
|
#5 |
|
Registered User
Join Date: May 2006
Posts: 7
|
its supposed to be the tag? i think
I got this off the wiki... AllActors (class<Actor> BaseClass, out Actor Actor, optional name MatchTag) If you specify an optional MatchTag, only includes actors which have a "Tag" variable specified I only want the code to find a specific mover, this mover has the tag "move1" |
|
|
|
|
#6 | ||
|
<insert custom title>
Join Date: Aug 2002
Posts: 1,242
|
If you want to hard-code the tag name, you need to write it as a name literal, i.e. enclose the value in single quotes.
__________________
Wormbo's Homepage Also visit Wormbo's Area on UnrealAdmin.org Got cheats you want to leak anonymously to the "Antis"? Submit them to the UTAN R-Team Share your editing knowledge: Unreal Wiki - The Unreal Engine Documentation Site Quote:
|
||
|
|
|
|
#7 |
|
Registered User
Join Date: May 2006
Posts: 7
|
wow!
your a star! I can now press a key and the relevant mover will be found, I get a lovely message in my log file saying "mover 2 found" thank you. Now for the second part of the conundrum, how do I make my mover... move. it has 2 key frames 'key 0' and 'key 1'. i attempted this Code:
local Mover M;
if ((Action == IST_Press) && (Key == IK_F))
{
Log("you pressed F");
foreach ViewportOwner.Actor.AllActors(class'Mover', M, 'move1')
{
Log("mover 1 found");
M.GotoState('key 1');
}
}
any ideas? |
|
|
|
|
#8 |
|
Registered User
Join Date: Aug 2005
Posts: 124
|
My guess is you want to call Triggered() on the relevant actors. (he says, posting without being able to refer to the source, again)
|
|
|
|
|
#9 |
|
Registered User
Join Date: May 2006
Posts: 7
|
Thanks, Ive been looking at the whole trigger thing but am having major difficulties.
Im not even sure I should have the code as it is. There is a console command called: Causeevent <eventname> and thats exactly what I need, I just need to cause an event, the event will move my mover. Code:
if ((Action == IST_Press) && (Key == IK_F))
{
Log("you pressed F");
//CAUSEEVENT move1?
}
Is it possible to turn a console command into something that will work here? |
|
|
|
|
#10 |
|
aka jeff wilson
Join Date: Dec 2004
Location: Kansas
Posts: 105
|
I think maybe what you are looking for is this function in Actor:
Code:
simulated event TriggerEvent( Name EventName, Actor Other, Pawn EventInstigator )
{
local Actor A;
local NavigationPoint N;
if ( EventName == '' )
return;
ForEach DynamicActors( class 'Actor', A, EventName )
A.Trigger(Other, EventInstigator);
For ( N=Level.NavigationPointList; N!=None; N=N.NextNavigationPoint )
if ( N.bStatic && N.Tag == EventName )
N.Trigger(Other, EventInstigator);
}
|
|
|
|
|
#11 |
|
Registered User
Join Date: May 2006
Posts: 7
|
Thank you! but Im sorry it just dosnt work.
Or at least it dosnt work how I tryed it. I just dont understand a word of it. I dont know how to fit it in. Is there no simple way of causing an event to happen from within an interaction class? Im getting so desperate now Ive started looking at macro editors that will automatically bring the console down and type in "causeevent move1" based on a specific keypress. (only problem with that is the macros cause UT to crash!) deary me, my poor little movers arent fulfilling their potential. |
|
|
|
|
#12 |
|
Registered User
Join Date: Aug 2005
Posts: 124
|
A quick 101:
you already know that when you cause an event, every actor with the tag matching the event name will be triggered. What you probably haven't realised is that all that happens when you cause an event is that something steps through all the actors just like your loop does, compares event name with tag and calls Triggered() on the actor if it matches. ffejnosliw posted the function that actors use to cause an event. I'd guess that this is exactly the code that happens when you CAUSEEVENT at the console. The reason you have the problem is that Interaction is not an actor, so it doesn't have AllActors, nor does it have TriggerEvent. My suggestion would be to have the playercontroller run the TriggerEvent, thus: Code:
if ((Action == IST_Press) && (Key == IK_F))
{
Log("you pressed F, triggering an event");
ViewportOwner.Actor.TriggerEvent('move 1',ViewportOwner.Actor,None);
}
|
|
|
|
|
#13 |
|
Registered User
Join Date: May 2006
Posts: 7
|
thank you all! a million times over!
Thanks NakedApe, for showing me the viewport thingy! Thanks Wormbo for seeing the error with the ' ' ! Thanks ffejnosliw for showing me the relevant trigger code! Thanks Sweavo for explaining it and showing me how to impliment it! thank you thank you! (needless to say it is now all working!) |
|
|
|
| Thread Tools | |
| Display Modes | |
|
|