Using and Not Using

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

b00z3r

At least you dont live with me!
Mar 18, 2002
6
0
0
39
BLAH
www.geocities.com
Ok, Ive searched and searched and cannot seem to find anything on "using" an actor.

Im new at this so bear with me.

Code:
//===========================================================
//Placeable Actor that allows for testing code
//===========================================================

class FX extends Actor placeable;

var int FXvar;
var Pawn pawnX;

event Timer()
{
 FXvar++;
 log("FXvar="$FXvar);
}

function Touch ( Actor Other )
{
 log("you just touched!");
 pawnX=Pawn(Other);
 setTimer (1.0, true);
}

function UnTouch (Actor Other )
{
 log("you just untouched!");
 pawnX=none;
 setTimer (0, false);
 FXvar=0;
}


defaultproperties
{
 FXvar=0
 bCollideActors=true
}

As you can see, this simple actor will just log out a count when I touch it, and reset when I untouch it. Now I want it to count when I use it, not touch it. But, I want it to count while I am using (holding down my use button). Any pointers would be awesome.
 

Mychaeel

New Member
The UsedBy function (declared in Actor) is called when an actor is "used" (using the "use" console command or a key bound to it).

You can start following the chain of execution which leads to this call by looking up "exec function Use" in PlayerController. It calls ServerUse (replicated from clients to server in online games), which then iterates over all actors the player's Pawn is currently touching and calls the UsedBy function on each of them.
 

Mychaeel

New Member
Well, there simply is no concept of "stopping to use" something -- you can only press your "use" key, but there's no "stop using" key, is there?

You could have the player press "use" again when they wish to stop using the actor (just like they have to to leave a vehicle).
 

b00z3r

At least you dont live with me!
Mar 18, 2002
6
0
0
39
BLAH
www.geocities.com
Im just throwing idea(s) out not knowing exactly how to implement them into my code. But how about a check to see if the actor is actually being used by a pawn. If pawn = none then stop.

The hitting the use key twice wouldnt work if I wanted a progress type of actor where progress would be made by using it fluidly. Like welding or cutting for example...
 

MKhaos7

Member of Clan |UED|
Apr 14, 2004
37
0
0
43
Brasil
I see what you want...
But, while i can not help you dire'ctly with coding, i think that some mods (like SAS or NeoTokyo) use this schemme for they "plant/defuse the bomb" game types. Maybe you could check their code (LOTS of code i know, but its a start :))
 

Mychaeel

New Member
If you want to get notified when a player presses or releases a key, you have two options:
  • Bind a key to "Use | OnRelease UnUse" and implement the "UnUse" exec command.
  • Use an Interaction. (With some smart coding you can even find out which key the user has bound to the "Use" command and automatically use that key instead of hard-coding one.)