How To Make A Multiplayer Game In Unity - Chat

How To Make A Multiplayer Game In Unity - Chat

Dapper Dino

5 лет назад

66,434 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@duelsoldier3048
@duelsoldier3048 - 16.10.2020 01:51

send message has no receiver help

Ответить
@daoollaa
@daoollaa - 25.10.2020 23:20

If Input Field doesn't work, make sure that the SCENE has EventSystem (an Empty Object with Event System and Standalone Player Movement)

Ответить
@FOE-FlameOFEmross
@FOE-FlameOFEmross - 27.10.2020 21:27

How to save chat history? For all new players.

Ответить
@cfredman
@cfredman - 29.10.2020 08:24

Anyone have advice for how to do this and not have the UI elements be a component of the player prefab?

The issue I'm having when I have the UI outside the player prefab is I start running into client/server authority issues. OnStartAuthority() never gets called--I believe because the player does not "own" the UI elements. Then the [Client], [Command], and [ClientRpc] tags generate all manner of horrible errors. "InvalidProgramException: Invalid IL code in ChatBehavior:Send (string): IL_000f: call 0x0a0001ee"

Ответить
@gavanscommandblock
@gavanscommandblock - 05.11.2020 19:35

code

Ответить
@techinspired5628
@techinspired5628 - 14.11.2020 15:26

Can we use this script to implement chat system on client server method ?

Ответить
@louismastbooms5048
@louismastbooms5048 - 16.11.2020 14:46

My inputfield is not interectable for some reason

Ответить
@sepehrgoodman3988
@sepehrgoodman3988 - 01.12.2020 19:54

how to spawn different prefabs over network?

Ответить
@riskgd
@riskgd - 17.12.2020 13:14

how do we add names from later episodes?

Ответить
@tmstudio5245
@tmstudio5245 - 29.12.2020 19:26

Bad Please Coding With PHP

Ответить
@old_school
@old_school - 29.12.2020 21:57

I understand the idea of using a string but why not just use a list. You can easily run a loop to populate the screen with each string and its more organized.

Ответить
@old_school
@old_school - 29.12.2020 21:57

I'm also confused how do you determine which port Mirror uses?

Ответить
@old_school
@old_school - 30.12.2020 00:46

So nothing works that you posted in the video. I really recommend you type code as you go instead of prebuilding code. Really creates a lot of confusion

Ответить
@danielekbom1263
@danielekbom1263 - 30.12.2020 12:08

Would it be possible to instead use a SyncList storing the chat messages instead of Rpc? Is there a reason why you are not doing it that way?

Ответить
@Jomesba
@Jomesba - 02.01.2021 04:38

Hi, I was following along but it wont let me click to type in the chat box

Ответить
@yourfellowgamer487
@yourfellowgamer487 - 13.01.2021 23:40

When I try to press on the Input Chat it doesn't work. Please help.

Ответить
@Delvarn
@Delvarn - 17.01.2021 01:47

My chat isn't working because my input isn't being stored. It will only work when I take the nullorwhitespace filter off. What am I doing wrong?

Ответить
@old_school
@old_school - 24.01.2021 06:21

your code does not work!!!!!!!!!!!!!!!!!!!!!

Ответить
@murphrichard
@murphrichard - 31.01.2021 23:52

I was able to get this to work with the following changes:

1. Add the following includes to ChatBehavior.cs:
"using System;
using TMPro;
using Mirror;"
2. Create an EventSystem in the scene. Right click in the hierarchy, then UI -> EventSystem
3. In the Send function, replace "message" with "inputField.text" in the following lines:
"if (string.IsNullOrWhiteSpace(message)) { return; }"
"CmdSendMessage(message);"

Ответить
@FakeGuthix01
@FakeGuthix01 - 20.02.2021 19:48

Will this chat have issues with code injection?

Ответить
@Delvarn
@Delvarn - 27.02.2021 18:28

"Trying to send command for object without authority. ChatBehaviour.CmdSendMessage" - I can't send messages as the host?

Ответить
@tonytran07
@tonytran07 - 02.03.2021 01:22

For Input Field chat and pressing enter
The issue you may run into is "nothing happens". That is because the parameter "message" is empty.
Under "On End Edit", there are TWO "Send" message.
Set yours to the Send under Dynamic string

Ответить
@Plaga5783
@Plaga5783 - 06.05.2021 17:31

subbed and liked thx man for the script i looked for script to download and i find what i was looking for

Ответить
@RoboYak
@RoboYak - 01.07.2021 07:23

When I try to follow along with this my Send never gets hit and the error shows up: InvalidProgramException: Invalid IL code in ChatBehavior:SendChat (): IL_000f: call 0x0a000042. If I take the [Client] decorator off of my Send function it doesn't throw that error, but instead throws: Trying to send command for object without authority in my Command method. Anyone get this and figure it out?

Ответить
@haachamachama7
@haachamachama7 - 27.07.2021 20:05

Please write the script as you go, you did this in the first two videos. I know, I write tutorials too, it's so much easier to show it after, but in the end it just makes it feel more like copying than actually following the steps on how to do something.

Ответить
@lora6938
@lora6938 - 01.08.2021 23:29

