View Full Version : Keybind for tap and hold keys?
John J
02-06-2012, 11:08 PM
I'm trying to figure out a way to get a keybind setup where I can press/hold a a key to get one result or double tap then hold to get a different result.
Example:
press hold Q = lean left
tap Q twice and hold on second press = step out left
I understand the keybind process, but can't figure out a way to do the double tap and/or a way to have different "modes" to 1 key.
any ideas?
Acecutter69
02-07-2012, 12:51 AM
you have to do it by hand. its the same way the controller tracks dodge. keybinds have a release call. so functioncallonpress | release functiononelease on your ini will do that:
so you would do something like:
exec function Lean()
{
if(LeanPressTime + 0.5 < worldinfo.timeseconds)
{
StepOut();
ClearTimer('DoLean');
return;
}
LeanPressTime = worldinfo.timeseconds;
SetTimer(0.5, false, 'DoLean');
}
function StepOut()
{
SetTimer(0.5, false, 'DoStepOut');
}
exec function Unlean()
{
ClearTimer('DoLean');
ClearTimer('DoStepOut');
}
then use dolean to lean, and dostepout to step out.
of course the 0.5 is the timer delay to check for double tapping. if its within 0.5 then handle the double tap, or else just handle tap :D
John J
02-08-2012, 12:00 AM
I get the concept but I can't seem to get it to work. No matter how I set it up, I am always just getting the lean to fire off. It never calls StepOut. It just seems to wait out the timer then do the lean.
John J
02-08-2012, 12:44 PM
I wonder if there is some way to use DoubleClickMove in PlayerMove instead? It's a little confusing to me though.
Acecutter69
02-08-2012, 01:24 PM
k i overlooked something, the unlean is clearing out the timers. just add a trap there as well so it wont unlean unless your already leaning or stepping out :D
John J
02-08-2012, 09:12 PM
Almost there..... What I am getting now is the "DoubleTap" is registered when I release the key on the second tap. So If I hit and hold bound key, LeanLeft() is executed fine. If I release key after 0.5 seconds LeanOff() is run as expected. If I hit and hold key then release before 0.5 seconds both LeanOff() and StepOutLeft() are fired. At no time can I get StepOutLeft() to fire on its own.
Sorry If I'm missing something obvious, but I'm a tech artist learning new things and sequential logic like this trips me up sometimes. :o
Here is what I have. I'm only showing the Left portion as Right is the same. Also, I don't have the stepout stuff done so I'm just doing Logs to verify it works.
exec function LeanLeft()
{
LeanPressTime = worldinfo.TimeSeconds;
if(LeanPressTime + 0.5 < worldinfo.TimeSeconds)
{
StepOutLeft();
ClearTimer('DoLeanLeft');
return;
}
SetTimer(0.5 , false, 'DoLeanLeft');
}
function DoLeanLeft()
{
if(IsLeaning) return;
IsLeaning = True;
if(FPLeanSkelControl != None) {
FPLeanSkelControl.SetSkelControlActive(False);
FPLeanSkelControl.BoneRotation.Roll = -LeanRoll;
FPLeanSkelControl.SetSkelControlActive(True);
}
if(LeanSkelControl != None) {
LeanSkelControl.SetSkelControlActive(False);
LeanSkelControl.BoneRotation.roll = -LeanRoll;
LeanSkelControl.SetSkelControlActive(true);
}
}
exec function LeanOff()
{
if(IsLeaning == true)
{
ClearTimer('DoLeanLeft');
ClearTimer('DoLeanRight');
DoLeanOff();
}
else{
StepOutOff();
}
}
function DoLeanOff()
{
IsLeaning=False;
if(FPLeanSkelControl != None) {
FPLeanSkelControl.SetSkelControlActive(false);
}
if(LeanSkelControl != None) {
LeanSkelControl.SetSkelControlActive(False);
}
}
function StepOutLeft()
{
SetTimer(0.5, false, 'DoStepOutLeft');
}
function DoStepOutLeft()
{
`Log("#### StepOutLeft");
}
function StepOutOff()
{
`Log("#### StepOutOff");
}
lovindadonks
02-08-2012, 10:00 PM
StepOutLeft is not being called for 1 of 2 reasons:
1. You have not declared StepOutLeft as an exec function, so you can't call it via keybind
2. If you didn't want this to be a keybind, then you are not calling it from another function you have listed. If it is your other code we can't see, then my mistake.
John J
02-08-2012, 10:13 PM
StepOutLeft shouldn't be an exec function because the idea is its a secondary choice to leaning. LeanLeft() is the bound function and the idea is that the decision whether to lean or step out based on how the bound key is manipulated is done from there. I am calling it from LeanLeft(), but maybe not the correct way, not sure.
Acecutter69
02-08-2012, 10:19 PM
no see here:
exec function LeanLeft()
{
LeanPressTime = worldinfo.TimeSeconds;
if(LeanPressTime + 0.5 < worldinfo.TimeSeconds)
{
StepOutLeft();
ClearTimer('DoLeanLeft');
return;
}
SetTimer(0.5 , false, 'DoLeanLeft');
}
the if(LeanPressTime + 0.5 < worldinfo.TimeSeconds) will never be true because you set the new time before you check
exec function LeanLeft()
{
if( TimerActive('DoLeanLeft'))
{
if(NextPressTime < worldinfo.TimeSeconds)
{
StepOutLeft();
ClearTimer('DoLeanLeft');
return;
}
}
NextPressTime = worldinfo.TimeSeconds + 0.5;
SetTimer(0.5 , false, 'DoLeanLeft');
}
try that and null out the lean out function, lets start by making sure we can double click :D then we can handle how to unlean
PS sorry for the mistakes im doing this out of the top of my head :D
John J
02-08-2012, 10:34 PM
Ok, with that I get this behavior (I'm just writing out log statements now):
Press key and hold = DoLeanLeft
Release Key = LeanOff *This is a bound exec function
Tap key = LeanOff then DoLeanLeft
Quick DoubleTap key and hold = LeanOff then StepOutLeft
Release key = LeanOff
Hopefully that makes sense. It's sort of working, just not in the right order. I guess the LeanOff being called makes sense because it's a bound exec function. So we will need to add in some similar logic there eventually.
EDIT:
Oh and I use IsTimerActive instead of TimerActive. Figured it was a typo. ;-) And thanks for helping me out!
Acecutter69
02-08-2012, 11:25 PM
yeah man im trying to help you with the logic more than the code :D
John J
02-09-2012, 10:19 AM
Got it working except for one little problem. If I do a quick tap of the bound key it will DoLeanLeft and stay there, not firing the exec LeanOff function. Ideally there would be some sort of way to do nothing if the bound key is just tapped once.
exec function LeanLeft()
{
local float NextPressTime;
if( IsTimerActive('DoLeanLeft'))
{
if(NextPressTime < worldinfo.TimeSeconds)
{
StepOutLeft();
ClearTimer('DoLeanLeft');
return;
}
}
NextPressTime = worldinfo.TimeSeconds + 0.5;
SetTimer(0.5, false, 'DoLeanLeft');
}
function DoLeanLeft()
{
`Log("#### DoLeanLeft");
IsLeaning = True;
}
exec function LeanOff()
{
if(IsLeaning)
{
DoLeanOff();
}
else{
DoStepOutOff();
}
}
function DoLeanOff()
{
`Log("#### LeanOff");
IsLeaning = false;
}
function StepOutLeft()
{
IsLeaning = false;
DoStepOutLeft();
}
function DoStepOutLeft()
{
`Log("#### StepOutLeft");
}
function StepOutOff()
{
`Log("#### StepOutOff");
}
sebi3110
07-18-2012, 08:40 AM
Hey there,
sorry to dig out this old topic, but I also want to perform something with this press and hold binding to functions.
I would like to perform a short jump when hitting spacebar short and a longer jump when spacebar gets hit and hold.
Any ideas? :)
slowJusko
07-18-2012, 09:21 AM
Tutorial: Advanced Button Actions (http://krisredbeard.wordpress.com/tutorials/tutorial-advanced-button-actions/) should cover it :)
sebi3110
07-19-2012, 07:55 AM
Okay so i have some trouble with getting this done.
I made an Variable in SPG_PlayerController.uc
var bool bLongJump;
and write an exec function in SPG_PlayerInput.uc
exec function LongJump ()
{
bLongJump=true;
}
exec function StopLongJump ()
{
bLongJump=false
}
To perform this "LongJump" I tried setting up an event in my SPG_PlayerPawn.uc
event bool DoJump (bool bUpdating)
{
if(SPG_PlayerController(Controller) .bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
}
What I like to do with this scripting is simply when pressing (in my case) M to perform a higher jump by increasing the velocity values while running a "DoJump".
I Also set up bindings in the DefaultInput.ini
.Bindings=(Name="GBA_LongJump",Command="LongJump | onrelease StopLongJump")
.Bindings=(Name="M",Command="GBA_LongJump")
Although Unreal Frontend is giving me the following error messages:
nalyzing...
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerInput.uc(2) : Error, Unexpected 'config'
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerPawn.uc(247) : Error, 'DoJump' conflicts with 'Function StarterPlatformGame.SPG_PlayerPawn:DoJump'
Compile aborted due to errors.
Warning/Error Summary
---------------------
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerInput.uc(2) : Error, Unexpected 'config'
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerPawn.uc(247) : Error, 'DoJump' conflicts with 'Function StarterPlatformGame.SPG_PlayerPawn:DoJump'
Failure - 2 error(s), 0 warning(s)
Execution of commandlet took: 4.72 seconds
[Jul 19, 1:45 ] COMMANDLET 'UDK.exe make' FAILED
Whats wrong with my Code?
Can you help me?:)
reinrag
07-19-2012, 08:06 AM
For the first error we can't you help you because you do not show the code where the error occurs, for the second it seems like you have two functions called DoJump remove one of them or you can change it's name,
sebi3110
07-19-2012, 08:27 AM
Thanks for your reply :)
I got rid of the first error.
For the second error I renamed
event bool DoJump (bool bUpdating)
{
if(SPG_PlayerController(Controller) .bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
}
to
event bool LongJump (bool bUpdating)
{
if(SPG_PlayerController(Controller) .bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
}
So this error is also away.
Although now I get this error in UnrealFrontend:
Analyzing...
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerInput.uc(21) : Error, 'bLongJump': Bad command or expression
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerInput.uc(14) : Error, 'bLongJump': Bad command or expression
E:\UDK-2012-05\Development\Src\StarterPlatformGame\Classes\SPG _PlayerPawn.uc(258) : Warning, LongJump: Missing return value
Compile aborted due to errors.
I included the whole script under this text, hope you can help me :)
SPG_PlayerController
//================================================== ===========================
// SPG_PlayerController
//
// Pawn which represents the player. Handles visual components and driving
// the aim offset.
//
// Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
//================================================== ===========================
class SPG_PlayerController extends PlayerController;
// The desired rotation that we want the pawn to be facing
var Rotator DesiredRotation;
var bool bLongJump;
/**
* Updates the rotation of the controller and the pawn. Called once per tick
*
* @param DeltaTime Time since the last tick was executed.
* @network Server and client
*/
function UpdateRotation(float DeltaTime)
{
local Rotator DeltaRot;
// Set the delta rotation to that of the desired rotation, as the desired rotation represents
// the rotation derived from the acceleration of the pawn
DeltaRot = DesiredRotation;
// Set the delta pitch to read from the look up input
DeltaRot.Pitch = PlayerInput.aLookUp;
// Never need to roll the delta rotation
DeltaRot.Roll = 0;
// Shake the camera if necessary
ViewShake(DeltaTime);
// If we have a pawn, update its facing rotation
if (Pawn != None)
{
Pawn.FaceRotation(DeltaRot, DeltaTime);
}
}
// Default state that pawn is walking
state PlayerWalking
{
/**
* Handle player moving. Called once per tick
*
* @param DeltaTime Time since the last tick
* @network Server and client
*/
function PlayerMove(float DeltaTime)
{
local Vector X, Y, Z, NewAccel, CameraLocation;
local Rotator OldRotation, CameraRotation;
local bool bSaveJump;
// If we don't have a pawn to control, then we should go to the dead state
if (Pawn == None)
{
GotoState('Dead');
}
else
{
// Grab the camera view point as we want to have movement aligned to the camera
PlayerCamera.GetCameraViewPoint(CameraLocation, CameraRotation);
// Get the individual axes of the rotation
GetAxes(CameraRotation, X, Y, Z);
// Update acceleration
NewAccel = PlayerInput.aStrafe * Y;
NewAccel.Z = 0;
NewAccel = Pawn.AccelRate * Normal(NewAccel);
// Set the desired rotation
DesiredRotation = Rotator(NewAccel);
// Update rotation
OldRotation = Rotation;
UpdateRotation(DeltaTime);
// Update crouch
Pawn.ShouldCrouch(bool(bDuck));
// Handle jumping
if (bPressedJump && Pawn.CannotJumpNow())
{
bSaveJump = true;
bPressedJump = false;
}
else
{
bSaveJump = false;
}
// Update the movement, either replicate it or process it
if (Role < ROLE_Authority)
{
ReplicateMove(DeltaTime, NewAccel, DCLICK_None, OldRotation - Rotation);
}
else
{
ProcessMove(DeltaTime, NewAccel, DCLICK_None, OldRotation - Rotation);
}
bPressedJump = bSaveJump;
}
}
}
defaultproperties
{
CameraClass=class'SPG_Camera'
InputClass=class 'SPG_Player_Input'
}
SPG_PlayerInput
class SPG_PlayerInput extends UDKPlayerInput;
var bool bMyButton, bMyButtonPressed, bMyButtonHeld, bMyButtonWasHeld, bMyButtonReleased, bMyButtonDoubletapped, bOld_MyButton;
var float LastPressedMyButtonTime;
exec function LongJump ()
{
bLongJump=true;
}
exec function StopLongJump ()
{
bLongJump=false
}
SPG_PlayerPawn
//================================================== ===========================
// SPG_PlayerPawn
//
// Pawn which represents the player. Handles visual components and driving
// the aim offset.
//
// Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
//================================================== ===========================
class SPG_PlayerPawn extends Pawn;
// Dynamic light environment component to help speed up lighting calculations for the pawn
var(Pawn) const DynamicLightEnvironmentComponent LightEnvironment;
// How fast a pawn turns
var(Pawn) const float TurnRate;
// How high the pawn jumps
var(Pawn) const float JumpHeight;
// Socket to use for attaching weapons
var(Pawn) const Name WeaponSocketName;
// Reference to the aim node aim offset node
var AnimNodeAimOffset AimNode;
// Reference to the gun recoil skel controller node
var GameSkelCtrl_Recoil GunRecoilNode;
// Internal int which stores the desired yaw of the pawn
var int DesiredYaw;
// Internal int which store the current yaw of the pawn
var int CurrentYaw;
// Internal int which stores the current pitch of the pawn
var int CurrentPitch;
/**
* Constructor which always gets called when the pawn is spawned. Just sets the value of the desired yaw and
* current yaw to the rotation yaw when first spawned
*
* @network Server and client
*/
simulated event PostBeginPlay()
{
Super.PostBeginPlay();
// Set the desired and current yaw to the same as what the pawn spawned in
DesiredYaw = Rotation.Yaw;
CurrentYaw = Rotation.Yaw;
JumpZ = JumpHeight;
}
/**
* Destructor which always gets called when the pawn is destroyed. This is useful for cleaning up any
* object reference we may have
*
* @network Server and client
*/
simulated event Destroyed()
{
Super.Destroyed();
AimNode = None;
GunRecoilNode = None;
}
/**
* Called when the actor has finished initializing a skeletal mesh component's anim tree. This is usually a good
* place to start grabbing anim nodes or skeletal controllers
*
* @param SkelComp Skeletal mesh component that has had its anim tree initialized.
* @network Server and client
*/
simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
{
if (SkelComp == Mesh)
{
// Find the aim offset node
AimNode = AnimNodeAimOffset(Mesh.FindAnimNode('AimNode'));
// Find the gun recoil skeletal control node
GunRecoilNode = GameSkelCtrl_Recoil(Mesh.FindSkelControl('GunRecoi lNode'));
}
}
/**
* Adjusts weapon aiming direction.
* Gives Pawn a chance to modify its aiming. For example aim error, auto aiming, adhesion, AI help...
* Requested by weapon prior to firing.
*
* @param W Weapon about to fire
* @param StartFireLoc World location of weapon fire start trace, or projectile spawn loc.
* @return Rotation to fire from
* @network Server and client
*/
simulated function Rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
{
local Vector SocketLocation;
local Rotator SocketRotation;
local SPG_Weapon SPG_Weapon;
local SkeletalMeshComponent WeaponSkeletalMeshComponent;
SPG_Weapon = SPG_Weapon(Weapon);
if (SPG_Weapon != None)
{
WeaponSkeletalMeshComponent = SkeletalMeshComponent(SPG_Weapon.Mesh);
if (WeaponSkeletalMeshComponent != None && WeaponSkeletalMeshComponent.GetSocketByName(SPG_We apon.MuzzleSocketName) != None)
{
WeaponSkeletalMeshComponent.GetSocketWorldLocation AndRotation(SPG_Weapon.MuzzleSocketName, SocketLocation, SocketRotation);
return SocketRotation;
}
}
return Rotation;
}
/**
* Return world location to start a weapon fire trace from.
*
* @param CurrentWeapon Weapon about to fire
* @return World location where to start weapon fire traces from
* @network Server and client
*/
simulated event Vector GetWeaponStartTraceLocation(optional Weapon CurrentWeapon)
{
local Vector SocketLocation;
local Rotator SocketRotation;
local SPG_Weapon SPG_Weapon;
local SkeletalMeshComponent WeaponSkeletalMeshComponent;
SPG_Weapon = SPG_Weapon(Weapon);
if (SPG_Weapon != None)
{
WeaponSkeletalMeshComponent = SkeletalMeshComponent(SPG_Weapon.Mesh);
if (WeaponSkeletalMeshComponent != None && WeaponSkeletalMeshComponent.GetSocketByName(SPG_We apon.MuzzleSocketName) != None)
{
WeaponSkeletalMeshComponent.GetSocketWorldLocation AndRotation(SPG_Weapon.MuzzleSocketName, SocketLocation, SocketRotation);
return SocketLocation;
}
}
return Super.GetWeaponStartTraceLocation(CurrentWeapon);
}
/**
* Handles updating the rotation of the pawn. This is where the pitch and yaw of the pawn is calculated.
*
* @param NewRotation New rotation that we wish to adjust the pawn to
* @param DeltaTime Time slice since the last called FaceRotation. FaceRotation is usually called once per tick.
* @network Server and client
*/
simulated function FaceRotation(Rotator NewRotation, float DeltaTime)
{
local Rotator FacingRotation;
// Set the desired yaw the new rotation yaw
if (NewRotation.Yaw != 0)
{
DesiredYaw = NewRotation.Yaw;
}
// If the current yaw doesn't match the desired yaw, then interpolate towards it
if (CurrentYaw != DesiredYaw)
{
CurrentYaw = Lerp(CurrentYaw, DesiredYaw, TurnRate * DeltaTime);
}
// If we have a valid aim offset node
if (AimNode != None)
{
// Clamp the current pitch to the view pitch min and view pitch max
CurrentPitch = Clamp(CurrentPitch + NewRotation.Pitch, ViewPitchMin, ViewPitchMax);
if (CurrentPitch > 0.f)
{
// Handle when we're aiming up
AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMax;
}
else if (CurrentPitch < 0.f)
{
// Handle when we're aiming down
AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMin;
if (AimNode.Aim.Y > 0.f)
{
AimNode.Aim.Y *= -1.f;
}
}
else
{
// Handle when we're aiming straight forward
AimNode.Aim.Y = 0.f;
}
}
// Update the facing rotation
FacingRotation.Pitch = 0;
FacingRotation.Yaw = CurrentYaw;
FacingRotation.Roll = 0;
SetRotation(FacingRotation);
}
defaultproperties
{
// Remove the sprite component as it is not needed
Components.Remove(Sprite)
// Create a light environment for the pawn
Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
bSynthesizeSHLight=true
bIsCharacterLightEnvironment=true
bUseBooleanEnvironmentShadowing=false
End Object
Components.Add(MyLightEnvironment)
LightEnvironment=MyLightEnvironment
// Create a skeletal mesh component for the pawn
Begin Object Class=SkeletalMeshComponent Name=MySkeletalMeshComponent
bCacheAnimSequenceNodes=false
AlwaysLoadOnClient=true
AlwaysLoadOnServer=true
CastShadow=true
BlockRigidBody=true
bUpdateSkelWhenNotRendered=false
bIgnoreControllersWhenNotRendered=true
bUpdateKinematicBonesFromAnimation=true
bCastDynamicShadow=true
RBChannel=RBCC_Untitled3
RBCollideWithChannels=(Untitled3=true)
LightEnvironment=MyLightEnvironment
bOverrideAttachmentOwnerVisibility=true
bAcceptsDynamicDecals=false
bHasPhysicsAssetInstance=true
TickGroup=TG_PreAsyncWork
MinDistFactorForKinematicUpdate=0.2f
bChartDistanceFactor=true
RBDominanceGroup=20
Scale=1.f
bAllowAmbientOcclusion=false
bUseOnePassLightingOnTranslucency=true
bPerBoneMotionBlur=true
Translation=(Z=-20.0)
End Object
Mesh=MySkeletalMeshComponent
Components.Add(MySkeletalMeshComponent)
InventoryManagerClass=class'SPG_InventoryManager'
JumpHeight=400.f
bCanCrouch=false
bCanPickupInventory=true
}
exec function startJump()
{
if(Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider)
{
SetPhysics(PHYS_Flying);
Velocity.Z=JumpZ;
SetTimer(0.5,false,'stopJump');
}
}
exec function stopJump()
{
SetPhysics(PHYS_Falling);
}
function bool DoJump(bool bUpdating)
{
if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
{
if (Physics == PHYS_Spider)
{
Velocity = JumpHeight * Floor;
}
else if (Physics == PHYS_Ladder)
{
Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
else
{
Velocity.Z = JumpHeight;
Velocity.Y = JumpHeight;
}
if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f && Base.Velocity.Y > 0.f)
{
Velocity.Z += Base.Velocity.Z;
Velocity.Y += Base.Velocity.Y;
}
SetPhysics(PHYS_Falling);
return true;
}
return false;
}
event bool LongJump (bool bUpdating)
{
if(SPG_PlayerController(Controller) .bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
}
reinrag
07-19-2012, 09:42 AM
You can't place functions under defaultproperties it's not a good thing to do,
anyway try this haven't tested it myself,
//================================================== ===========================
// SPG_PlayerPawn
//
// Pawn which represents the player. Handles visual components and driving
// the aim offset.
//
// Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
//================================================== ===========================
class SPG_PlayerPawn extends Pawn;
// Dynamic light environment component to help speed up lighting calculations for the pawn
var(Pawn) const DynamicLightEnvironmentComponent LightEnvironment;
// How fast a pawn turns
var(Pawn) const float TurnRate;
// How high the pawn jumps
var(Pawn) const float JumpHeight;
// Socket to use for attaching weapons
var(Pawn) const Name WeaponSocketName;
// Reference to the aim node aim offset node
var AnimNodeAimOffset AimNode;
// Reference to the gun recoil skel controller node
var GameSkelCtrl_Recoil GunRecoilNode;
// Internal int which stores the desired yaw of the pawn
var int DesiredYaw;
// Internal int which store the current yaw of the pawn
var int CurrentYaw;
// Internal int which stores the current pitch of the pawn
var int CurrentPitch;
/**
* Constructor which always gets called when the pawn is spawned. Just sets the value of the desired yaw and
* current yaw to the rotation yaw when first spawned
*
* @network Server and client
*/
simulated event PostBeginPlay()
{
Super.PostBeginPlay();
// Set the desired and current yaw to the same as what the pawn spawned in
DesiredYaw = Rotation.Yaw;
CurrentYaw = Rotation.Yaw;
JumpZ = JumpHeight;
}
/**
* Destructor which always gets called when the pawn is destroyed. This is useful for cleaning up any
* object reference we may have
*
* @network Server and client
*/
simulated event Destroyed()
{
Super.Destroyed();
AimNode = None;
GunRecoilNode = None;
}
/**
* Called when the actor has finished initializing a skeletal mesh component's anim tree. This is usually a good
* place to start grabbing anim nodes or skeletal controllers
*
* @param SkelComp Skeletal mesh component that has had its anim tree initialized.
* @network Server and client
*/
simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
{
if (SkelComp == Mesh)
{
// Find the aim offset node
AimNode = AnimNodeAimOffset(Mesh.FindAnimNode('AimNode'));
// Find the gun recoil skeletal control node
GunRecoilNode = GameSkelCtrl_Recoil(Mesh.FindSkelControl('GunRecoi lNode'));
}
}
/**
* Adjusts weapon aiming direction.
* Gives Pawn a chance to modify its aiming. For example aim error, auto aiming, adhesion, AI help...
* Requested by weapon prior to firing.
*
* @param W Weapon about to fire
* @param StartFireLoc World location of weapon fire start trace, or projectile spawn loc.
* @return Rotation to fire from
* @network Server and client
*/
simulated function Rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
{
local Vector SocketLocation;
local Rotator SocketRotation;
local SPG_Weapon SPG_Weapon;
local SkeletalMeshComponent WeaponSkeletalMeshComponent;
SPG_Weapon = SPG_Weapon(Weapon);
if (SPG_Weapon != None)
{
WeaponSkeletalMeshComponent = SkeletalMeshComponent(SPG_Weapon.Mesh);
if (WeaponSkeletalMeshComponent != None && WeaponSkeletalMeshComponent.GetSocketByName(SPG_We apon.MuzzleSocketName) != None)
{
WeaponSkeletalMeshComponent.GetSocketWorldLocation AndRotation(SPG_Weapon.MuzzleSocketName, SocketLocation, SocketRotation);
return SocketRotation;
}
}
return Rotation;
}
/**
* Return world location to start a weapon fire trace from.
*
* @param CurrentWeapon Weapon about to fire
* @return World location where to start weapon fire traces from
* @network Server and client
*/
simulated event Vector GetWeaponStartTraceLocation(optional Weapon CurrentWeapon)
{
local Vector SocketLocation;
local Rotator SocketRotation;
local SPG_Weapon SPG_Weapon;
local SkeletalMeshComponent WeaponSkeletalMeshComponent;
SPG_Weapon = SPG_Weapon(Weapon);
if (SPG_Weapon != None)
{
WeaponSkeletalMeshComponent = SkeletalMeshComponent(SPG_Weapon.Mesh);
if (WeaponSkeletalMeshComponent != None && WeaponSkeletalMeshComponent.GetSocketByName(SPG_We apon.MuzzleSocketName) != None)
{
WeaponSkeletalMeshComponent.GetSocketWorldLocation AndRotation(SPG_Weapon.MuzzleSocketName, SocketLocation, SocketRotation);
return SocketLocation;
}
}
return Super.GetWeaponStartTraceLocation(CurrentWeapon);
}
/**
* Handles updating the rotation of the pawn. This is where the pitch and yaw of the pawn is calculated.
*
* @param NewRotation New rotation that we wish to adjust the pawn to
* @param DeltaTime Time slice since the last called FaceRotation. FaceRotation is usually called once per tick.
* @network Server and client
*/
simulated function FaceRotation(Rotator NewRotation, float DeltaTime)
{
local Rotator FacingRotation;
// Set the desired yaw the new rotation yaw
if (NewRotation.Yaw != 0)
{
DesiredYaw = NewRotation.Yaw;
}
// If the current yaw doesn't match the desired yaw, then interpolate towards it
if (CurrentYaw != DesiredYaw)
{
CurrentYaw = Lerp(CurrentYaw, DesiredYaw, TurnRate * DeltaTime);
}
// If we have a valid aim offset node
if (AimNode != None)
{
// Clamp the current pitch to the view pitch min and view pitch max
CurrentPitch = Clamp(CurrentPitch + NewRotation.Pitch, ViewPitchMin, ViewPitchMax);
if (CurrentPitch > 0.f)
{
// Handle when we're aiming up
AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMax;
}
else if (CurrentPitch < 0.f)
{
// Handle when we're aiming down
AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMin;
if (AimNode.Aim.Y > 0.f)
{
AimNode.Aim.Y *= -1.f;
}
}
else
{
// Handle when we're aiming straight forward
AimNode.Aim.Y = 0.f;
}
}
// Update the facing rotation
FacingRotation.Pitch = 0;
FacingRotation.Yaw = CurrentYaw;
FacingRotation.Roll = 0;
SetRotation(FacingRotation);
}
exec function startJump()
{
if(Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider)
{
SetPhysics(PHYS_Flying);
Velocity.Z=JumpZ;
SetTimer(0.5,false,'stopJump');
}
}
exec function stopJump()
{
SetPhysics(PHYS_Falling);
}
function bool DoJump(bool bUpdating)
{
if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
{
if (Physics == PHYS_Spider)
{
Velocity = JumpHeight * Floor;
}
else if (Physics == PHYS_Ladder)
{
Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
else
{
Velocity.Z = JumpHeight;
Velocity.Y = JumpHeight;
}
if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f && Base.Velocity.Y > 0.f)
{
Velocity.Z += Base.Velocity.Z;
Velocity.Y += Base.Velocity.Y;
}
SetPhysics(PHYS_Falling);
return true;
}
return false;
}
event bool LongJump (bool bUpdating)
{
if(SPG_PlayerController(Controller).bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
return true;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
return false;
}
}
// Don't place functions underneath default properties
defaultproperties
{
// Remove the sprite component as it is not needed
Components.Remove(Sprite)
// Create a light environment for the pawn
Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
bSynthesizeSHLight=true
bIsCharacterLightEnvironment=true
bUseBooleanEnvironmentShadowing=false
End Object
Components.Add(MyLightEnvironment)
LightEnvironment=MyLightEnvironment
// Create a skeletal mesh component for the pawn
Begin Object Class=SkeletalMeshComponent Name=MySkeletalMeshComponent
bCacheAnimSequenceNodes=false
AlwaysLoadOnClient=true
AlwaysLoadOnServer=true
CastShadow=true
BlockRigidBody=true
bUpdateSkelWhenNotRendered=false
bIgnoreControllersWhenNotRendered=true
bUpdateKinematicBonesFromAnimation=true
bCastDynamicShadow=true
RBChannel=RBCC_Untitled3
RBCollideWithChannels=(Untitled3=true)
LightEnvironment=MyLightEnvironment
bOverrideAttachmentOwnerVisibility=true
bAcceptsDynamicDecals=false
bHasPhysicsAssetInstance=true
TickGroup=TG_PreAsyncWork
MinDistFactorForKinematicUpdate=0.2f
bChartDistanceFactor=true
RBDominanceGroup=20
Scale=1.f
bAllowAmbientOcclusion=false
bUseOnePassLightingOnTranslucency=true
bPerBoneMotionBlur=true
Translation=(Z=-20.0)
End Object
Mesh=MySkeletalMeshComponent
Components.Add(MySkeletalMeshComponent)
InventoryManagerClass=class'SPG_InventoryManager'
JumpHeight=400.f
bCanCrouch=false
bCanPickupInventory=true
}
//================================================== ===========================
class SPG_PlayerController extends PlayerController;
// The desired rotation that we want the pawn to be facing
var Rotator DesiredRotation;
var bool bLongJump;
/**
* Updates the rotation of the controller and the pawn. Called once per tick
*
* @param DeltaTime Time since the last tick was executed.
* @network Server and client
*/
function UpdateRotation(float DeltaTime)
{
local Rotator DeltaRot;
// Set the delta rotation to that of the desired rotation, as the desired rotation represents
// the rotation derived from the acceleration of the pawn
DeltaRot = DesiredRotation;
// Set the delta pitch to read from the look up input
DeltaRot.Pitch = PlayerInput.aLookUp;
// Never need to roll the delta rotation
DeltaRot.Roll = 0;
// Shake the camera if necessary
ViewShake(DeltaTime);
// If we have a pawn, update its facing rotation
if (Pawn != None)
{
Pawn.FaceRotation(DeltaRot, DeltaTime);
}
}
// Default state that pawn is walking
state PlayerWalking
{
/**
* Handle player moving. Called once per tick
*
* @param DeltaTime Time since the last tick
* @network Server and client
*/
function PlayerMove(float DeltaTime)
{
local Vector X, Y, Z, NewAccel, CameraLocation;
local Rotator OldRotation, CameraRotation;
local bool bSaveJump;
// If we don't have a pawn to control, then we should go to the dead state
if (Pawn == None)
{
GotoState('Dead');
}
else
{
// Grab the camera view point as we want to have movement aligned to the camera
PlayerCamera.GetCameraViewPoint(CameraLocation, CameraRotation);
// Get the individual axes of the rotation
GetAxes(CameraRotation, X, Y, Z);
// Update acceleration
NewAccel = PlayerInput.aStrafe * Y;
NewAccel.Z = 0;
NewAccel = Pawn.AccelRate * Normal(NewAccel);
// Set the desired rotation
DesiredRotation = Rotator(NewAccel);
// Update rotation
OldRotation = Rotation;
UpdateRotation(DeltaTime);
// Update crouch
Pawn.ShouldCrouch(bool(bDuck));
// Handle jumping
if (bPressedJump && Pawn.CannotJumpNow())
{
bSaveJump = true;
bPressedJump = false;
}
else
{
bSaveJump = false;
}
// Update the movement, either replicate it or process it
if (Role < ROLE_Authority)
{
ReplicateMove(DeltaTime, NewAccel, DCLICK_None, OldRotation - Rotation);
}
else
{
ProcessMove(DeltaTime, NewAccel, DCLICK_None, OldRotation - Rotation);
}
bPressedJump = bSaveJump;
}
}
}
defaultproperties
{
CameraClass=class'SPG_Camera'
InputClass=class 'SPG_PlayerInput' // you need to write the exact class name
}
class SPG_PlayerInput extends UDKPlayerInput;
var bool bMyButton, bMyButtonPressed, bMyButtonHeld, bMyButtonWasHeld, bMyButtonReleased, bMyButtonDoubletapped, bOld_MyButton;
var float LastPressedMyButtonTime;
var bool bLongJump; // you should add a boolean variable here
exec function LongJump ()
{
bLongJump=true;
}
exec function StopLongJump ()
{
bLongJump=false; // you forgot a semicolon here
}
sebi3110
07-19-2012, 09:48 AM
Thanks for your time investing in my problem! :)
Although I get this error now when compiling:
Analyzing...
E:\UDK-2012-05\Binaries\..\Development\Src\StarterPlatformGame \Classes\SPG_PlayerController.uc : Error, Bad class definition ''/''/2669/2669
Compile aborted due to errors.
Warning/Error Summary
---------------------
E:\UDK-2012-05\Binaries\..\Development\Src\StarterPlatformGame \Classes\SPG_PlayerController.uc : Error, Bad class definition ''/''/2669/2669
Failure - 1 error(s), 0 warning(s)
Execution of commandlet took: 4.53 seconds
[Jul 19, 3:47 ] COMMANDLET 'UDK.exe make' FAILED
reinrag
07-19-2012, 10:08 AM
What's the name of your file ? is it SPG_PlayerController.uc ? have you written any symbols in the class name as in 123SPG_PlayerController.uc ? even though it did not output it here it's better to ask
sebi3110
07-19-2012, 11:36 AM
The filename is SPG_PlayerController.uc. So no symbols used.
Although I also have a SPG_PlayerController.uc_bak and a SPG_PlayerController.uc~ in the same directory but I dont think that s a problem?
EDIT: Fault on my side, I'm very sorry.
When copying your code I somehow missed the first line, so obvoiusly there was no class defined then.... Now it compiled successfully. Will test it out now.
Thanks again!
Edit2: I'm getting a crash of the Editor when launching the game and giving an Input (e.g. press jump or press w) SOLVED
SOLVED: let the class SPG_PlayerController extending UDKPlayerController and not (as it was before) only PlayerController
New Problem:
Binding is not working. Binded the LongJump to the key M, but it does nothing ingame when pressing M.
Also is it possible to bind the LongJump to spacebar and only activating this LongJump when spacebar is hold for a certain timevalue?
And when spacebar is only hit for a short amount of time, normal Jump gets activated.
reinrag
07-19-2012, 12:52 PM
Have you set the correct gametype ? you could try to log the function and see if it gets called,
sebi3110
07-19-2012, 05:31 PM
Yep its set.
I placed Log commands in SPG_PlayerInput:
exec function LongJump ()
{
bLongJump=true;
`log("LongJump has been activated");
}
exec function StopLongJump ()
{
bLongJump=false; // you forgot a semicolon here
`log("LongJump has been disabled");
}
and in SPG_PlayerPawn Where Velocity should be changed):
//================================================== ===========================
// SPG_PlayerPawn
//
// Pawn which represents the player. Handles visual components and driving
// the aim offset.
//
// Copyright 1998-2011 Epic Games, Inc. All Rights Reserved.
//================================================== ===========================
class SPG_PlayerPawn extends Pawn;
// Dynamic light environment component to help speed up lighting calculations for the pawn
var(Pawn) const DynamicLightEnvironmentComponent LightEnvironment;
// How fast a pawn turns
var(Pawn) const float TurnRate;
// How high the pawn jumps
var(Pawn) const float JumpHeight;
// Socket to use for attaching weapons
var(Pawn) const Name WeaponSocketName;
// Reference to the aim node aim offset node
var AnimNodeAimOffset AimNode;
// Reference to the gun recoil skel controller node
var GameSkelCtrl_Recoil GunRecoilNode;
// Internal int which stores the desired yaw of the pawn
var int DesiredYaw;
// Internal int which store the current yaw of the pawn
var int CurrentYaw;
// Internal int which stores the current pitch of the pawn
var int CurrentPitch;
/**
* Constructor which always gets called when the pawn is spawned. Just sets the value of the desired yaw and
* current yaw to the rotation yaw when first spawned
*
* @network Server and client
*/
simulated event PostBeginPlay()
{
Super.PostBeginPlay();
// Set the desired and current yaw to the same as what the pawn spawned in
DesiredYaw = Rotation.Yaw;
CurrentYaw = Rotation.Yaw;
JumpZ = JumpHeight;
}
/**
* Destructor which always gets called when the pawn is destroyed. This is useful for cleaning up any
* object reference we may have
*
* @network Server and client
*/
simulated event Destroyed()
{
Super.Destroyed();
AimNode = None;
GunRecoilNode = None;
}
/**
* Called when the actor has finished initializing a skeletal mesh component's anim tree. This is usually a good
* place to start grabbing anim nodes or skeletal controllers
*
* @param SkelComp Skeletal mesh component that has had its anim tree initialized.
* @network Server and client
*/
simulated event PostInitAnimTree(SkeletalMeshComponent SkelComp)
{
if (SkelComp == Mesh)
{
// Find the aim offset node
AimNode = AnimNodeAimOffset(Mesh.FindAnimNode('AimNode'));
// Find the gun recoil skeletal control node
GunRecoilNode = GameSkelCtrl_Recoil(Mesh.FindSkelControl('GunRecoi lNode'));
}
}
/**
* Adjusts weapon aiming direction.
* Gives Pawn a chance to modify its aiming. For example aim error, auto aiming, adhesion, AI help...
* Requested by weapon prior to firing.
*
* @param W Weapon about to fire
* @param StartFireLoc World location of weapon fire start trace, or projectile spawn loc.
* @return Rotation to fire from
* @network Server and client
*/
simulated function Rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
{
local Vector SocketLocation;
local Rotator SocketRotation;
local SPG_Weapon SPG_Weapon;
local SkeletalMeshComponent WeaponSkeletalMeshComponent;
SPG_Weapon = SPG_Weapon(Weapon);
if (SPG_Weapon != None)
{
WeaponSkeletalMeshComponent = SkeletalMeshComponent(SPG_Weapon.Mesh);
if (WeaponSkeletalMeshComponent != None && WeaponSkeletalMeshComponent.GetSocketByName(SPG_We apon.MuzzleSocketName) != None)
{
WeaponSkeletalMeshComponent.GetSocketWorldLocation AndRotation(SPG_Weapon.MuzzleSocketName, SocketLocation, SocketRotation);
return SocketRotation;
}
}
return Rotation;
}
/**
* Return world location to start a weapon fire trace from.
*
* @param CurrentWeapon Weapon about to fire
* @return World location where to start weapon fire traces from
* @network Server and client
*/
simulated event Vector GetWeaponStartTraceLocation(optional Weapon CurrentWeapon)
{
local Vector SocketLocation;
local Rotator SocketRotation;
local SPG_Weapon SPG_Weapon;
local SkeletalMeshComponent WeaponSkeletalMeshComponent;
SPG_Weapon = SPG_Weapon(Weapon);
if (SPG_Weapon != None)
{
WeaponSkeletalMeshComponent = SkeletalMeshComponent(SPG_Weapon.Mesh);
if (WeaponSkeletalMeshComponent != None && WeaponSkeletalMeshComponent.GetSocketByName(SPG_We apon.MuzzleSocketName) != None)
{
WeaponSkeletalMeshComponent.GetSocketWorldLocation AndRotation(SPG_Weapon.MuzzleSocketName, SocketLocation, SocketRotation);
return SocketLocation;
}
}
return Super.GetWeaponStartTraceLocation(CurrentWeapon);
}
/**
* Handles updating the rotation of the pawn. This is where the pitch and yaw of the pawn is calculated.
*
* @param NewRotation New rotation that we wish to adjust the pawn to
* @param DeltaTime Time slice since the last called FaceRotation. FaceRotation is usually called once per tick.
* @network Server and client
*/
simulated function FaceRotation(Rotator NewRotation, float DeltaTime)
{
local Rotator FacingRotation;
// Set the desired yaw the new rotation yaw
if (NewRotation.Yaw != 0)
{
DesiredYaw = NewRotation.Yaw;
}
// If the current yaw doesn't match the desired yaw, then interpolate towards it
if (CurrentYaw != DesiredYaw)
{
CurrentYaw = Lerp(CurrentYaw, DesiredYaw, TurnRate * DeltaTime);
}
// If we have a valid aim offset node
if (AimNode != None)
{
// Clamp the current pitch to the view pitch min and view pitch max
CurrentPitch = Clamp(CurrentPitch + NewRotation.Pitch, ViewPitchMin, ViewPitchMax);
if (CurrentPitch > 0.f)
{
// Handle when we're aiming up
AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMax;
}
else if (CurrentPitch < 0.f)
{
// Handle when we're aiming down
AimNode.Aim.Y = float(CurrentPitch) / ViewPitchMin;
if (AimNode.Aim.Y > 0.f)
{
AimNode.Aim.Y *= -1.f;
}
}
else
{
// Handle when we're aiming straight forward
AimNode.Aim.Y = 0.f;
}
}
// Update the facing rotation
FacingRotation.Pitch = 0;
FacingRotation.Yaw = CurrentYaw;
FacingRotation.Roll = 0;
SetRotation(FacingRotation);
}
exec function startJump()
{
if(Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider)
{
SetPhysics(PHYS_Flying);
Velocity.Z=JumpZ;
SetTimer(0.5,false,'stopJump');
}
}
exec function stopJump()
{
SetPhysics(PHYS_Falling);
}
function bool DoJump(bool bUpdating)
{
if (bJumpCapable && !bIsCrouched && !bWantsToCrouch && (Physics == PHYS_Walking || Physics == PHYS_Ladder || Physics == PHYS_Spider))
{
if (Physics == PHYS_Spider)
{
Velocity = JumpHeight * Floor;
}
else if (Physics == PHYS_Ladder)
{
Velocity.Z = 0.f;
Velocity.Y = 100.f;
}
else
{
Velocity.Z = JumpHeight;
Velocity.Y = JumpHeight;
}
if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f && Base.Velocity.Y > 0.f)
{
Velocity.Z += Base.Velocity.Z;
Velocity.Y += Base.Velocity.Y;
}
SetPhysics(PHYS_Falling);
return true;
}
if(SPG_PlayerController(Controller).bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
`log("Velocity has been increased!!!!");
return true;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
`log(" Velocity is normal again!!!");
return false;
}
return false;
}
/*event bool LongJump (bool bUpdating)
{
if(SPG_PlayerController(Controller).bLongJump)
{ Velocity.Z = 100.f;
Velocity.Y = 200.f;
return true;
}
else
{ Velocity.Z = 0.f;
Velocity.Y = 100.f;
return false;
}
}*/
// Don't place functions underneath default properties
defaultproperties
{
// Remove the sprite component as it is not needed
Components.Remove(Sprite)
// Create a light environment for the pawn
Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
bSynthesizeSHLight=true
bIsCharacterLightEnvironment=true
bUseBooleanEnvironmentShadowing=false
End Object
Components.Add(MyLightEnvironment)
LightEnvironment=MyLightEnvironment
// Create a skeletal mesh component for the pawn
Begin Object Class=SkeletalMeshComponent Name=MySkeletalMeshComponent
bCacheAnimSequenceNodes=false
AlwaysLoadOnClient=true
AlwaysLoadOnServer=true
CastShadow=true
BlockRigidBody=true
bUpdateSkelWhenNotRendered=false
bIgnoreControllersWhenNotRendered=true
bUpdateKinematicBonesFromAnimation=true
bCastDynamicShadow=true
RBChannel=RBCC_Untitled3
RBCollideWithChannels=(Untitled3=true)
LightEnvironment=MyLightEnvironment
bOverrideAttachmentOwnerVisibility=true
bAcceptsDynamicDecals=false
bHasPhysicsAssetInstance=true
TickGroup=TG_PreAsyncWork
MinDistFactorForKinematicUpdate=0.2f
bChartDistanceFactor=true
RBDominanceGroup=20
Scale=1.f
bAllowAmbientOcclusion=false
bUseOnePassLightingOnTranslucency=true
bPerBoneMotionBlur=true
Translation=(Z=-20.0)
End Object
Mesh=MySkeletalMeshComponent
Components.Add(MySkeletalMeshComponent)
InventoryManagerClass=class'SPG_InventoryManager'
JumpHeight=400.f
bCanCrouch=false
bCanPickupInventory=true
}
The input seems to work, because I get this in the log window:
ScriptLog: LongJUmp has been activated
CMD: onrelease StopLongJump
SCriptLog: LongJump has been disabled
So that works but I dont get the other two log files from the SPG_PlayerPawn.
the if function didnt get "played",..
Mh any ideas?
reinrag
07-20-2012, 04:55 AM
What exactly calls this event ? and also why did you "comment" the function with this sign /* ?
sebi3110
07-20-2012, 05:21 AM
The event enable LongJump? Should call the exec function LongJUmp and give more velocity to the jump. I removed the /* from the function but It didnt changed anything.
What I'm currently try to achieve is a jump that is long when pressing the key M and a normal jump when I press scpaebar.
At the end of the day I want to have the LongJump when pressing and holding spacebar. and when only hitting spacebar for a short time it should play the normal Jump.
It seams that something is missing in the code. But I dont know what. mh
reinrag
07-20-2012, 06:33 AM
I don't know why but the function you wrote doesn't make sense to me at all and to be honest i don't think it will ever work so i've wrote a function myself right now just one function that makes it all work,
write this variable on your pawn class
var float LongJumpZ;
copy/paste this on your pawn class above default properties not below
exec function LongJump( bool bUpdating )
{
if ( Physics == PHYS_Spider )
Velocity = LongJumpZ * Floor;
else if ( Physics == PHYS_Ladder )
Velocity.Z = 0;
else if ( bIsWalking )
Velocity.Z = Default.LongJumpZ;
else
Velocity.Z = LongJumpZ;
if (Base != None && !Base.bWorldGeometry && Base.Velocity.Z > 0.f)
{
Velocity.Z += Base.Velocity.Z;
}
SetPhysics(PHYS_Falling);
}
pretty high i know but you wanted a long jump, eh ?
anyway write this on your defaultproperties
LongJumpZ=+09000.000000
now on UDK hit the @ key and write LongJump true you'll see for yourself ...
sebi3110
07-20-2012, 11:04 AM
Okay cool that works.
Now my question is how I can bind this Long Jump to the spacebar (but only when spacebar was hold).
Short spacebar hit -->DoJump (the normal Jump )
Spacebar hit and hold-->LongJump
How do I do that?
Thanks for the time!
reinrag
07-20-2012, 11:16 AM
This should help http://krisredbeard.wordpress.com/tutorials/tutorial-advanced-button-actions/ SlowJusko has done this tutorial and tbh it's quite helpful IMO, good luck mate and post back if you got it all solved,
sebi3110
07-21-2012, 01:09 PM
Hey, so I tried fo several hours now to call my LongJump function (from SPG_PlayerPawn) if "myButton" gets klicked.
But I have no idea how I can communicate between the "MyButtonActions" function from SPG_PlayerInput (I integrated there, I had to remove config(Input) because otherwise It gave my an error: "Unexpected config") and my LongJump exec function from SPG_PlayerPawn.I tried to integtrate a "byMyButtonPressed" in the if () but this also doesnt work.
I read through several forums and topics, but I cant help me.
Could you give me a tip?
That would be nice.
Cheers
slowJusko
07-22-2012, 08:51 AM
@sebi : just replied in the Advanced Button Actions (http://forums.epicgames.com/threads/820124-Advanced-Button-Actions) thread.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.