PlayerCamera.ts
script.PlayerCamera.ts
script consumes events delivered by other entities or triggers in the world, including in the event message data on the camera mode and other properties to configure.PlayerCamera.ts
your own! Bring this script into your world and begin exploring how it can work for you. Remember to create the object reference and attach the script and to send the appropriate PlayerCamera events, which are defined at the top of the script.Camera Mode | Use Case |
---|---|
First Person | Shooting a weapon at a target |
Third Person | Close quarters combat |
Orbit | Explore this interesting location |
Fixed Camera | Spectator Mode |
Fixed Camera with camera movements | Cut scenes |
PlayerCameraManager.ts
is used to safely deploy cameras for each player entering the world. This script is necessary to ensure that the non-sequential execution of scripts at startup does not interfere with camera assignment.name
defines the instructional text set to apply to the custom UI/post-it.name
property is used to reference the string to apply from the InstructionConsts.ts
file, which is a set of key-value pairs:export const InstructionConsts = {
'SWORD': "Third-Person Camera\n\nThis sword uses the third-person camera. \n\nThe third-person camera is enabled by default, and is good for building the relationship between the player and their avatar, and for showing off the avatar's actions, cosmetic items and wearables.\n\nThird-person camera can make it difficult for players to see small objects and text in front of them, and can be awkward in small spaces.",
'GUN': "First-Person Camera\n\nThis blunderbuss uses the first-person camera.\n\nThe first-person camera is good for building the relationship between the player and the environment, for precise aiming and for seeing small objects and text in front of the player.\n\nFirst-person camera can make it difficult for players to see what is around them, and to avoid obstacles or jump over gaps.",
'ORBIT': "Orbit Camera\n\nThis area triggers an orbit camera.\n\nThe orbit camera is good for showing off the environment, for giving players a sense of scale, traversing tricky terrain and taking selfies!\n\nOrbit camera can make it difficult for players to aim projectile weapons, see small objects and text in front of them, and can be awkward in small spaces.",
'FIXED': "Fixed Camera\n\nThe fixed-camera decouples the player's camera from their avatar.\n\nThe fixed camera is good for giving player's an unencumbered view of the world. It's great for spectating, cut-scenes and for non-avatar focused gameplay.\n\nMake sure that players can easily return the camera to their avatar if they need to, and that they can't get stuck in the fixed camera."
};
Weapon.ts
script contains a rudimentary system for grabbing and swinging a weapon in hand.Gun.ts
script contains a simple gun management system for firing a gun.