Announcement

Collapse
No announcement yet.

Relative Physics Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Try replacing this:

    Code:
    // 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


    with...

    Code:
    // Calculate AR_Rotation so we know how the plane lifts:
    		AR_ForceRotation.X = 100 * 35 * Steering; // Steering is between -1 and 1	
    		AR_ForceRotation.Y = 100 * 30 * Throttle; // Throttle is between -1 and 1
    		AR_ForceRotation.Z = 100 * 12 * Steering; // Rise is between -1 and 1
    Because while I was working with some camera tilting functionality, I wanted to rotate it on the X axis to roll by 15 degrees... I noticed that when I scale it up to 1500, it gives me the rotation I wanted... I don't know why this is happening, it may not help your case, but you could try and perhaps you have a similar issue to mine.

    Leave a comment:


  • replied
    It would help greatly if you could tell us what that does, how it behaves and how it's meant to behave, otherwise its difficult to know what to look for.

    However, from a quick once-over, a few possibilities arise:

    For one, on this line:
    AR_ForceRotation.Z = 12 * Steering
    The comment would make it seem as though you meant to type:
    AR_ForceRotation.Z = 12 * Rise

    Secondly, Rotation values are not stored in Radians OR Degrees, but UnrealRot values. I'm not certain that Cos works on UnrealRots though, so something to look into, you mave have to convert units.

    Leave a comment:


  • started a topic Relative Physics Problem

    Relative Physics Problem

    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.

    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 */
    Thanks.
Working...
X