Hello! Can you please tell me if you can change the standard Lana buttons to your own buttons to your liking? It seems to me that this is impossible !?

Ответить
@koferperk
@koferperk - 13.08.2021 07:08

very cool!

Ответить
@yadhuvtk
@yadhuvtk - 26.08.2021 07:08

What about voice chat

Ответить
@NoName-rs4th
@NoName-rs4th - 02.09.2021 01:58

This may be a dumb question or whatever but is there a difference between these:

if(!Input.GetKeyDown(KeyCode.Return)) { return; }

if(!Input.GetKeyDown(KeyCode.Return)) return;

Ответить
@VBG33k
@VBG33k - 02.09.2021 14:03

Nothing that you just wrote here, worked... sorry to say, and i copypasta everything...

Ответить
@gr1m046
@gr1m046 - 25.09.2021 06:03

This was alot of help for my voice hangout game

Ответить
@FC12CGaming
@FC12CGaming - 09.10.2021 15:53

The Input field isn't working

Ответить
@orfeo6021
@orfeo6021 - 24.11.2021 22:02

Have no word ahah really fast and great tutorial ! Have you a solution to use Enter and not the Mouse to open chat and send the text ? <3

Ответить
@fakemayham084
@fakemayham084 - 31.12.2021 07:11

i setup it on with steam so now the chta shows there steam name as there chat name

Ответить
@quboss2008
@quboss2008 - 23.01.2022 17:10

ITS WORKING!!! THAANKS!!!

Ответить
@Vanilla102
@Vanilla102 - 07.02.2022 03:21

didnt work fucked me up

Ответить
@edps
@edps - 12.02.2022 04:37

and in a online game? how make?

Ответить
@craakx621
@craakx621 - 20.03.2022 01:46

hey, every time i click on the input field it doesnt work? help please

Ответить
@DeathxStrike18
@DeathxStrike18 - 31.03.2022 23:26

You actually may have filtering on both client or server. Server may have banned words such as can't say N word even if you have profanity off or it gives a warning and to the client and prevents the message from being sent to other clients. Where a client filter would have a filter for normal curse words.

Ответить
@koferperk
@koferperk - 20.07.2022 14:44

what does static do in that action? it feels weird to me like if all clients had that static action, wown't invoking a static action on one client, invoke the other ones too because the static action is the same???? huh

[EDIT : cleared up my misunderstanding]
Static variables are only shared between classes on the same client. This means that across clients, you're not gonna have the same values.

Ответить
@Rajiigh
@Rajiigh - 29.07.2022 02:12

Can you please tell us how to make it show usernames instead of numbers?

Ответить
@moose43h
@moose43h - 25.11.2022 14:27

very good. thank you

Ответить
@ElTeteh
@ElTeteh - 06.12.2022 03:38

If you're using the new input system and having trouble with checking if OnEndEdit was from pressing Enter or clicking off:
The TMP_InputField has an event called onSubmit that is exactly what you're looking for, it pass the text string when Enter is pressed only
You can't serialize it from the Inspector but with a reference to the inputfield you can easily access it and write something like "inputField.onSubmit.AddListener(Send);" and "inputField.onSubmit.RemoveListener(Send);" to subscribe and unsubscribe

Ответить
@danilox94
@danilox94 - 07.05.2023 16:42

congratulations for the previous videos, I just wanted to point out that unfortunately in this video I can't figure out which objects are the ones already created in the video, "input chat" I don't know what's inside as a child object, and "text chat".

Ответить
@kucer0043-Games
@kucer0043-Games - 02.06.2023 15:43

Code:
using Mirror;
using UnityEngine;
using System;
using TMPro;
using Unity.VisualScripting;

public class Chat : NetworkBehaviour
{

[SerializeField] private GameObject chatUI = null;
[SerializeField] private TMP_Text chatText = null;
[SerializeField] private TMP_InputField inputField = null;

private static event Action<string> onMessage;

public override void OnStartAuthority()
{
chatUI.SetActive(true);

onMessage += HandleNewMessage;

}

[ClientCallback]
private void OnDestroy()
{
if (!hasAuthority) { return; }
onMessage -= HandleNewMessage;

}

private void HandleNewMessage(String messsage)
{
chatText.text += messsage;
}

[Client]
public void Send(String message)
{
if (!Input.GetKeyDown(KeyCode.Return)) { return; }

if (string.IsNullOrWhiteSpace(message)) { return; }

CmdSendMessage(inputField.text);

inputField.text = String.Empty;
}

[Command]
private void CmdSendMessage(String message)
{
RpcHandleMessage($"[{connectionToClient.connectionId}]: {message}");
}

[ClientRpc]
private void RpcHandleMessage(String message)
{
onMessage?.Invoke($"\n{message}");
}
}

Ответить
@LegendaryCombatForce
@LegendaryCombatForce - 22.07.2023 17:30

How to make multiplayer search bar to find people to add as friend in unity

Ответить
@Bro-tl8jo
@Bro-tl8jo - 31.07.2023 11:55

Hey, is it possible to also add custom emojis in the chat, and also when a user writes a message, its puts a message bubble over the player’s face kinda like in roblox. If u can make a tutorial for that that would be great. Thanks for the tutorial

Ответить