Пример #1
0
        protected override void OnState(SMClient c)
        {
            //normal force
            Vector3 normal = motor[c].groundInfo.surfaceNormal * motor[c].gravity.magnitude * Mathf.Cos(Vector3.Angle(motor[c].gravity, -motor[c].groundInfo.surfaceNormal) * Mathf.Deg2Rad);
            //normal force + gravity
            Vector3 slopeRaw = normal + motor[c].gravity;
            //friction force
            float friction = normal.magnitude * (motor[c].velocity == Vector3.zero ? staticFriction * motor[c].groundInfo.surfaceStaticFriction : dynamicFriction * motor[c].groundInfo.surfaceDynamicFriction);

            //slope force magnitude counting with friction
            float slopeMag = slopeRaw.magnitude - friction;

            //slope force
            Vector3 slope = slopeMag > 0 ? slopeRaw.normalized * maxFallSpeed : Vector3.zero;

            motor[c].velocity = MotorUtil.MovUniVarDir(motor[c].velocity, slope, 0, maxFallSpeed, 0, Mathf.Abs(slopeMag));

            //add platform velocity with friction as max acel
            motor[c].velocity = MotorUtil.MovUniVarDir(motor[c].velocity, motor[c].groundInfo.platformVel, 0, Mathf.Infinity, 0, friction);

            //input direction on surface
            MotorUtil.MotorInputOnSurface(motor[c]);
            base.OnState(c);

            //rotate
            float angle = (motor[c].input != Vector3.zero) ? MotorUtil.GetAngleWithSignal(motor[c].transform.forward, motor[c].lookDir) : 0;

            motor[c].angularVelocity.y = MotorUtil.MovUniVar(motor[c].angularVelocity.y, angle / Time.fixedDeltaTime, minAngVel, maxAngVel, minAngAcel, maxAngAcel);

            motor[c].angularVelocity += motor[c].groundInfo.platformAngVel;


            //motor.transform.up = -cMotor.gravidadeDirecao.normalized; //try putting perpendicular to the ground
        }
Пример #2
0
        protected override void OnState(SMClient c)
        {
            float vel       = motor[c].velocity.magnitude / Time.fixedDeltaTime;
            float crrMinVel = (!ignorePrevVel && vel < minVel) ? vel : minVel;
            float crrMaxVel = (!ignorePrevVel && vel > maxVel) ? vel : maxVel;

            Vector3 velDes;

            if (motor[c].input != Vector3.zero)
            {
                velDes = motor[c].input * crrMaxVel;
            }
            else if (motor[c].velocity != Vector3.zero)
            {
                velDes = motor[c].velocity.normalized * crrMinVel;
            }
            else
            {
                velDes = motor[c].lookDir * crrMinVel;
            }

            motor[c].velocity = MotorUtil.MovUniVar(motor[c].velocity, velDes, crrMinVel, crrMaxVel, minAcel, maxAcel);
        }
Пример #3
0
        public override void ProcessMovement(Motor motor)
        {
            float vel       = motor.velocity.magnitude / Time.fixedDeltaTime;
            float crrMinVel = (!ignorePrevVel && vel < minVel) ? vel : minVel;
            float crrMaxVel = (!ignorePrevVel && vel > maxVel) ? vel : maxVel;

            Vector3 velDes;

            if (motor.input != Vector3.zero)
            {
                velDes = motor.input * crrMaxVel;
            }
            else if (motor.velocity != Vector3.zero)
            {
                velDes = motor.velocity.normalized * crrMinVel;
            }
            else
            {
                velDes = motor.lookDir * crrMinVel;
            }

            motor.velocity = MotorUtil.MovUniVar(motor.velocity, velDes, crrMinVel, crrMaxVel, minAcel, maxAcel);
        }
Пример #4
0
 void OnControllerColliderHit(ControllerColliderHit hit)
 {
     MotorUtil.KillVector(velocity, hit.normal);
 }
Пример #5
0
        public override void ProcessMovement(Motor motor)
        {
            base.ProcessMovement(motor);

            motor.velocity = MotorUtil.MovUniVarDir(motor.velocity, motor.gravity.normalized * terminalVelocity, 1, terminalVelocity, 0, motor.gravity.magnitude);
        }
Пример #6
0
 protected override void OnState(SMClient c)
 {
     MotorUtil.MotorInputOnSurface(motor[c]);
     base.OnState(c);
 }
Пример #7
0
        protected override void OnState(SMClient c)
        {
            base.OnState(c);

            motor[c].velocity = MotorUtil.MovUniVarDir(motor[c].velocity, motor[c].gravity.normalized * terminalVelocity, 1, terminalVelocity, 0, motor[c].gravity.magnitude);
        }
Пример #8
0
 public override void OnStateEnter(SMClient c)
 {
     MotorUtil.NavAgent(motor[c], this);
 }
Пример #9
0
 public override void OnStateEnter(Motor motor)
 {
     MotorUtil.NavAgent(motor, this);
 }
Пример #10
0
 public override void ProcessMovement(Motor motor)
 {
     MotorUtil.MotorInputOnSurface(motor);
     base.ProcessMovement(motor);
 }