Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: FlareBaffled on January 30, 2007, 12:54:55 pm
-
Reading through the stuff about making thrusters that could be moved got me wondering! My modding background comes from flightsims, and one of the things I really found aided immersion was having detailed cockpits...with moving controls.
A flight control stick and 'rudder' pedals that moved when you moved your own joystick.
Could this code be used for the same thing? You would need to have a 'parent' part of the stick that rotated forwards and backwards as the ship pitched up and down, with a 'child' part that moved left and right as the ship rolled...assuming you can have a part rotate in this 'nested' fashion! Rudder pedals can then also be rotated when the ship is yawed left or right. The final icing on the cake would be a throttle control too :D
Is this possible ?
-
I'll bet that if it isn't already, it will be soon with all the scripting stuff available.
-
I'm guessing you're refering to features such as the 3D cockpit in MS FlightSim 9 (or if you got FSX:D which is what I want though I'm not getting-its already slow in FS9, and FSX would just slaughter my machine at any reasonable settings).
I would recommend against it, actually. One of the cool things about FreeSpace is the incredibly helpful and uncluttered cockpit. I find that stuff cool in FlightSim but not FreeSpace; Freespace is more efficent and its more about looking through your HUD then looking out the cockpit. BUt whatever... I don't use the cockpits from the game.
-
ive done this on one ship with cutting edge builds. so its very possible. my code is far from perfect and the scripting system is always subject to change. heres my code, it worked on bobs last build (which as far as i know is in cvs).
$Subsystem: stick_pitch, 1,1.0
$animation:script
[
Angs = stick_pitch.Orientation
d = Self.DesiredRotationalVelocity.x /60
if(Angs.p < d)then
Angs.p = Angs.p + Self.RotDamp * ba.getFrametime()
elseif(Angs.p > d)then
Angs.p = Angs.p - Self.RotDamp * ba.getFrametime()
end
stick_pitch.Orientation = Angs
]
$Subsystem: pilot_stick, 1,1.0
$animation:script
[
Angs = pilot_stick.Orientation
e = Self.DesiredRotationalVelocity.y /5
f = Self.DesiredRotationalVelocity.z /1
if(Angs.h < e)then
Angs.h = Angs.h + Self.RotDamp * ba.getFrametime()
elseif(Angs.h > e)then
Angs.h = Angs.h - Self.RotDamp * ba.getFrametime()
end
if(Angs.b < f)then
Angs.b = Angs.b + Self.RotDamp * ba.getFrametime()
elseif(Angs.b > f)then
Angs.b = Angs.b - Self.RotDamp * ba.getFrametime()
end
pilot_stick.Orientation = Angs
]
$Subsystem: copilot_stick, 1,1.0
$animation:script
[
copilot_stick.Orientation = Angs
]
$Subsystem: throttle, 1,1.0
$animation:script
[
Angs = throttle.Orientation
d = Self.DesiredVelocity.z*1.4 - 110
Angs.p = d * ba.getFrametime()
throttle.Orientation = Angs
]
now this is for what youd find on a passenger jet, flight yoke and throttle.
the throttle stick is just a subobject with the center at the pivot point. stick pitch is the point at which the stick columb rotates, the pilot and copilot yokes are children of the stick pitch. i havet done rudders cause you never be able to see them. its crude and might not work on every model without tweaking. post shaders wel be able to do animated panels with shader based rtt.
-
Are we talking about thrust vectoring engines like the vampire and panther have?
-
those are possible too :D
-
WOOHOOO now one of these days you'll have to show me how to get that to work :nod:
-
I have a few ideas for multi-axis control of ships... will the code actually make the engines change in direction partially? Like if the ship I have goes forward on the normal axis and I can straff to the left... will the engine be able to rotate the proper amount for the speed?
-
straifing is a ground attack flight manuver, i dont know how it became gamerspeak for moving left or right.
anyway you have all those physics vars toplay with. more than enough to animate like mad. i suggest you all start learning lua.
-
I know both meanings of it...
But anyways, Nuke... I don't know lua (and have no real reason to learn it) and I was wondering if I could have a ship that will maneuver with an engine at different angles. could be cool to do that with a next-gen ship.
-
I know both meanings of it...
But anyways, Nuke... I don't know lua (and have no real reason to learn it) and I was wondering if I could have a ship that will maneuver with an engine at different angles. could be cool to do that with a next-gen ship.
That would the be the vampire, panther :)
-
well ive done thrust vectoring on some ships. but to make it feel right it would need to be tweaked so as to manuver accordingly. you do have acess to the velocity vector, so that shouldnt be too hard.
and lua was a fairly easy language to learn. the manual sucks but the lua wiki makes up for it. after looking at a few examples and by tweaking them i managed to learn quite abit.
-
Most of the physics variables should be in the physics class. But it is perfectly possible for redundant variables to exist, I just greatly dislike it. I know that I changed some of the stuff Bobb imported to CVS for similar reasons, other stuff I just grimaced and left in because I didn't feel strongly enough about it to take it out or change ti.
-
I can see I am going toDoes have to delve into the scripting Wiki when I get in from work tonight!
I will set up the model hieracrchy, and have a go at this. Do the parts need to be arranged in any particular way, or should they all just be child objects of the cockpit model?
-
Ok question and thought time :lol:
Ok what build do you need to do scripting? (whats the best build yet?) link please :)
second from what it looks the scripts go into the table presumably in the subsystems, correct?
third the actually script for the vampire as a start, could somone write the script, i think nuke's got the right idea but i have no clue on the actually code and vectors.
- a roll to port will cause the port engine to pitch down and the starboard engine to pitch up
- a roll to star will cause the port engine to pitch up and the starboard engine to pitch down
- pitch down will cause both engines to pitch up
- pitch up will cause both engines to pitch down
- I'm guessing the engine change angles would be opposite to ships change angle.
- I'm also guessing that the only difference between the port and starboard scripts would be that the angle would be negative of each other (i.e. if one is going 20 degrees the other is going -20 degrees
for those wondering or don't know what the vampire is
(http://img.photobucket.com/albums/v356/Shodan_AI/Model%20Display/vampire-showoff.jpg)
-
I can see I am going toDoes have to delve into the scripting Wiki when I get in from work tonight!
I will set up the model hieracrchy, and have a go at this. Do the parts need to be arranged in any particular way, or should they all just be child objects of the cockpit model?
mine are set up as child of the ship i think. sence they are subobjects they will render properly behind the glass.
*edit*
btw this (http://www.hard-light.net/forums/index.php/topic,43812.0.html) thread should have the builds you need to get my code to work.
*edit again*
just tested it and theres a possibility this may also work under one of wmcs latest scripting builds with some modifivations. mainly the self.insertphysicsvarher needs to be changed to self.Physics.insertphysicsvarhere