I edited a video to demonstrate the HTML/CSS design, but in addition to explaining how to do that: what element or entity would I use surrounding the dronecar, so that when the player’s rigidbody or collision entity (not sure which) interacts with it, the message is triggered to appear?
By the way I’m talking about the Press x to enter. Lol that part isn’t real, it’s edited.
Hi @Lorenzmotors! You can create a trigger entity. This is an entity with a collision component and a script to activate the text. Enable the text on trigger enter and disable the text on collision leave.
So, now I’m guessing I call a function to display (true) the HTML/CSS ui on entered and hide (false) on left.
How would you go about doing this and what would the code look like? I understand there’s probably a few ways to do it; I’m just wondering if I’m thinking about it in a way that makes the most sense.
How is var triggerEntered associated with the function? What mechanism is triggering/changing the false to true?
I’m trying to understand the “mechanism” behind everything, lol not just get it to work. So, while I appreciate the vague idea, and while I do get it, unfortunately if it’s not explained in detail, I can’t: 1. learn or understand what’s going on, but also 2. plug it into the computer and make it work.
As you know, computers only work one way, so I’m sitting here scrambling around ideas on where to plug these codes in, but I really learn best by example! LOL so please be specific and detailed. Sorry for the tall ask, I just won’t be able to understand it or implement it without learning the language/mechanism/syntax/etc. which like I said I learn through copy/pasting. (And, yes, I do sit here and read line by line what you’re writing and trying to develop the linguistics behind the machine language).
Oooh! Okay, got it! I’m glad you did it that way because that’s essentially exactly what I was thinking; in terms of adding the boolean under the console. I just wasn’t sure how to code it.
Thank you.
And, now I’m guessing I create a separate JavaScript file with a function that calls the HTML/CSS ui?
No idea, not used HTML/CSS myself that much. I suggest to try the logic above in combination with the HTML/CSS text that is already in the tutorial project.
Instead of HTML/CSS you can use an entity with a text element. (For this you need to import a font asset to your project).
Hey, so basically I transfer the variable from the triggerVolume.js file into the enterDronecar-ui-call.js, right?
And, then when the computer turns the triggerEntered variable to true it pops up the Press X to enter. message.
I started as you can see, lol but there’s no way for me to know the vocabulary because I never have been taught this stuff, so I wouldn’t even know which words to Google to find the answer. Haha, all I’m looking for is some linguistics training in machine code so I can talk like a programmer
I don’t think you can do this in the initialize function, because this is only executed at start of the game. You need to create something in the update function, where you can change the text based on the conditions.
Where is the text applied in the original project?
On initialize you would need to generate the HTML element with its CSS. Then, on collision event, just like you change triggerEntered , you would instead show/hide the HTML element - you can either remove/add the element from DOM, or apply CSS property to hide/show it.
Okay! These sound like really good ideas in terms of the computing power requirements and stuff. Sounds really efficient.
How do you code it though
I get the theory and everything; there’s multiple ways of doing it I guess. Just whatever works is fine. And I hate to keep reiterating this point if whoever responds can just please walk me through the thought process, including where you go to look for this information and solutions.
I looked at the API and everything just the words I’m looking for don’t seem to match what I need? Is PlayCanvas the only source for this stuff or can you look on external websites/sources for coding assistance?
Hey, I’m getting a few errors. I tried to change the names of the classes/methods whatever those things are called to more match how I think about what’s happening, lol so I may have made a few mistakes transferring your code over.
But, it looks like some sort of declaration error?
I had a quick look at your project. Here are a few things I changed:
The UI elements need to be created in the initialize method of the script, since it needs an application reference to find the HTML asset (this.app.assets.find(...)).
Try to use close to real life scales. 1 unit in PlayCanvas is 1 meter. Your drone model is about 800 meters. A common way is to add the model as a child to an entity, and then downscale it to match wanted size. Otherwise you will have issues rendering shadows at large distances.