Recording movement directions (Issue for UGOLD)

Discussions about Coding and Scripting
Post Reply
FSM
Novice
Posts: 3
Joined: Wed Dec 05, 2018 11:16 am

Recording movement directions (Issue for UGOLD)

Post by FSM »

So, keeping it short here. I managed to find a way to log the movement directions using booleans and some some of the original Unreal PlayerPawn code. The issue i've run into is the script returning false if I am not using the Fire() function to log the variables, and what I'm shooting for is to have this code successfully log inside a regular movement function.

bMoveForward = (bWasForward ^^ (aBaseY > 0));
bMoveBackward = (bWasBack ^^ (aBaseY < 0));
bMoveRight = (bWasLeft ^^ (aStrafe > 0));
bMoveLeft = (bWasRight ^^ (aStrafe < 0));

So basically, whenever I put this code in the Fire() alongside boolean logging, it accurately logs my movement keys when being pressed and held down. However, if I try and execute this code in a movement function instead, it only shows bMoveForward and bMoveBackward returning true. Does anyone know what the issue is?
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: Recording movement directions (Issue for UGOLD)

Post by ANUBITEK »

You don't want to put that sort of thing into movement code. Instead either make an attach actor and give it an actor check then run a tick() with debug code inside or run it through a class extending PlayerPawn.

You could make a debug button that deletes the actor or at least toggles tick() in the second actor if you do that method, plus you could eventually start moving some code from that into a HUD so you can make a debug HUD instead of worrying about using log().

The following is good enough for testing. I believe this event runs for any input, but it could also run for every tick, I'm not sure, haven't coded in a while in UnrealScript.
Spoiler

Code: Select all

event PlayerInput( float DeltaTime ) {
	[YOUR CODE HERE]
	aStrafe += aBaseX; // Side to side movement by default
	aForward += aBaseY; // Forward movement by default

	if (bWasForward ^^ (aBaseY > 0)) { log( string( aBaseY) ); } // Log Forward
	elif (bWasBack ^^ (aBaseY < 0)) { log( string( aBaseY) ); } // Log Backward
	if (bWasLeft ^^ (aStrafe > 0)) { log( string( aStrafe) ); } // Log Left
	elif (bWasRight ^^ (aStrafe < 0)) { log( string( aBaseY) ); } // Log Right
}
whoops i said node like 4 times in my other post, Godot on the brain lol
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
FSM
Novice
Posts: 3
Joined: Wed Dec 05, 2018 11:16 am

Re: Recording movement directions (Issue for UGOLD)

Post by FSM »

Sounds good, I'll give it a shot tonight. Probably the only thing I don't know how to do is toggle tick(), but I'm assuming that has been done already by Tim Sweeney in some of his code. I'll let you know how this all goes. :rock:
User avatar
ANUBITEK
Adept
Posts: 261
Joined: Sun Dec 28, 2014 1:10 am
Location: Anubitek

Re: Recording movement directions (Issue for UGOLD)

Post by ANUBITEK »

I need to clarify that the playertick code needs to go into the playerpawn extension, as playerpawn has the function and not any actors I am aware of.
<<| http://uncodex.ut-files.com/ |>>

Code reference for UGold, UT99, Unreal2, UT2k3, UT3
Additional Beyond Unreal Wiki Links
wiki.beyondunreal.com/Legacy:Console_Bar
wiki.beyondunreal.com/Exec_commands#Load
wiki.beyondunreal.com/Legacy:Exec_Directive#Loading_Other_Packages
wiki.beyondunreal.com/Legacy:Config_Vars_And_.Ini_Files
wiki.beyondunreal.com/Legacy:INT_File
FSM
Novice
Posts: 3
Joined: Wed Dec 05, 2018 11:16 am

Re: Recording movement directions (Issue for UGOLD)

Post by FSM »

So the code has worked out fine, but I discovered that I couldn't call super.PlayerInput() without any issues with the logging. I guess those values were either being overwritten or being erased by the garbagecollector. Idk, but anyways... it works now so I am most thankful.
Post Reply