#Interact Script

1 messages · Page 1 of 1 (latest)

static sage
#

good evening, can anyone help me?
i wanted the player's prefeb to be inside the array use a canvas called pc_interact.
another thing, i don't know why i can't open canvas from my pc.

static sage
#

I've updated a few things but I still can't get what I wanted before

oak wharf
#

[]cb

rapid widgetBOT
#

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.

oak wharf
#

Also pls use proper codeblocks, the format is way easier to read, like I'm not even gonna bother opening a txt file =)

static sage
#

Okok, when I get home I'll send it properly

#

Thank you in advance for your help and have a merry Christmas

static sage
oak wharf
# static sage Thank you in advance for your help and have a merry Christmas

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 :)

oak wharf
#

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,

  1. don’t use strings, they’re highly errorprone and it doesn’t scale.
  2. In your update, you’ve got too many if statements, use a switch statement instead.
  3. 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
static sage
#

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

oak wharf
#

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

static sage
#

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?

oak wharf
#

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.

static sage
#

No, it will always be just one at a time that is active

oak wharf
#

So, do you then need 3 arrays of canvases ;)

oak wharf
oak wharf
#

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

static sage
#

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?

oak wharf
#

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)

oak wharf
#

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

static sage
#

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