RaycastGizmo with objectTag
I'm trying to use RayCastGizmo with objectTag, but it seems like the tag set in the interface isn't being used in the script. Example: const options = { layerType: hz.LayerType.Objects, maxDistance: 10 }; const hit = this.rayCaster!.raycast(origin, direction); Will hits all objects, not just the ones with the objectTag set in the RayCastGizmo. Has anyone else run into this? Has this feature been removedSolved1.6KViews1like12CommentsIs there a way to have weekly leaderboards?
I can't figure this one out. Codeblocks have the ability to set the timeframe for leaderboards (ex. weekly, monthly, etc) but there doesn't seem to be a way to set this anywhere now that Codeblocks is not available. How does one set a timeframe for leaderboards so that the leaderboard is cleared out on, say, a weekly basis? Is everyone just coding their own?1.3KViews0likes15CommentsIssue accessing player position using world.getLocalPlayer()
Hello! I'm new to scripting using Typescript in the desktop editor and I've run into a problem that I haven't quite been able to solve. I saw code snippets and suggestions about using world.getLocalPlayer() but it's not quite working for me. When I call that method, the resulting player has an empty name and trying to access its position with player.position.get() gives an error. Here's the code that isn't working, inside Start : const player = this.world.getLocalPlayer(); console.log(`local player name: ${player.name.get()}`); console.log(`local player id: ${player.id}`); console.log(`local player exists?: ${player}`); if (player) { //const position = player.position.get(); //this line gives an error when uncommented //console.log(`Player position: ${position.x}, ${position.y}, ${position.z}`); } Here's the console output for that, when the error is commented out: Here's the error if I attempt to access the position: It may be something silly, but I have no idea what's wrong! I also tried using a player map (code below) that I found and that does work and give me my name and position, however I don't know how I could use that without knowing who is the local player. this.connectCodeBlockEvent( this.entity, hz.CodeBlockEvents.OnPlayerEnterWorld, (player: hz.Player) => { this.playerMap.set(player.id, player); console.log(`added player: ${player.name.get()}`); const position = player.position.get(); console.log(`Player id: ${player.id}`); console.log(`Player position: ${position.x}, ${position.y}, ${position.z}`); //this DOES work unlike the other code }, ); If anyone's able to help I'd be grateful! Thanks for reading1.2KViews1like18CommentsPublished world different from Editor
My published world looks very different from how it appears in the editor. Has anyone else experienced this issue? Here are the differences I noticed: The lighting is extremely bright, and I lose important environment effects like pink smoke and the dark ambiance. The script that changes object colors works on the spotlights, but not on the "stab" on the floor (which is an Asset object). this is the Editor: This is the Publish: Here’s my world if anyone wants to try it and let me know if it works for them: Name: EverybodyQuiz Link: https://horizon.meta.com/worlds/10229187571338836 Please help! 😢1.1KViews0likes10CommentsDifferentiating NPC and Player
Hi all, I having a little issue with differentiating player and NPC. Side note: I have the NPC gizmo in the editor and enabled avatar ai_agent. I named my NPC "NameNPC" I have this script that was referenced from "Intro to desktop Editor and Typescript". I added some logic to check if it's an NPC. If it is an NPC it will print "Should be NPC". If it is a player it will print "Should be Player" Since I only have one NPC and myself. I was expecting to see "Should be Player" and "Should be NPC" printed once However, not only was Should be Player printed three tiems, but it thought NPC was a player, than deleted the NPC and than said NPC is a player again. See attached below This would be a problem because I have other logic where enemies will check when player entered world and follow that player, but it will start following the NPC instead because it thinks the NPC is a player How come the NPC is treated as a player at the beginning? How can I make sure the NPC is never treated as a player - I don't want to have to check the NPC's name to see if it is an NPCSolved970Views0likes8CommentsHow to access Methods and Properties of a referenced Entity in TypeScript (Desktop Editor)
Hi, I have two local scripts SomeLocalItem.ts AnotherLocalItem.ts SomeLocalItem has reference to Entity with AnotherLocalItem. I want: 1) Inside SomeLocalItem invoke method on referenced AnotherLocalItem. 2) Inside SomeLocalItem read some property from AnotherLocalItem. Note, both scripts are local, so Behaviour.ts doesn't work here without rewriting it to work locally. Is there simpler way? SomeLocalItem.ts import * as hz from 'horizon/core'; import { AnotherLocalItem } from 'AnotherLocalItem'; class SomeLocalItem extends hz.Component<typeof SomeLocalItem> { static propsDefinition = { anotherLocalItemEntity: { type: hz.PropTypes.Entity } }; start() { this.connectCodeBlockEvent(this.entity, hz.CodeBlockEvents.OnButton1Down, () => {this.onButton1Down();}); } onButton1Down() { this.anotherLocalItem = this.props.anotherLocalItemEntity as AnotherLocalItem; // This doesn't work, how to assign the entity to the component? this.anotherLocalItem.printToConsole('Hello from SomeLocalItem'); // I want to invoke this method, how? console.log('Level of anotherLocalItem: ', this.anotherLocalItem.level); // Or print it's public property, how? } } hz.Component.register(SomeLocalItem); AnotherLocalItem.ts import * as hz from 'horizon/core'; export class AnotherLocalItem extends hz.Component<typeof AnotherLocalItem> { static propsDefinition = { level: { type: hz.PropTypes.Number, default: 1} }; public level: number = 1; preStart(): void { this.level = this.props.level; } start() { } public printToConsole(message: string) { console.log('AnotherLocalItem.printToConsole: ', message); } } hz.Component.register(AnotherLocalItem);Solved932Views0likes3CommentsDoes the Focus Prompt option for CustomUI enter FocusedInteraction?
If a player clicks the focus prompt button that is built in with customUI, do they enter FocusedInteraction? Meaning could I use the CodeBlockEvent OnPlayerEnteredFocusedInteraction? Right now my assumption is no because it is not working for me, but I wanted to check in case my code is the problem. preStart() { this.connectCodeBlockEvent(this.entity, CodeBlockEvents.OnPlayerEnteredFocusedInteraction, this.onFocusedInteraction.bind(this)); } start() {} initializeUI() { return View({ }); } onFocusedInteraction(player: Player) { console.log("onFocusedInteraction triggered"); if (this.entity) { player.focusUI(this.entity, { fillPercentage: 0.4, }); console.log("UI focused successfully"); } else { console.error("Entity is null or undefined"); } }Solved793Views0likes7Comments