{
  "code": "var Vector3 = Laya.Vector3;\r\nimport { ScenceManager } from \"./ScenceManager\";\r\nimport { ColliderLay } from \"./Runner\";\r\nexport class Rigbody extends Laya.Script3D {\r\n    constructor() {\r\n        super(...arguments);\r\n        this.m_life = 1;\r\n        this.m_time = 0;\r\n        this.m_resistance = 0.03;\r\n        this.OnLand = true;\r\n        this.hit = new Laya.HitResult();\r\n        this.offestY = 0;\r\n        this.g = 1;\r\n        this.curdir = new Vector3();\r\n        this.curPos = new Vector3();\r\n    }\r\n    onAwake() {\r\n        this.m_sprite = this.owner;\r\n        Laya.timer.once(this.m_life * 1000, this, this.OnEnd);\r\n        Laya.timer.frameLoop(1, this, this.Update);\r\n    }\r\n    OnEnd() {\r\n        Laya.timer.clearAll(this);\r\n        this.destroy();\r\n    }\r\n    CheckPlaneCollider() {\r\n        var startpoint = new Vector3(this.m_sprite.transform.position.x, this.m_sprite.transform.position.y, this.m_sprite.transform.position.z);\r\n        var dir = new Vector3(0, -1, 0);\r\n        var ray = new Laya.Ray(startpoint, dir);\r\n        if (ScenceManager.Instance.GameScence.physicsSimulation.rayCast(ray, this.hit, 0.5)) {\r\n            if (this.hit.collider.collisionGroup != ColliderLay.Plane)\r\n                return;\r\n            var dis = this.m_sprite.transform.position.y - this.hit.point.y;\r\n            if (this.OnLand) {\r\n                if (dis > 0.15) {\r\n                    this.OnLand = false;\r\n                    return;\r\n                }\r\n                else {\r\n                    this.m_sprite.transform.position = new Vector3(this.m_sprite.transform.position.x, this.hit.point.y + 0.1, this.m_sprite.transform.position.z);\r\n                }\r\n            }\r\n            else {\r\n                if (dis < 0.01) {\r\n                    this.OnLand = true;\r\n                    this.OnPlane();\r\n                }\r\n            }\r\n        }\r\n        else {\r\n            this.OnLand = false;\r\n        }\r\n    }\r\n    OnPlane() {\r\n    }\r\n    gravity() {\r\n        this.offestY -= this.g * this.m_time * this.m_time;\r\n    }\r\n    AddVelocity(_dir, _speed) {\r\n        Vector3.normalize(_dir, this.curdir);\r\n        Vector3.scale(this.curdir, _speed, this.curdir);\r\n        Laya.timer.frameLoop(1, this, this.Move);\r\n    }\r\n    Update() {\r\n        this.m_time += 0.012;\r\n        this.gravity();\r\n        this.CheckPlaneCollider();\r\n    }\r\n    Move() {\r\n        var mpos = this.m_sprite.transform.position;\r\n        Vector3.add(mpos, this.curdir, this.curPos);\r\n        if (this.OnLand) {\r\n            this.curPos = new Vector3(this.curPos.x, this.m_sprite.transform.position.y, this.curPos.z);\r\n        }\r\n        else {\r\n            Vector3.add(this.curPos, new Vector3(0, this.offestY, 0), this.curPos);\r\n        }\r\n        this.m_sprite.transform.position = this.curPos;\r\n        Vector3.lerp(this.curdir, new Vector3(0, 0, 0), this.m_resistance, this.curdir);\r\n        if (Vector3.scalarLength(this.curdir) < 0.01) {\r\n            Laya.timer.clear(this, this.Move);\r\n        }\r\n    }\r\n}\r\n",
  "references": [
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/ScenceManager.ts",
    "C:/Users/admin/Desktop/runner/src/Scripts/Game/Runner.ts"
  ]
}
