void ResetAfterTimeout() { Wait(ResetTimeout); _rb.SetMotionType(RigidBodyMotionType.MotionTypeKeyframed); _rb.SetAngularVelocity(Vector.Zero); _rb.SetLinearVelocity(Vector.Zero); _rb.SetPosition(ObjectPrivate.InitialPosition); _rb.SetOrientation(ObjectPrivate.InitialRotation); _rb.SetMotionType(RigidBodyMotionType.MotionTypeDynamic); }
bool ResetToInitialPosition(RigidBodyComponent rigidBody) { ObjectPrivate objectPrivate = ScenePrivate.FindObject(rigidBody.ComponentId.ObjectId); if (objectPrivate != null && objectPrivate.IsValid) { try { var motionType = rigidBody.GetMotionType(); WaitFor(rigidBody.SetMotionType, RigidBodyMotionType.MotionTypeKeyframed); rigidBody.SetAngularVelocity(Vector.Zero); rigidBody.SetLinearVelocity(Vector.Zero); rigidBody.SetOrientation(objectPrivate.InitialRotation); rigidBody.SetPosition(objectPrivate.InitialPosition); rigidBody.SetMotionType(motionType); return(true); } catch { Log.Write(LogLevel.Error, __SimpleTag, "Position Reset: error resetting object position."); } } return(false); }
void ResetToInitialPosition() { var motionType = RigidBody.GetMotionType(); WaitFor(RigidBody.SetMotionType, RigidBodyMotionType.MotionTypeKeyframed); RigidBody.SetAngularVelocity(Vector.Zero); RigidBody.SetLinearVelocity(Vector.Zero); RigidBody.SetOrientation(ObjectPrivate.InitialRotation); RigidBody.SetPosition(ObjectPrivate.InitialPosition); RigidBody.SetMotionType(motionType); }
public override void Init() { if (ObjectPrivate.TryGetFirstComponent(out RigidBody)) { RigidBody.Subscribe(CollisionEventType.RigidBodyContact, OnCollision); RigidBody.SetMotionType(RigidBodyMotionType.MotionTypeDynamic); } else { Log.Write(LogLevel.Error, "Choppable couldn't find a RigidBody component. That component is needed in order to detect when an avatar walks into them"); return; } Pieces = ScenePrivate.FindReflective <INamedRigidThing>("Kitchen.Chopped").ToList <INamedRigidThing>(); Log.Write(LogLevel.Info, $"Found {Pieces.Count()} chopped bits"); Axe = ScenePrivate.FindReflective <IChopper>("Kitchen.Chopper").FirstOrDefault(); Log.Write(LogLevel.Info, $"Found Axe: {Axe.GetName()}"); }