Unrealscript self-study note (1), add the custom configuration file config (User) to the class );

Source: Internet
Author: User


Unrealscript self-study note (1), add the custom configuration file config (User) to the class );

Author: 文 2011/7/29

 

A large number of configuration files are used in udk. The parameters in these configuration files correspond to a certain script variable. The biggest benefit of using the configuration file is, we can change the default values of some parameters at any time, instead of re-compiling our udk script, it can also be used for gamers to set some parameters and save them, the udk will automatically load these configurations the next time you open the game.

In the epic official documentation has the following articles, made a detailed introduction: http://udn.epicgames.com/Three/ConfigurationFiles.html

This article introduces the application of the configuration file, but it is not clear how to add a custom configuration file to the custom class.

Here we will give an example of the tutorialpawn class in [udk games getting started]. udk. part.4.first. unrealscript,

 

class TutorialPawn extends UTPawn;simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV){local vector start,end,hitLocation, hitNormal;local actor a;start = Location;if(Controller != none){end = Location - Vector(Controller.Rotation) * 192.0f;}else{end = Location - Vector(Rotation) * 192.0f;}a = Trace(hitLocation, hitNormal, end, start, false);if ( a != none ){out_CamLoc = hitLocation;}else{out_camLoc = end;}out_CamRot = Rotator(Location - out_Camloc);return true;}defaultproperties{Begin Object Name=WPawnSkeletalMeshComponentbOwnerNoSee = falseEnd ObjectName="TutorialPawn"}

Calccamera is a function used to calculate the third-person perspective. The hardcoded value 192.0f indicates the distance from the camera to the role. We can write it into the configuration file, this makes it easier for players to modify the settings, so we can handle the issue as follows:

class TutorialPawn extends UTPawn config(User);var config float CameraDistance;simulated function bool CalcCamera(float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV){local vector start,end,hitLocation, hitNormal;local actor a;start = Location;if(Controller != none){end = Location - Vector(Controller.Rotation) * CameraDistance;}else{end = Location - Vector(Rotation) * CameraDistance;}............................

Add a Config (User) setting after the class declaration. Here, user refers to the ini configuration file name, which can be customized. This file is in D: \ udk \ UDK-2011-05 \ udkgame \ config directory. The file is named udkuser. ini. You must add a udk before it. Otherwise, the system cannot identify it. This naming method is very strange. For example, config (game), which refers to reading the udkgame. ini file.

In the udkuser. ini file, we add two lines at the end of the file:

[TutorialGame.TutorialPawn]CameraDistance = 192.0f

[Tutorialgame. tutorialpawn]
Cameradistance = 192.0f [tutorialgame. tutorialpawn]-> [package name. Class Name]

 

VaR config float cameradistance; this is used to configure variables. You must add the keyword config.

After compilation, the system can automatically read this configuration parameter.

 

========================================================== ========================================================== ======================

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.