#Interact Script
1 messages · Page 1 of 1 (latest)
I've updated a few things but I still can't get what I wanted before
[]cb
Use codeblocks to send code in a message!
To make a codeblock, surround your code with ```
To use C# syntax highlighting add cs after the three back ticks.
For example:
```cs
Console.WriteLine("Hello World");
```
Produces:
Console.WriteLine("Hello World");
To send lengthy code, paste it into https://paste.myst.rs/ and send the link of the paste into chat.
You can't reference a scene object into a prefab. If that's what you wanted, kinda hard to know with your description
Also pls use proper codeblocks, the format is way easier to read, like I'm not even gonna bother opening a txt file =)
Okok, when I get home I'll send it properly
Thank you in advance for your help and have a merry Christmas
a powerful website for storing and sharing text and code snippets. completely free and open source.
Super late answer, merry christmas to you to (which was yesterday😅) I will give a proper answer tomorrow(it’s very later for me now)
I’ve looked briefly through your code and there’s several bad practises that I’ll go over more detailed. In the meantime, I want to ask you what the purpose of the script you sent me is :)
I’ve had some time to read more through the code. I’ll start with this: your code needs cleanup. It’s super messy. Secondly, you show code, but you don’t tell what the issue is about that code, clarify the problem with the code.
For cleaning up,
- don’t use strings, they’re highly errorprone and it doesn’t scale.
- In your update, you’ve got too many if statements, use a switch statement instead.
- Do not use gameObject.Find … it is slow and not reliable (because it uses strings), there are alternative ways that are way better.. a singleton could be one solution
Good morning, thanks for the tips, I'll say it again to see if I can understand it. I have a PC where the player can interact, when the player approaches this PC he will see a canva with the text "Use" but for that I need to put this canva in the array I created. That's basically what I can't do.
If you don't understand something, please let me know
Ok so my question now is, why do you have 3 arrays of canvas… how many canvases do you need?
Please explaing step by step what’s gonna happen, I.E (player walks to computer, which enables a canvas etc) then the problem.
I also want to suggest to swap the name PC to computer, as PC is commonly used for player character
Imagine, there are doors, objects that will be usable and npcs that will have a canvas in world space mode. When the player approaches one of these objects in range, this canvas appears with different messages.
I guess that's all you wanted to know, right?
Yeah that’s a good start. How many canvases will be active at one time? Is there a scenario where more than one world canvas will be active.
No, it will always be just one at a time that is active
So, do you then need 3 arrays of canvases ;)
What I’m getting at is that you can simplify this. Having a bunch of world-space-canvases when you only need one is redundant… and the more complex you make it the harder it is to manage. So simplify everything when/if you can
So how can I simplify things?
Start by reducing the amounts of canvases to one. And come up with a way to make it modular and scaleable
My point here is, everytime you want to create a new npc you’d need to create a new canvas, while you don’t necessary need to. At least you can re-use alot of it
Yes, that makes sense, thanks for the suggestion
I don't know if you're aware of this, but have you ever had an urp project and switched to hdrp and your terrain didn't have the textures?
Yes I have x) about a year ago, I don’t remember exactly what I did. But there’s some graphics settings where you can convert all exisiting mateirals to the new one, which fixed it(iirc)
You should make a new post with that though if you need help^^ if you haven’t already:) I can’t really help with that😅
but do let me know here how it goes with the other issue:) and if you need more help with it
Okok, yes I've created it but I haven't had a reply yet, I'll test what you said, I'm not at home now but if I need help I'll let you know, thanks for everything