using Sandbox; public sealed class RagdollController : Component { [Group("Setup"), Order(-100), Property] public ModelPhysics bodyPhysics { get; set; } [Group("Setup"), Order(-100), Property] public SkinnedModelRenderer bodyRenderer { get; set; } [Group("Config"), Order(0), Property] public bool isLocked { get; set; } // [Property] public Collider Collider; [Sync] public new bool Enabled { get => bodyPhysics.Enabled; private set { bodyPhysics.Enabled = value; bodyPhysics.MotionEnabled = value; bodyRenderer.UseAnimGraph = !value; // Collider.Enabled = !value; if ( !value ) { WorldPosition = bodyRenderer.WorldPosition; bodyRenderer.LocalPosition = Vector3.Zero; } } } // protected override void OnStart() // { // Collider = GetComponent(); // // Log.Info(Collider.Enabled); // } protected override void OnUpdate() { if ( Network.IsOwner ) { if (Input.Pressed( "Ragdoll" )) { Enabled = !Enabled; } } var bodyLock = new PhysicsLock(); bodyLock.Pitch = isLocked; bodyLock.Yaw = isLocked; bodyLock.Roll = isLocked; bodyLock.X = isLocked; bodyLock.Y = isLocked; bodyLock.Z = isLocked; bodyPhysics.Locking = bodyLock; bodyPhysics.MotionEnabled = !isLocked; WorldPosition = bodyRenderer.WorldPosition; } }