mercredi 29 novembre 2017

How to change the lift with deploy and retract?

I solved it myself. parts.cgf MODULE { name = ModuleAnimateGeneric animationName = bigsolarpanel actionGUIName = WingToggle startEventGUIName = Deploy endEventGUIName = Retract } MODULE { name = ModuleLiftingSurface useInternalDragModel = True deflectionLiftCoeff = 2.0 dragAtMaxAoA = 0.5 dragAtMinAoA = 0.0 } MODULE { name = AnimatedWing } source.cs using System; using UnityEngine; namespace Utls_AnimatedWing { public class AnimatedWing : PartModule { private string animationName = "bigsolarpanel"; private Animation anim; private ModuleLiftingSurface liftingSurface; private bool deployOld; private bool deployNow; private bool init = false; public override void OnStart(PartModule.StartState state) { Debug.Log("OnStart() *** AnimatedWing ***"); anim = part.FindModelAnimators(animationName)[0]; liftingSurface = part.FindModuleImplementing(); init = true; ChangeLift(); } private void ChangeLift() { if (anim == null || liftingSurface == null) return; float animTm = anim[animationName].normalizedTime; deployNow = (animTm < 1.0f) ? false : true; if (init==true || (deployNow != deployOld)) { Debug.Log("ChangeLift() *** AnimatedWing ***"); if (deployNow == true) { liftingSurface.deflectionLiftCoeff = 2.0f; liftingSurface.useInternalDragModel = true; } else { liftingSurface.deflectionLiftCoeff = 0.0f; liftingSurface.useInternalDragModel = false; } deployOld = deployNow; if (init == true) init = false; } } public void FixedUpdate() { ChangeLift(); } } } I also have some code that I do not understand, so I need to check it.How to change the lift with deploy and retract?
---------------------------------------------------------------------------
Visit this link to stop these emails: http://zpr.io/nfAVj

Aucun commentaire:

Enregistrer un commentaire