Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Cockpit game object  (Read 1153 times)

0 Members and 1 Guest are viewing this topic.

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Cockpit game object
« on: August 26, 2020, 12:17:35 AM »

The cockpit game object has a bunch of extra components that we don't want in the aircraft gameobject.

These define the default keyboard mapping for the aircraft.

They have to be in the cockpit class and not the aircraft as we don't want pressing a key to affect every other aircraft in the game. There will only be one cockpit class in use at any one time, the one the player is sat in.

To define a key mapping , you add an InputEventComponent

This can be added in the game object editor , or you can do it in any text editor.

An example is here

Code: [Select]
InputEventComponent_1
InputEventComponent
1
Root#Root#SpitfireMkIXcc:GameComponents
0
4
Button String Up
Event String LeanForward
Type String Button
Modifier String LeftShift


Going though it line by line

InputEventComponent_1The name of the component, must be unique
InputEventComponentThe type of the component
1Number of direct connections, this component only connects to the root container
Root#Root#SpitfireMkIXcc:GameComponentsThe connection to root
0Number of list connections , for this component there are none
4Number of parameters, this component has 4
Button String UpParameter 0 has the name Button which defines which button to use, and the key is the Up key (up arrow)
Event String LeanForwardParameter 1 has the name Event , and is the event to send to the games code
Type String ButtonParameter 2 has the name Type , and defines how the key press is treated, this is a button press
Modifier String LeftShiftParameter 3 has the name Modifier , and specifies any modifiers in use

So this component sends the event LeanForward to the game when the player presses left shift and the up arrow

I will publish a list of events the code knows about when I have enough of them in to make it useful

Note these are the default  input settings . In game you can replace them with joystick buttons etc.
Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Cockpit game object
« Reply #1 on: August 26, 2020, 12:28:18 AM »

Cockpit animations

Animating items in the cockpit is done by adding animation components to the cockpit game object, again you can do this is the editor or you can do it in a text editor

So far I have several components defined

CVTAnimatorComponent is used where you would have used Aircraft.Cvt in java code.

So this line of Java ....

Code: [Select]
this.mesh.chunkSetAngles("STREL_ALT_LONG", 0.0F, 0.0F, cvt(interp(this.setNew.altimeter, this.setOld.altimeter, paramFloat), 0.0F, 9144.0F, 0.0F, -10800.0F));
becomes this block of text in the cockpit game object

Code: [Select]
CVTAnimatorComponent_1
CVTAnimatorComponent
1
Root#Root#SpitfireMkIXcc:GameComponents
0
7
TargetMesh String STREL_ALT_LONG
ControlValue String Altitude
Minimum Float 0
Maximum Float 9144.0
Start Float 0
Finish Float -10800.0
Flags Int 1


For simpler animations I have the SmoothedAngleAnimatorComponent

Code: [Select]
this.mesh.chunkSetAngles("Z_Throtle1", -64.545403F * interp(this.setNew.throttle, this.setOld.throttle, paramFloat), 0.0F, 0.0F);
becomes

Code: [Select]
SmoothedAngleAnimatorComponent_5
SmoothedAngleAnimatorComponent
1
Root#Root#SpitfireMkIXcc:GameComponents
0
5
Plane Int 4
Scale Float -64.545403
Smoothing Float 0.8
Mesh String Z_Throtle1
Control String ThrottleSetting

The variable Plane defines which 3D plane you want the rotation to be applied in.

I am adding more animators all the time.
Logged

Stainless

  • moderator
  • member
  • Offline Offline
  • Posts: 1534
Re: Cockpit game object
« Reply #2 on: August 26, 2020, 12:34:11 AM »

Aircraft Settings

All aircraft have certain differences that need to defined in the cockpit class rather than the aircraft class because they relate to player input.

These are added in an AircraftSettingsComponent

This just a list of string/ value pairs that get stored in the aircraft state component and can be queried by anything.

An example is here

Code: [Select]
AircraftSettingsComponent_1
AircraftSettingsComponent
1
Root#Root#SpitfireMkIXcc:GameComponents
0
3
ElevatorTrimMax Float 0.5
ElevatorTrimMin Float -0.5
ThrottleMax Float 1.0


ThrottleMax set to 1 means this aircraft does not have an afterburner. It's a Spitfire IXc . Hmmm spit with an afterburner ......... ~{don't get distracted}~

You can put anything in here and use it in animators et al.
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 24 queries.