First Person Controller
Updated
Mouse-look from the player’s eyes.
- Type
comp-first-person-controller- Script class
FirstPersonControllerComponent- Per entity
- One
- Version
- 2.0.0
Read about it in Camera controllers: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
lookHeight |
-20 ≤ x ≤ 20 |
|
lookSpeed |
0 ≤ x ≤ 1 |
|
pitch |
-89 ≤ x ≤ 89 |
|
pitchLimit |
0 ≤ x ≤ 89 |
|
smoothTime |
0 ≤ x ≤ 0.5 |
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
Live example
Switch between first and third person with VThe player camera carries a First Person and a Third Person controller; pressing V enables the one that is off, and the runtime turns the other off.
Click the scene, then press V to switch between following the hero and looking through your own eyes. In first person, WASD moves and dragging looks around.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(FirstPersonControllerComponent); if (component) log(component.props);}