Jump to content

DocMop

Members
  • Posts

    135
  • Joined

  • Last visited

Posts posted by DocMop

  1. @blackheart612

    I have build one simple car and set the spring strength of all wheels to 0.2 for testing purposes.

    http://steamcommunity.com/sharedfiles/filedetails/?id=1337074481

    The car is currently drifting sideways (in direction of the camera on the screenshot) with no friction at all.
    I removed KerbalFoundries for this test but that didn't make a difference.

    After some more testing:
    The grip is missing only in the direction perpendicular to the driving direction. This means I can accelerate and brake but have no sideways grip.

     

    This does not happen when the spring strength is higher. However I have no spring articulation whatsoever. I'll do some mod conflict tests.

     

    Edit:
    No spring articulation problem persists even with stock game.
    No sideways grip under low spring power persists with stock game

  2. In that case the landing point and trajectory are based on the current velocity and gravity only. Which means, as far as I know, it can not show the correct landing spot when the craft is influenced by aerodynamic drag / lift on its future flight path.

    Interesting non the less.

  3. 21 hours ago, the_machemer said:

    Is Physics Range Extender essential or will everything still work more or less without it, maybe just with reduced missile ranges or something? I'm mainly interested in direct fire weapons and just wanna have WWII style close range dogfights, will that still work?

    It will work. But entities will not load before 2km. Even with WW2 style planes, that's not much.

  4. For ease of use and extendibility I would suggest a part config value like "waterPropulsionLevel". That would be a float value which works like this:

    0.0 = No water propulsion
    >0.0 to 1.0 = maximum percentage of part immersion depth for water propulsion to work

    I guess that would catch all possible use cases.

    Then, for propulsion effectiveness you can do the following:

    //immersion = percentage of part immersion in water
    //toDeepFactor = ineffectiveness factor of too deep immersion
    float getWaterPropulsionFactor(float immersion, float toDeepFactor)
    {
      	float propulsionFactor = 0.0;
    	
      	if(immersion <= 0.0) //above water
        		return 0.0;
    	if(waterPropulsionLevel <= 0.0) //no water propulsion
        		return 0.0;
      
      	if(immersion > waterPropulsionLevel) //to deep -> reduced propulsion
        		propulsionFactor = waterPropulsionLevel / (toDeepFactor * immersion);
      	else //not deep enough -> reduced propulsion
        		propulsionFactor = immersion / waterPropulsionLevel;
      	
      	return propulsionFactor;
    }

    Disclaimer: Just a fast prototype, no actual KSP coding experience.
    Warning: toDeepFactor can not be 0.0 because of DBZ!

  5. 1 hour ago, CoilFace said:

    Maybe is a stupid question, but I'm stuck with this. For the "tour bus around KSC" mission how do I make the passengers jump into the bus I made? I have it parked next to them and nothing... I went on EVA and can't see any options or any way to control the passengers. Great mod by the way...

    Use the "switch to next vessel" buttons located right of the number keys to switch to the Kerbals.

  6. 2 hours ago, Citizen247 said:

    You'd know what forces were acting on the craft as a whole, would you not need to just know if those forces rose above the strength of the weakest join, and only calculate physics for each part in those circumstances? It's possible I'm being an idiot in thinking that though.

    Forces are only one way to break inter part connections, there is also torque. In the end you would have to implement lots of extra code to catch any and all exceptions. And I guarantee you that there would still be cases where it would not work as intended. Implementing it this way would just create more bugs at the cost of limited performance gain in exceptional cases only.

  7. 27 minutes ago, Citizen247 said:

    I was wondering about something tangentially related to FAR: FAR calculates aerodynamics for the whole craft rather than each single part as I understand it. Would a similar thing be possible for physics, i.e. only applying physics to the craft as a whole instead of individual parts? It seems computationally wasteful to be calculating physics for individual parts unless the craft is currently breaking up... Most of the time it would seem a better approach to treat the craft as a single "part" and only calculate it as separate ones if it's staging or experiencing forces strong enough to break the connections between parts. Is that possible from a modding perspective?

    How would you know about whether the forces are high enough for breaking or not if you do not calculate the physics for each part?

  8. 1 hour ago, Shadowmage said:

    Good write-up though; I'm glad there is someone who I can converse with intelligently about this stuff :)   Far too often I get the feeling that I'm entirely alone in my understanding of all of this, which is quite depressing considering the game is about rocket science; I would think there would be at least a few other interested parties around the forums who would understand at least the math bits of the code.

    Anytime. At least when my exams are not hindering me :D

     

    Some thoughts:
    In my opinion the response mode (instant / gradual) should be changeable via the game settings menu. There is no need to further clutter the wheel context menus for something thats either globally on or off. And of course the instant mode can very well hide any steering speed tweak-ables. Always a fan of clutter free menus and stuff.

     

    PS: Literals! For a coder the only value between -1 and 1 is 0 :sticktongue:

  9. @Shadowmage

    It should be irrelevant then whether Precision Mode is enabled or not, as long as you always approach the target value rI (minus the different limiters) with the speed steeringReponse from the current value of wheel.steeringAngle.

    Something like this:

    internal override void preWheelPhysicsUpdate()
    {
        base.preWheelPhysicsUpdate();
        float rI = -(part.vessel.ctrlState.wheelSteer + part.vessel.ctrlState.wheelSteerTrim);
        
        if (steeringLocked) { rI = 0; }
        if (invertSteering) { rI = -rI; }
        
        if (rI < 0)
        {
            rI = rI * (1.0 - steeringBias);
        }
        if (rI > 0)
        {
            rI = rI * (1.0 + steeringBias);
        }
        
        rI = Mathf.Clamp(rI, -1.0, 1.0);
        
        float perc = Mathf.Clamp01(Mathf.Abs(wheel.wheelLocalVelocity.z) / (controller.maxSpeed * controller.wheelMaxSpeedScalingFactor));
        float limit = ((1.0 - perc) * steeringLimit) + (perc * steeringLimitHigh);
        
        if (useSteeringCurve)
        {
            limit *= steeringCurve.Evaluate(perc); 
        }
        
        float targetAngle = maxSteeringAngle * rotInput * limit;
        
        wheel.steeringAngle = Mathf.MoveTowards(wheel.steeringAngle, targetAngle, steeringResponse);
    }

    That should always do a smooth transition. And I removed one unnecessary variable (bias). The only issue I can see right now is that steering speed and centering speed could differ in Precision Mode if steeringResponse is faster than the rI gain.

    Warning: I never touched KSP code. Seems like some C derivate though.

     

    Edit:
    You might want to scale steeringResponse dependent on the current speed of the vehicle so it turns the wheels slower if the vehicle is really fast. Could be as simple as this although it should be clamped so it doesn't get too slow maybe:

    float steeringResponseScaled = steeringResponse * (1.0 - perc);
    
    //Optional Clamping to prevent steeringResponseScaled from geting too low
    steeringResponseScaled = Mathf.Clamp(steeringResponseScaled, MIN_STEERING_RESPONSE, steeringResponseScaled);
    
    wheel.steeringAngle = Mathf.MoveTowards(wheel.steeringAngle, targetAngle, steeringResponseScaled);

    However, gameplay testing would have to be done in order to see if the scaling is needed.

     

    Edit2:
    I swear someday I'll do a post without editing it 3 dozens times afterwards -.-

×
×
  • Create New...