Wearable Only
Describes a request for haptic feedback.
//typescriptconst MotionControllerModule = require("LensStudio:MotionControllerModule")@componentexport class NewScript extends BaseScriptComponent { @input @allowUndefined target: SceneObject @input setRotation: boolean @input setPosition: boolean private transform; private controller; onAwake() { var options = MotionController.Options.create() options.motionType = MotionController.MotionType.SixDoF this.controller = MotionControllerModule.getController(options) this.target = this.target === undefined ? this.sceneObject : this.target; this.transform = this.target.getTransform() this.controller.onTransformEvent.add(this.updateTransform.bind(this)); this.controller.onTouchEvent.add(this.onTouchEvent.bind(this)); } updateTransform(position, rotation) { if (this.setPosition) { this.transform.setWorldPosition(position); } if (this.setRotation) { this.transform.setWorldRotation(rotation); } } onTouchEvent(normalizedPosition, touchId, timestampMs, phase) { if (phase != MotionController.TouchPhase.Began) { return } var request = MotionController.HapticRequest.create() request.hapticFeedback = MotionController.HapticFeedback.Tick request.duration = 1.0 this.controller.invokeHaptic(request) }} Copy
//typescriptconst MotionControllerModule = require("LensStudio:MotionControllerModule")@componentexport class NewScript extends BaseScriptComponent { @input @allowUndefined target: SceneObject @input setRotation: boolean @input setPosition: boolean private transform; private controller; onAwake() { var options = MotionController.Options.create() options.motionType = MotionController.MotionType.SixDoF this.controller = MotionControllerModule.getController(options) this.target = this.target === undefined ? this.sceneObject : this.target; this.transform = this.target.getTransform() this.controller.onTransformEvent.add(this.updateTransform.bind(this)); this.controller.onTouchEvent.add(this.onTouchEvent.bind(this)); } updateTransform(position, rotation) { if (this.setPosition) { this.transform.setWorldPosition(position); } if (this.setRotation) { this.transform.setWorldRotation(rotation); } } onTouchEvent(normalizedPosition, touchId, timestampMs, phase) { if (phase != MotionController.TouchPhase.Began) { return } var request = MotionController.HapticRequest.create() request.hapticFeedback = MotionController.HapticFeedback.Tick request.duration = 1.0 this.controller.invokeHaptic(request) }}
How long the haptic request should last for.
A type of haptic feedback.
Returns the name of this object's type.
Returns true if the object matches or derives from the passed in type.
Returns true if this object is the same as other. Useful for checking if two references point to the same thing.
other
Describes a request for haptic feedback.
Example