Thread:Tyolyl/@comment-32689351-20170519023648

using System;using UnityEngine; // Token: 0x0200002E RID: 46public class jiggleBone : MonoBehaviour{    // Token: 0x060000A0 RID: 160 RVA: 0x00005AD4 File Offset: 0x00003CD4    private void Awake    {        Vector3 vector = base.transform.position + base.transform.TransformDirection(new Vector3(this.boneAxis.x * this.targetDistance, this.boneAxis.y * this.targetDistance, this.boneAxis.z * this.targetDistance));        this.dynamicPos = vector;    }     // Token: 0x060000A1 RID: 161 RVA: 0x00005B40 File Offset: 0x00003D40    private void LateUpdate    {        base.transform.rotation = default(Quaternion);        Vector3 dir = base.transform.TransformDirection(new Vector3(this.boneAxis.x * this.targetDistance, this.boneAxis.y * this.targetDistance, this.boneAxis.z * this.targetDistance));        Vector3 vector = base.transform.TransformDirection(new Vector3(0f, 1f, 0f));        Vector3 vector2 = base.transform.position + base.transform.TransformDirection(new Vector3(this.boneAxis.x * this.targetDistance, this.boneAxis.y * this.targetDistance, this.boneAxis.z * this.targetDistance));        this.force.x = (vector2.x - this.dynamicPos.x) * this.bStiffness;        this.acc.x = this.force.x / this.bMass;        this.vel.x = this.vel.x + this.acc.x * (1f - this.bDamping);        this.force.y = (vector2.y - this.dynamicPos.y) * this.bStiffness;        this.force.y = this.force.y - this.bGravity / 10f;        this.acc.y = this.force.y / this.bMass;        this.vel.y = this.vel.y + this.acc.y * (1f - this.bDamping);        this.force.z = (vector2.z - this.dynamicPos.z) * this.bStiffness;        this.acc.z = this.force.z / this.bMass;        this.vel.z = this.vel.z + this.acc.z * (1f - this.bDamping);        this.dynamicPos += this.vel + this.force;        base.transform.LookAt(this.dynamicPos, vector);        if (this.SquashAndStretch)        {            float magnitude = (this.dynamicPos - vector2).magnitude;            float x;            if (this.boneAxis.x == 0f)            {                x = 1f + -magnitude * this.sideStretch;            }            else            {                x = 1f + magnitude * this.frontStretch;            }            float y;            if (this.boneAxis.y == 0f)            {                y = 1f + -magnitude * this.sideStretch;            }            else            {                y = 1f + magnitude * this.frontStretch;            }            float z;            if (this.boneAxis.z == 0f)            {                z = 1f + -magnitude * this.sideStretch;            }            else            {                z = 1f + magnitude * this.frontStretch;            }            base.transform.localScale = new Vector3(x, y, z);        }        if (this.debugMode)        {            Debug.DrawRay(base.transform.position, dir, Color.blue);            Debug.DrawRay(base.transform.position, vector, Color.green);            Debug.DrawRay(vector2, Vector3.up * 0.2f, Color.yellow);            Debug.DrawRay(this.dynamicPos, Vector3.up * 0.2f, Color.red);        }    }     // Token: 0x040000DB RID: 219    public bool debugMode = true;     // Token: 0x040000DC RID: 220    private Vector3 targetPos;     // Token: 0x040000DD RID: 221    private Vector3 dynamicPos;     // Token: 0x040000DE RID: 222    public Vector3 boneAxis = new Vector3(0f, 0f, 1f);     // Token: 0x040000DF RID: 223    public float targetDistance = 2f;     // Token: 0x040000E0 RID: 224    public float bStiffness = 0.1f;     // Token: 0x040000E1 RID: 225    public float bMass = 0.9f;     // Token: 0x040000E2 RID: 226    public float bDamping = 0.75f;     // Token: 0x040000E3 RID: 227    public float bGravity = 0.75f;     // Token: 0x040000E4 RID: 228    private Vector3 force;     // Token: 0x040000E5 RID: 229    private Vector3 acc;     // Token: 0x040000E6 RID: 230    private Vector3 vel;     // Token: 0x040000E7 RID: 231    public bool SquashAndStretch = true;     // Token: 0x040000E8 RID: 232    public float sideStretch = 0.15f;     // Token: 0x040000E9 RID: 233    public float frontStretch = 0.2f;} 