Discord SDK - / discord Discord App - / discord My Script - github.com/sve... /* Music used in the video */ @KUBBIkthxbai - Polar Bear Rides @KUBBIkthxbai - Something New
Пікірлер: 96
@sventomasek2 жыл бұрын
Note: I didn't know this at the time of making the video, but Discord slows down the activity update frequency the more it needs to update it, so having a number that constantly changes will not be displayed correctly, it will update it every 5-20 seconds. This still works correctly as long as you don't need to update it constantly. It is an issue on Discord's end so nothing I could do. If you want to see how I used this method in my game sventomasek.itch.io/umami-island Discord_Controller.cs - github.com/sventomasek/Discord-Script-for-Unity/blob/main/Discord_Controller.cs
@itsjust246 Жыл бұрын
how to add buttons
@jakeinalake_ Жыл бұрын
This video had text explaining what to do, background music and was very understanding to follow! Thanks for making an actual understandable tutorial!
@joshuamaitland Жыл бұрын
Very good! I will use it for my future unity projects!! Thanks for this tutorial.
@Dilithium1 Жыл бұрын
THANK YOU FOR THIS VIDEO SO MUCH!!
@realzoogies8 ай бұрын
+1, to the point with link to source script provided
@angelicaz133211 ай бұрын
such detailed steps! you are awesome!
@aihkww5 ай бұрын
W video
@korbyntalks Жыл бұрын
omg tysmmm you need more recognition, Subbed!
@korbyntalks Жыл бұрын
oh and also do you have a solution for uhm this? So I really want it to show what scene your on in the status thing, Got anything?
@sventomasek Жыл бұрын
@@korbyntalks To get the name of the Scene you can use SceneManager.GetActiveScene().name which you can write in State or Details (where rb.velocity is in my script)
@slicetheduck Жыл бұрын
This really helped me implement DiscordRpc into a game using BepInEx i did have to change some things but still thank you!
@sventomasek Жыл бұрын
I'm glad I could help!
@HighPalace123 Жыл бұрын
Thank you!
@malyplus9839 Жыл бұрын
hey! Thanks For Tutorial!
@laym.glitched11 ай бұрын
AMAZING TUTORIAL!!! Loved it! and also i Liked and Subbed! but 1 quick question: In your Awake() for my else if, its telling me FindObjectsOfType() is deprecated, and makes it so I have to restart discord to remove the discord rpc, any way to fix this?
@sventomasek11 ай бұрын
Thank you! Are you getting an error or a warning? If it's a warning I think the function should still work fine, it just may have a different name in the future Unity versions. But if you're not sure you can reply with the full error message here. As for having to restart Discord that's probably because you're in the Unity editor. Try building the game and check if it works fine that way.
@laym.glitched11 ай бұрын
@@sventomasek Thanks for the quick reply! Its just a vs warning and here is the full error for more info: Warning CS0618 'Object.FindObjectsOfType(Type)' is obsolete: 'Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID, but if you do not need this using FindObjectSortMode.None is considerably faster.' Ill will try to build it and see if it fixes, Thank you so much!
@kirdow4 ай бұрын
How do I add buttons? I recall seeing some rich presences users have contain buttons below the details that you can click. Looking at the discord documentation Buttons should exist as an array of objects taking Label and Url, but there seem to be no Buttons property under the Activity class. Am I missing something important for that to work?
@YURIKZbutSJ Жыл бұрын
THANK YOU SO MUCH!!!!
@RadSow Жыл бұрын
Wonderful tutorial! Will it work if I send it to someone else? Do they also have to have the application created at their account or not?
@sventomasek Жыл бұрын
Yes it will work for everyone using Discord. The only person that needs to create the application is the developer.
@RadSow Жыл бұрын
@@sventomasek THX FOR THE FAST REPLY! You are wonderfull
@RadSow Жыл бұрын
@@sventomasek I'll drop a sub for you and I hope you will make more useful tutorials like this one :D
@sventomasek Жыл бұрын
@@RadSow Thank you!
@RadSow Жыл бұрын
@@sventomasek You're Welcome. Also, I just downloaded your game, and after I try it I'll definitely put a review (probably 5/5 stars but we'll see :D)
@exator9117 ай бұрын
I'm having an issue with the timestamp for how the game has been running. The code is there and it should work however it doesn't appear properly. The time shows a zero or nothing at all.
@krippanus Жыл бұрын
problem: when you close the game build or exit playtesting mode, the rich presence from that session stays and will not update when starting again.
@sventomasek Жыл бұрын
That's because the Rich Presence only disappears after you close the application which means you would need to close Unity itself. When you export the game and run it outside Unity that won't be a problem.
@krippanus Жыл бұрын
@@sventomasek just checked. when it's exported, it doesn't work at all.
@krippanus Жыл бұрын
wait fuck... i had the architecture wrong
@krippanus Жыл бұрын
the problem was entirely on me, my bad
@sventomasek Жыл бұрын
@@krippanus Well I'm glad you figured it out ^^
@4Raynixx2 ай бұрын
How to add Buttons?
@blob7115 Жыл бұрын
thanks
@krippanus Жыл бұрын
"Multiple plugins with the same name 'discord_game_sdk' (found at 'Assets/Plugins/lib/x86_64/discord_game_sdk.dll' and 'Assets/Plugins/lib/x86/discord_game_sdk.dll'). That means one or more plugins are set to be compatible with Editor. Only one plugin at the time can be used by Editor." bruh
@Davis_Bogdanovs Жыл бұрын
To fix this error I opened the Plugins folder and then the x86 folder, in there for the discord_game_sdk file I checked to exclude Editor. Might want to do the same for Android/iOS if you are exporting your project to mobile devices as otherwise it might give you errors
@krippanus Жыл бұрын
@@Davis_Bogdanovs you're... a little late, don't you think? i fixed it months ago already. not sure what i did.
@juzdepeche Жыл бұрын
@@Davis_Bogdanovs You're not late for me, thanks!
@Sk8_2 жыл бұрын
Great video, I've just started development on a retro fps game so this has really helped me out. I do have a question, which is: How do I go about changing the status when a user loads a new scene, I cant re-implement the discord controller from scene to scene and change the value of the 'details' and 'state' because the first one is already running. So how can this be achieved?
@sventomasek2 жыл бұрын
Thanks! How I would go about this is making another script that finds the DiscordController and changes the variables in the Start function. Here's an example, you can just copy and paste it if you want. Let me know if you have any issues with it! using UnityEngine; public class Discord_Changer : MonoBehaviour { public string newDetails = "Example Details"; public string newState = "Example State"; [Space] public string newLargeImage = "game_logo"; public string newLargeText = "Example Text"; void Start() { Discord_Controller discord = GameObject.Find("DiscordController").GetComponent(); discord.details = newDetails; discord.state = newState; discord.largeImage = newLargeImage; discord.largeText = newLargeText; } }
@Sk8_ Жыл бұрын
@@sventomasek Sorry for the late reply, thank you for this. I'll be sure to test it out.
@jozatheman Жыл бұрын
@@sventomasek do i have to create a seperate gameobject for this?
@sventomasek Жыл бұрын
@@jozatheman Yes, you place that script onto a new game object in each scene you want to change the status in.
@joshuamaitland Жыл бұрын
Well... Even if Discord is not running, I'm getting this error: ResultException: InternalError Discord.Discord..ctor (System.Int64 clientId, System.UInt64 flags) (at Assets/Plugins/DiscordGameSDK/Core.cs:1075) DiscordManager.Start () (at Assets/Scripts/Managers/DiscordManager.cs:37) Any ideas?
@MCew_prv Жыл бұрын
I now have a different problem, when i started the game and launch spotify, then the spotify rich presence gets on top of the one from my game. If I would to the same with any other game then the spotify rich presence would stay behind the one of the game and would only be viewably if i close the game.
@sventomasek Жыл бұрын
That's probably because those games have an official rich presence provided by Discord, so I don't think anything can be done about that unless Discord adds a status priority option or the user disables their Spotify rich presence in Discord settings.
@Delta-Warrior8 ай бұрын
when i close the game it keeps the status how would i fix that?
@sventomasek8 ай бұрын
That should only happen in the Unity editor. Try exporting the game and see if it still happens.
@kiatu23529 ай бұрын
whenever i start up a new session it creates a new activity on my discord profile, is there a way to make sure only one of itself is present in my activities tab?
@sventomasek9 ай бұрын
That's because you're in the Unity editor so activities close only when you close Unity. When you export the game it should work fine.
@LukeKido Жыл бұрын
Made a small 2D doodle and it worked like a charm! How can I set the logo to be shown on Discord?
@sventomasek Жыл бұрын
You have to upload your logo on the Discord Applications website like shown at 0:52 (name it whatever you want), then make a string "largeImage" and set it to whatever you named your logo on the website, like shown at 2:49. Then like at 6:30 under Assets you add LargeImage = largeImage and it should be working. If it's not try waiting a few minutes since it takes Discord some time to approve the image you upload.
@LukeKido Жыл бұрын
Thanks a lot for your quick reply and explaining every step 🥰
@Il_Tizio Жыл бұрын
Unity say that this script can't be loaded and I need to fix it, but the console didn't expose any error
@sventomasek Жыл бұрын
Can you post a screenshot of the error you're getting? You can upload it to imgur for example and post a link here.
@MCew_prv Жыл бұрын
Getting this error: "NullReferenceException: Object reference not set to an instance of an object Discord_Controller.Start () (at Assets/Scripts/Discord_Controller.cs:39)" Can someone help me?
@sventomasek Жыл бұрын
You probably forgot to add a Rigidbody to your player object like at 8:51 or forgot to add the tag "Player" like at 8:45 If that doesn't work double check if you misspelled something, the line should be "rb = GameObject.FindWithTag("Player").GetComponent();" unless you changed some code. Let me know if you need more help!
@MCew_prv Жыл бұрын
@@sventomasek thanks a lot, i didnt implemented the rigidbody because i habe a 2d Game and have no Moving player so i can try to simply remove it. I didnt thought of still having code with the rigidbody. Thanks
@LeftoverAtoms Жыл бұрын
Copied the script and tutorial 1-1 and I have no rich presence?
@sventomasek Жыл бұрын
Do you have activity status turned on in Discord? It's under settings > activity privacy > display current activity as a status message
@RubyPiec Жыл бұрын
what if i wanna do this for a game that isnt mine?
@sventomasek Жыл бұрын
Then you would have to learn how to mod the game, which I wouldn't know how to do.
@RubyPiec Жыл бұрын
@@sventomasek ah, okay. there arent any tutorials for this unfortunately either :( this was like the best i could find
@pietro420 Жыл бұрын
Bro, for some reason it says "Internal Error" on the console
@sventomasek Жыл бұрын
I can't help you without the full error.
@pietro420 Жыл бұрын
@@sventomasek I got it now, it was because my discord rpc server was turned off
@AenR1 Жыл бұрын
can u help how can we show scene name in rpc like playing in {worldname} world
@sventomasek Жыл бұрын
You can get the scene name using SceneManager.GetActiveScene().name Don't forget to reference UnityEngine.SceneManagement at the start of the script.
@AenR1 Жыл бұрын
@@sventomasek thx i did and can we add buttons?
@sventomasek Жыл бұрын
@@AenR1 Haven't really looked into it, but you can search for it in the documentation discord.com/developers/docs/intro I might make a video on how to do it in the future.
@AenR1 Жыл бұрын
@@sventomasek thx a lot
@ekal3_YT6 ай бұрын
what does the noclip thing do, does it work?
@sventomasek6 ай бұрын
I don't really know what you're referring to. Can you be more specific and maybe write a timestamp?
@ekal3_YT6 ай бұрын
8:00 it says in movement no clip
@sventomasek6 ай бұрын
@@ekal3_YT It allows me to fly and move through walls when enabled for debugging purposes. I haven't included it in this video as the video is about discord rich presence and not player movement.
@ekal3_YT6 ай бұрын
oh cool, thanks for the info
@eyepatch6726 Жыл бұрын
How can we create rich presence for an already released famous games?I saw some people do it idk how though.
@sventomasek Жыл бұрын
That would depend on the game. Try looking up if the game has some modding tools.
@eyepatch6726 Жыл бұрын
@@sventomasek can't we do it without mod?because I want it to work with that game in real time
@--__--__--__--__--__--__--__-- Жыл бұрын
my image is not working
@sventomasek Жыл бұрын
You need to wait a few minutes for it to upload. If it still isn't working then double check if the image name on the website and name in the script is the same.
@--__--__--__--__--__--__--__-- Жыл бұрын
@@sventomasek now it works but i have another question, can i add like buttons that for example send me to project page when i click them?
@thelelik02 жыл бұрын
Help me please Assets/Script/Discord_Controller.cs(42,42): error CS1061: Type `System.DateTimeOffset' does not contain a definition for `ToUnixTimeMilliseconds' and no extension method `ToUnixTimeMilliseconds' of type `System.DateTimeOffset' could be found. Are you missing an assembly reference?
@sventomasek2 жыл бұрын
Can you post your code here? It's a bit hard to figure out what's wrong without it.
@thelelik0 Жыл бұрын
@@sventomasek Yes, using System.Collections; using System.Collections.Generic; using Discord; using UnityEngine; public class Discord_Controller : MonoBehaviour { public long applicationID; [Space] public string details = "Исследует мир!"; public string state = "Текущие координаты: "; [Space] public string largeImage = "1"; public string largeText = "Project Porcelain"; private Rigidbody rb; private long time; private static bool instanceExists; public Discord.Discord discord; void Awake() { // Transition the GameObject between scenes, destroy any duplicates if (!instanceExists) { instanceExists = true; DontDestroyOnLoad(gameObject); } else if (FindObjectsOfType(GetType()).Length > 1) { Destroy(gameObject); } } void Start() { // Log in with the Application ID discord = new Discord.Discord(applicationID, (System.UInt64)Discord.CreateFlags.NoRequireDiscord); rb = GameObject.FindWithTag("Player").GetComponent(); time = System.DateTimeOffset.Now.ToUnixTimeMilliseconds(); UpdateStatus(); } void Update() { // Destroy the GameObject if Discord isn't running try { discord.RunCallbacks(); } catch { Destroy(gameObject); } } void LateUpdate() { UpdateStatus(); } void UpdateStatus() { // Update Status every frame try { var activityManager = discord.GetActivityManager(); var activity = new Discord.Activity { Details = details, State = state + rb.velocity, Assets = { LargeImage = largeImage, LargeText = largeText }, Timestamps = { Start = time } }; activityManager.UpdateActivity(activity, (res) => { if (res != Discord.Result.Ok) Debug.LogWarning("Failed connecting to Discord!"); }); } catch { // If updating the status fails, Destroy the GameObject Destroy(gameObject); } } }
@sventomasek Жыл бұрын
@@thelelik0 The same code works fine for me. Do you have .NET Framework installed?
@slicetheduck Жыл бұрын
If you are using dontet 4.5 or ealier try "(int)System.DateTime.UtcNow.Subtract(new System.DateTime(1970, 1, 1)).TotalSeconds;" The method used in the video only works for 4.6 and up, althogh unless you have stuff that specifically requires dotnet 4.5 or lower id recommend bumping up those versions.
@raingayming Жыл бұрын
i get the error ```ResultException: InternalError Discord.Discord..ctor (System.Int64 clientId, System.UInt64 flags) (at Assets/Plugins/DiscordGameSDK/Core.cs:1017)``` can anyone help?
@sventomasek Жыл бұрын
Sorry for the late reply. Have you tried making a new Unity project and following the steps again? I don't know how to replicate the error so that's my best guess. Also make sure to place all the files into correct paths like I did in the video.