SphereCollider IGenHumanColliders.AddSphere(Transform bone, double x, double y, double z, double radius) { // bone.gameObject.layer = layers.BitNumber_Characters; var sc = bone.gameObject.AddComponent <SphereCollider>(); sc.center = V3(x, y, z); sc.radius = (float)radius; /* * * if (dbg.DebugDrawColliders) * { * var visual = * fun.meshes.CreateSphere(new DtSphere { radius = radius }) * .SetStandardShaderTransparentColor(dbg.Colors[sc.GetInstanceID().Abs() % dbg.Colors.Length].WithA(0.2)) * .transform; * visual.position = bone.position + sc.center.AsWorldVec(bone); * visual.SetParent(bone); * visual.localScale = V3(1); * }*/ var cd = new GenColliderData { Type = GenColliderType.Sphere, Sphere = sc, Trans = bone }; _colliderByInstanceId[sc.GetInstanceID()] = cd; if (!_collidersByBoneName.ContainsKey(bone.name)) { _collidersByBoneName[bone.name] = new HashSet <GenColliderData>(); } _collidersByBoneName[bone.name].Add(cd); _gcc.RegisterCollider(sc, _human); return(sc); }
CapsuleCollider IGenHumanColliders.AddCapsule(Transform bone, double x, double y, double z, double radius, double height, int direction) { // bone.gameObject.layer = layers.BitNumber_Characters; var cc = bone.gameObject.AddComponent <CapsuleCollider>(); cc.center = V3(x, y, z); cc.radius = (float)radius; cc.height = (float)height; cc.direction = direction; /* * * if (dbg.DebugDrawColliders) * { * var visual = * fun.meshes.CreateCapsule(new DtCapsule { height = height - radius * 2, radius = radius }) * .SetStandardShaderTransparentColor(dbg.Colors[cc.GetInstanceID().Abs() % dbg.Colors.Length].WithA(0.5)) * .transform; * visual.position = bone.position + cc.center.AsWorldVec(bone); * visual.SetParent(bone); * visual.localRotation = Quaternion.LookRotation(v3.forward, v3.up) * RotationByIndex[cc.direction]; * visual.localScale = V3(1); * } */ var cd = new GenColliderData { Type = GenColliderType.Capsule, Capsule = cc, Trans = bone }; _colliderByInstanceId[cc.GetInstanceID()] = cd; if (!_collidersByBoneName.ContainsKey(bone.name)) { _collidersByBoneName[bone.name] = new HashSet <GenColliderData>(); } _collidersByBoneName[bone.name].Add(cd); _gcc.RegisterCollider(cc, _human); return(cc); }