Greetings,
I have developed rough code for controlling a biplane vehicle; however, it doesn't function correctly. It seems as if the modifiers I have applied are acting on it globally, not locally. In-game, when I enter the vehicle, it initially seems to control as I wish it to, but further testing reveals it's not controlling how it should.
I think my main issue is that I am unfamiliar with UnrealScript and UDK - I believe I am using the wrong methods to manipulate the biplane's physics.
Any help? This is rather urgent. Code attached below.
Thanks.
I have developed rough code for controlling a biplane vehicle; however, it doesn't function correctly. It seems as if the modifiers I have applied are acting on it globally, not locally. In-game, when I enter the vehicle, it initially seems to control as I wish it to, but further testing reveals it's not controlling how it should.
I think my main issue is that I am unfamiliar with UnrealScript and UDK - I believe I am using the wrong methods to manipulate the biplane's physics.
Any help? This is rather urgent. Code attached below.
Code:
class AR_Aircraft extends UTAirVehicle; /* etc */ var float AR_Lift, AR_Forward, AR_MaxLift, AR_TurnSpeed; var Vector AR_UpwardsNormal; var Rotator AR_Rotation; /* etc */ // Code in development; exact values to be tweaked. simulated function AirRaidKinematics(float DeltaTime) { local Vector AR_ForceApplication, AR_ForceRotation, AR_ForwardsNormal; // While there is a player in the biplane: if (PlayerController(Controller) != None) { AR_ForwardsNormal = Normal(Vector(Rotation)); // Calculate UpwardsNormal of the plane so I can lift it in that direction: AR_UpwardsNormal.X = - AR_ForwardsNormal.Z; AR_UpwardsNormal.Y = AR_ForwardsNormal.Y; AR_UpwardsNormal.Z = AR_ForwardsNormal.X; // Calculate AR_Rotation so we know how the plane lifts: AR_ForceRotation.X = 35 * Steering; // Steering is between -1 and 1 AR_ForceRotation.Y = 30 * Throttle; // Throttle is between -1 and 1 AR_ForceRotation.Z = 12 * Steering; // Rise is between -1 and 1 AR_Forward = 500; // Will allow variable forwards speed later // Calculate lift for the biplane: AR_Lift = AR_Forward * 1.5 * Abs(Cos(Rotation.Pitch)); if (AR_Lift > AR_MaxLift) AR_Lift = AR_MaxLift; // This is meant to calculate the applied force for the biplane, // to give it lift upwards relative to its normal: AR_ForceApplication.X = AR_UpwardsNormal.X * AR_Lift + AR_Forward; AR_ForceApplication.Y = AR_UpwardsNormal.Y * AR_Lift; AR_ForceApplication.Z = AR_UpwardsNormal.Z * AR_Lift; // Propel the biplane AddForce(AR_ForceApplication); // Rotate the biplane AddTorque(AR_ForceRotation); } else { AR_Lift = 0; AR_Rotation.Pitch = 0; AR_Rotation.Yaw = 0; AR_Rotation.Roll = 0; } } simulated function Tick(float DeltaTime) { AirRaidKinematics(DeltaTime); Super.Tick(DeltaTime); } /* etc */
Comment