![]() |
![]() |
|
|
|
#1
|
|||
|
|||
|
Hey guys,
I thought I'd try to write my first mutator today and start simple but I am lost. It compiles but does nothing in game. From searching the forums it looks like I'm meant to to use ModifyVelocity in some form but I have no idea how. In the end I'm hoping to make it a sprint function but right now I'm just trying to change the player speed overall for the whole match. Anyway, here is the bit of code I tried: Code:
class SprintMutator extends Mutator;
function PostBeginPlay()
{
local KFHumanPawn Player;
foreach DynamicActors(class 'KFHumanPawn', Player)
{
Player.GroundSpeed = 2000.0; //high to make sure I just wasn't noticing the increase
}
}
defaultproperties
{
GroupName="KFSprintMutator"
FriendlyName="Allow Sprint"
Description="More Speed"
}
|
|
#2
|
||||
|
||||
|
Hey Vallo, good to see a new face learning the ropes.
Sorry there hasn't been much response. My recommendation to you is think simpler. You've got the correct function. But there is a much easier way to change a classes default value. You would have already seen it if following the tutorials on this board. Shout back if you are still stuck.
__________________
Whisky's Workshop ![]() "As you can see here, I'm -ALL ON MY F***ING OWN! Guys where the hell are you?!" |
|
#3
|
||||
|
||||
|
Good for the first approach. The mutator code does work, but it has no effect and that is logical.
You have to consider when PostBeginPlay() will be called. UnrealWiki PostBeginPlay() will be called when your Mutator will be created. So this happens at level start up. But at this time no player (Playerpawn) exists. So your iteration won't find any suitable object to modify. Therefore you should use the Mutator's "ModifyPlayer(Pawn Other)" function. This function will be called every time a "Pawn" spawns. Then modify the value directly in there and you will get the result you want to.
|
|
#4
|
||||
|
||||
|
PostBeginPlay() function will still work as he desires as it changes the variable at the beginning of the game.
Code:
simulated function PostBeginPlay()
{
//Increase base speed value.
class'KFHumanPawn'.default.GroundSpeed = 2000; //200
}
__________________
Whisky's Workshop ![]() "As you can see here, I'm -ALL ON MY F***ING OWN! Guys where the hell are you?!" |
|
#5
|
||||
|
||||
|
Quote:
taken from Benjamins, mutator tutorial thread Code:
class ExampleMutator extends Mutator;
function PostBeginPlay()
{
SetTimer(1, true);
}
function Timer()
{
local KFHumanPawn Player;
foreach DynamicActors(class 'KFHumanPawn', Player)
{
Player.default.GroundSpeed = 2000.0; //high to make sure I just wasn't noticing the increase
}
}
defaultproperties
{
GroupName="KFExampleMutator"
FriendlyName="Example Mutator"
Description="Mutator description here"
}
or Code:
class ExampleMutator extends Mutator;
ffunction ModifyPlayer(Pawn Other)
{
local xPawn ThePawn;
if(Other.IsA('xPawn'))
{
ThePawn = xPawn(Other);
ThePawn.default.GroundSpeed = 2000.0; //high to make sure I just wasn't noticing the increase
}
}
defaultproperties
{
GroupName="KFExampleMutator"
FriendlyName="Example Mutator"
Description="Mutator description here"
}
|
|
#6
|
||||
|
||||
|
Quote:
The problem is when you host several different modded servers (on the same machine) these values does affect both servers. Futhermore, when the client changes from Internet play to Solo these values remain being stored. Moreover, it does only change the defaults from 'KFHumanPawn', so if a modded server uses a subclass it won't have any effect on them. @braindead, it should work as Gartley described, but it brings along some issues as I described above. Last edited by TheMutant; 07-10-2012 at 03:21 PM. |
|
#7
|
||||
|
||||
|
Ah yes, it worked fine in solo, just not multi player. Derp point for me for not double checking.
__________________
Whisky's Workshop ![]() "As you can see here, I'm -ALL ON MY F***ING OWN! Guys where the hell are you?!" |
|
#8
|
|||
|
|||
|
Hey guys I'm a bit stuck so if you could help me with any of this it would be appreciated.
Code:
Class SprintBind extends Interaction;
Function Initialize()
{
//Log("Interaction Initialized");
}
function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
{
local KFHumanPawn Player;
if ((Action == IST_Press) && (Key == IK_PageUp)) { //checks for keypress
ViewportOwner.Actor.ClientMessage("Works" @ Key);
ForEach DynamicActors(class 'KFHumanPawn', Player)
{
Player.default.GroundSpeed = 700.0; //high to make sure I just wasn't noticing the increase
}
}
return false;
}
DefaultProperties
{
bActive=True
}
I get an error when I try to compile and it says the ForEach need an iterator or something and from what I can tell it wants something like, ForEach something.DynamicActors but I have no idea what to put or even if I'm going about it the right way. Thanks in advance if you can help in any way |
|
#9
|
||||
|
||||
|
Interactions are bound to each controller, which in turns gives you access to the pawn, and are handled client side. There's no need to use foreach KFHumanPawn. Using the ViewportOwner.Actor variable gives you access to the PlayerController class of the interaction owner, which in turn gives you access to the Pawn the interaction is bound to.
Last edited by scary ghost; 07-25-2012 at 03:50 PM. |
|
#10
|
|||
|
|||
|
Thanks, I made the mistake of assuming that ViewportOwner.Actor was just used to show the text so I never looked into it. Anyway it's working perfectly now, I just need to restrict certain things and then it's good to go.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|