View Full Version : Change the MouseSensitivity
Psyke
09-21-2010, 12:48 PM
Hi again!
I am having some problems with acessing other classes.
I Have 3 classes:
- TorInfo
- TorPlayerController
- TorPawn
In TorPlayerController I have one Float variable called: TorMouseSensitivity
What I want is to change the MouseSensitivity value from the TorPawn class and not from the TorPlayerController class.
When I go through the directory: C:\UDK\UDK-2010-05\UDKGame\Config, and open the file: "DefaultInput" and change the value of the MouseSensitivity, with works, but I need to change that value at RealTime.
I Tried that, but no good results, only errors:
//In TorPawn class
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
TorPlayerController.PlayerInput.MouseSensitivity = TorMouseSensitivity;
}
And that too:
//In TorPawn class
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
PlayerControllerClass.PlayerInput.MouseSensitivity = TorMouseSensitivity;
}
and that...
//In TorPawn class
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
TorPlayerController(WorldInfo.Game).PlayerInput.Mo useSensitivity = TorMouseSensitivity;
}
Any kind of help is useful, thanks a lot!
seenooh
09-21-2010, 12:56 PM
What are the errors?
Psyke
09-21-2010, 01:01 PM
For the first and third try:
Error, 'TorPlayerController' : Bad Command or Expression.
For the second try:
Error, 'PlayerControllerClass' : Bad Command or Expression.
SeanO'Connor
09-21-2010, 01:29 PM
What I want is to change the MouseSensitivity value from the TorPawn class and not from the TorPlayerController class.
You can access the controller from the pawn itself, and typecast it to retain all your custom functionality:
In TorPawn:
TorPlayerController(Controller).PlayerInput.MouseS ensitivity=TorMouseSensitivity;
I'm pretty sure you can always get any pawn's controller via the Controller variable. In case you are wondering, this variable is declared in Pawn.uc with the following line:
/** Controller currently possessing this Pawn */
var editinline repnotify Controller Controller;
Psyke
09-21-2010, 02:08 PM
Hey, thanks for the help.
I tried that you said but I am getting 1 error and 1 warning:
Error, Unrecognized member 'MouseSensitivity' in class 'TorPlayerController'
Warning, Variable declaration: 'Controller' conflicts with previously defined field in 'Pawn'
If someone knows what's going on with the code, pls let me know.
:(
SeanO'Connor
09-21-2010, 02:21 PM
I think you will need to show the code. I just made sure, and MouseSensitivity is a member of the PlayerInput class, and there is an instance of PlayerInput as a member of the PlayerController class. Assuming TorPlayerController extends from PlayerController, you should have access to those variables.
Also, from the looks of it, you have another variable named Controller somewhere in your TorPawn class. Or perhaps there is a typo somewhere that makes it think so. Nevertheless, seeing the code will help.
Psyke
09-21-2010, 02:30 PM
Ok, here is the 2 codes:
TorPlayerController.uc
class TorPlayerController extends UTPlayerController;
var float TorMouseSensitivity;
defaultproperties
{
Name="Default__TorPlayerController"
TorMouseSensitivity = 5.0;
}
TorPawn.uc
class TorPawn extends UTPawn;
var editinline repnotify Controller Controller;
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
TorPlayerController(Controller).MouseSensitivity = TorMouseSensitivity;
}
defaultproperties
{
Name="Default__TorPawn"
}
seenooh
09-21-2010, 03:57 PM
I would suggest that you extend UTPlayerInput and modify the sensitivity their directly in you default properties.
class TorPlayerInput extends UTPlayerInput within TorPlayerController;
var float TorMouseSensitivity;
default properties
{
TorMouseSensitivity = 1.0;
MouseSensitivity = TorMouseSensitivity;
}
And then in your controller class, you set your input controller class to the new one in the def prop block.
InputClass= TorPlayerInput;
:)
Psyke
09-21-2010, 04:26 PM
Thanks for the help, but if I want to change that MouseSensitivity value from TorPawn.uc?
How do I do that?
I'm asking that because there will be functions in the TorPawn that must change the MouseSensitivity value, that's why I need to change the value from that class, I want to change in REALTIME and not in defaultproperties.
SeanO'Connor
09-21-2010, 06:23 PM
class TorPawn extends UTPawn;
var float TorMouseSensitivity;
simulated function PostBeginPlay()
{
Super.PostBeginPlay();
TorPlayerController(Controller).PlayerInput.MouseS ensitivity = TorMouseSensitivity;
}
defaultproperties
{
Name="Default__TorPawn"
TorMouseSensitivity=yourvalue
}
Change your code to the above and it will work. You didn't need to redeclare Controller, I was just showing you how it was declared in Pawn. Also, you left out the .PlayerInput, so it couldn't find MouseSensitivity. Be sure to replace yourvalue in the default properties with a floating point number of your choice.
seenooh
09-22-2010, 01:41 AM
To make things easy for you, make an exec function that changes the mouse sensitivity in the new player input class. Then use the ConsoleCommand() function to execute it from anywhere easily.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.