#π»βcode-beginner
1 messages Β· Page 811 of 1
Smart, glad i asked lol
cuts down on the 10 singleton gameobjects i already have π
You probably already setup things somewhere on game start so that can also do various tasks
Its a good thing to learn that you dont have to have everything be a monobehaviour and a component
I'm gonna admit that I spent an embarrassing amount of time rereading this to understand what it meant π
I figured it out, but now I feel like such an idiot π
The power of indexes
I feel like looping is inefficient if you have the index of the page you wish to open and the index to the page you wish to close
"inefficient" isn't really relevant because it's basically a non issue as I explained below that message.
Plus it ensures that everything is always in the correct state by making sure two pages cannot be activated at the same time
Ah hadnt even seen the other person mention the same thing -_-
I mean yeah fair i doubt there will be too many pages so worrying about it would be silly
If I only understand 40% of what Beans video (Advanced Movement Shooter Physics in 1 hour) is it too early for me to be watching this tutorial, or is this how people learn this lol
If you only understand 40% of it you might be in over your head yes. But you can take the concepts you're not understanding and use them as starting off points for more research
The more you learn about coding the more you learn you know nothing lol
guys I get why the rotation on my character is messed up but idk how to fix it HELP!>
what are you trying to do? and is your rigidbody kinematic or dynamic?
dynamic i think
do you want to rotate your character with force (simulating physics), or just set its rotation?
set its rotation, or like a point i want the player to rotate to, then have the player rotate there
like it works ,but for example when I turn around, my left now becomes my right and my right now becomes my left
I solve this by rotating an object that represents the player rather than it's actual body
but that has it's own problems
I guess I'll try that thanks
oh, no, that only works if the camera is static, I have separate things that rotate the physical body too
sorry, ignore me, I'm tired π
I think setting the rotation based on inputs, should be done in Update not Fixed Update.
And I'd use Transform.Rotate.
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Transform.Rotate.html
Scroll down for examples.
thanks
How do i move an object down with an anim? or better how do i run an anim inside C#?
referring to the animator system?
for the latter you would generally use .SetTrigger or .Play
and for the animation itself, you could simply move the object's transform while recording the clip.
can anyone remember how u open package manager to get the samples tab?
this is a code channel, try #π»βunity-talk
how do i play a sound through C#
look this stuff up, man
have a reference to an audiosource an make it play an audioclip.
though it would be faster to just google it instead of waiting for someone to answer it here :P
now its too quiet
lemme look up how to change dat
tried 100000 and its still quiet
what
audiosource volume is a 0-1 float. maybe your clip is just so quiet or you have the 3d blending configured incorrectly.
should i send the audioclip?
just judge by yourself if it's loud enough. if it is, then it's the issue with the audiosource config.
if im using 2D, does it work? ( audiosource )
yes
ok
can the order of the array of material on a meshrenderer be relied on?
pretty sure its loud enough, is this config good?
in what way
don't see anything wrong here.
As you said before - it's "too quiet", so i guess the audio triggers? if yes then the code isn't the problem here
is it static? is renderer.materials[0] the same as the list in the inspector suggests or not?
the term static does not make sense in what we are talking about but no
the inspector will show renderer.sharedMaterials iirc
I could be mistaken
well is sharedMaterials and material in the same order then?
the audio triggers? whats that? is that the trigger that runs the sound?
"triggers" as in the sound plays and you can hear it, I guess
earlier you said that the sound is too quiet - so i assume it triggers correctly (triggers e.g. activates).
i don't see anything wrong with your code so i really don't know why the audio would be so quiet judging by code logic. my only guess is that it's something with the audioclip itself or the position of the audio isn't set correctly
i think all is setup correctly
i don't see anything wrong here either
Make sure your Audio Source is close enough to your Audio Listener (on the Camera by default)
You should also post a screenshot of your AudioSource component
i dont have an audiosource i only use it once in that scipt
Unity is showing this error: CS0246: The type or namespace name MaterialReferenceChanger could not be found after importing Sample Assets Package & Terrain Tools
I am using Built-in render pipeline
then make sure that Player.Player1.transform.position is close enough to the AudioListener, as this is the position you play the clip at
i dont know where the audiolistener is, if its next/in the camera, i don have one bcs im modding a game
as SPR2 said, it's probably on the Camera
and i don have one
we really have no insight in the technical aspects of the game you're modding so it's hard to help
hollow knight
wdym you don't have one? if you didn't have it then the screen wouldn't render the scene at all
my only guess is that you could look at how hollow knight overall handles audio but as i said before we have no insight in it
something that modifies the unity editor (WeaverCore) on play creates a temporary tk2d cam
we don't support modding here, sorry #πβcode-of-conduct
we cant help with mods here, sorry
i know
one can know and still ask
not modding just help with audio
that's called either arrogance or ignorance, generally
this is one of the reasons (plural) we can't help with modding, because you don't know about the game your developing
and the issue you're describing seems to originate from not having control over your environment
anyways nvm
i have make .json and manage load the value.
now i wand to do the opiset when press E to save this newPlayerName to Jason how can i do that ?
using UnityEngine;
using System.IO;
public class LoadJsonExample : MonoBehaviour
{
public string newPlayerName; // :point_left: public string editable in Inspector
void Start()
{
// Load JSON file from Resources folder
TextAsset jsonFile = Resources.Load<TextAsset>("JsonExample");
// Convert JSON text to class
SimpleData data = JsonUtility.FromJson<SimpleData>(jsonFile.text);
newPlayerName = data.playerName;
// Now you can use the values
Debug.Log("Name: " + data.playerName);
Debug.Log("Is Alive: " + data.isAlive);
Debug.Log("Score: " + data.score);
// Example usage
if (data.isAlive)
{
Debug.Log(data.playerName + " is alive with score " + data.score);
}
}
void Update()
{
if (Input.GetKeyDown(KeyCode.E)) //save Please
{
// SimpleData data = new SimpleData();
// string json = JsonUtility.ToJson(data, true);
// File.WriteAllText(savePath, json);
}
}
}
What you see in the inspector is either sharedMaterials, or materials if it has instantiated materials. Materials get instantiated when you access materials for example.
Not sure why the order would ever change. Are you asking because of some issue?
Is there any documentation about what you can/can't do with references to prefabs in a monobehaviour?
what exactly do you have in mind? that you can't Destroy them, etc?
there's no restrictions that are specific to prefabs in monobehaviours
What if I access a component on the prefab? Can I change the value of variables from there? Would that persist after ending playmode?
Yeah all those questions are probably things I could've tested myself... but I was just wondering if there's documentation that would answer those questions and possibly others that arise.
unity documentation is here > https://docs.unity3d.com/6000.0/Documentation/Manual/index.html otherwise the answer would be searching for if there any
Yeah I'm aware of the docs website π I was looking for any pages about accessing prefabs from runtime but couldn't find any
those changes would stay yes
couldn't say much about accessing them but i do know it's possible to make them during runtime
Interesting, including non serialized data, as in variables that aren't shown in the inspector?
not as confident there but i would assume so
exiting play mode doesn't touch assets period afaik
I see. tysm for the answers!
you're generally not manipulating the prefab at runtime, just an instance of it
Can you even touch the actual prefab without using Prefab Utilities.. which is editor only ?
in builds the concept of a specific instance being a "prefab" is just a little flag on the object that puts it in a secret scene
All the ones loaded are in the HideAndDontSave scene
public static void RoleAlgorithm()
{
if (PhotonFusionWrapper.instance.runner.IsSharedModeMasterClient)
{
//make a monster
//for how many monsters
for (int i = 0; instance.monsters.Count() < instance.monstersCount; i++)
{
PlayerRef player_i = PhotonFusionWrapper.instance.runner.ActivePlayers.ToArray()[Random.Range(0, PhotonFusionWrapper.instance.runner.ActivePlayers.Count())];
NetworkPlayer tmpPlr = NetworkPlayer.GetNetworkPlayer(player_i);
if (!tmpPlr || !tmpPlr.isReady) continue;
if (!instance.monsters.Any(x => x == player_i))
{
instance.monsters.Add(player_i);
}
}
foreach (var player in instance.monsters)
{
NetworkRoles.SetRole(player, NetworkRoles.Roles.Monster);
}
}
}
honestly no idea, but when i do
NetworkPlayer tmpPlr = NetworkPlayer.GetNetworkPlayer(player_i);
if (!tmpPlr || !tmpPlr.isReady) continue;
unity just crashes π
this is GetNetworkPlayer
public static NetworkPlayer GetNetworkPlayer(PlayerRef player)
{
if (PhotonFusionWrapper.GetPlayerNetworkObject(player).TryGetComponent<NetworkPlayer>(out NetworkPlayer networkPlayer))
{
return networkPlayer;
}
return null;
}
0 idea why its happening, could someone help me out?
its not about the network
Well, debug what you're getting from player_i, and debug all the dot accessing chain in GetNetworkPlayer
I suppose I should clarify my end goal in case there's possible a much better solution.
I'm making a destructible zombie, a rigged and animated character whose limbs can change their model between damaged states and also fall off. Currently, the ragdoll and the zombie are visually identital but separate prefabs so I don't have to have the ragdoll loaded but hidden in a scene where there could be hundreds of zombie. The zombie can also become a ragdoll when it dies. When a limb falls off, my goal is to make it look at the ragdoll prefab and find the part of the ragdoll it can duplicate to have a physics limb be created in the fallen limb's place.
And where my question comes in is I want to have a data structure where I can cache that hierarchical search for limbs instead of just traversing through all the armature's gameobjects when a limb falls off.
I would probably store that data structure as a variable on the ragdoll component in the ragdoll prefab.
Very roundabout question...
random two cents but this feels like something you could just handcraft or cache/populate in editor somewhere, no?
You can use OnValidate to serialize these parts, but otherwise can just do it in awake.
honestly not sure which is least painful but maybe something like a dictionary like
Dictionary<string, List<GameObject>>
where the string is the bone name (using names is yucky but i assume more acceptable in rigging contexts?) and the list of prefabs to switch to that would be ordered from least to most damaged
Do some hiearchy search downwards from the armature
or if this is stored on the prefab the key could be a direct reference to the bone object which might make things easier
I mean the idea is there in your post, you just need to cache it yeah
Right, and where would I cache it?
probably not a big issue anyway, can't expect the zombies to have thousands of limbs now
probably just wherever this swap is actually taking place, which i assume is somewhere enemy code related right
btw you might already be up on this, but if they are legit identical except for model and texture stuff, you might be able to just swap those references instead of swapping in the whole different gameobject
I think what I should do is just create a helper component to put on an empty in the scene that caches what I need on startup
If I put it on the armature or enemy there would be many duplicates of the same data
If each instance has these objects already then that is not duplicate data
If however they would all point to the same external stuff, why not use a scriptable object and reference that?
yeah SO over empty in scene
Then its just 1 reference to a shared asset that then points to many things
The mesh, textures, and GO hierarchy are the same, but the enemy has the enemy controller and the ragdoll has no controller and all the rigidbodies and physics joints
prefab variants work too
I assume you'd have different type of body parts if you have a different zombie variant
If I use an SO the cached data would need to be serialized to be editable in inspector, right? If that's the case I can def just created that data type for this purpose, just wanting to clarify.
Yeah this is smart, is there a performance benefit over using two different prefabs?
prefab variants offer no perf benefit, it just helps asset creation
The benefit is that you can have some root prefabs where you provide default values or fallback onto
as when built the "variant link" vanishes and both prefabs contain the same data
I remember the dark ages when we could not nest prefabs π’
zombies always have 10 parts say, but you have red zombie and green zombie where their hand limbs are different but otherwise share the same parts
Ok I hope this isn't all going over my head lol
Currently I have just one zombie for testing but I could totally see the benefit when I have more than just one type
prefab variants and SOs are similar, just that variants are easier to load and play with in the editor and don't require you to script extend
this kinda thing has many levels to how well you can cook it up so land on whatever you feel
Yeah I was getting that impression too, wondering which approach is the most 'optimal'
I'll just need to weight the pros vs the time cost of refactoring for the different options.
Scriptable objects are custom assets with serialised data. Prefabs are gameobjects with components serialised as an asset.
pure data approach is a pain sometimes as if you're caching all the serialized data in it then it won't be loaded at editor time
how do you mean?
I have worked with pure data configuration and as long as your system does not rely on monobehaviours you can easily load it at edit time
let's consider you build your zombies using an SO blueprint, then this would be done in awake. Let's use textures for example, you wouldn't see this applied till the game is ran so you don't have that prefab to see those changes on the scene in the editor.
doesn't have to be done in awake
Can be done in an init methods too
just saying that if you construct your objects using a blueprint like this, you don't have those assets loaded at editor time
unless you do
you yourself suggested a way to do so π
Yeah true, you can do some additional work to serialize it like that
Holy moly my head is going to explode lmao
Dont forget that in editor if you want to automate things and access this data you can just use AssetDatabase and load whatever you wish
But full SO workflow you can basically have a single prefab and just use SOs to construct these objects
good object pooling solution
Oh i like that
Spawn base prefab, pass reference to some EnemyConfig scriptable object instance to set up
Wait what would SO's have to do with being setup at runtime?
If I'm understanding right
Scriptable objects are assets with data so something can be initialized with that as its data source
class ScriptableEnemy : ScriptableObject
//Where you put stuff like the limb damage prefab stuff you wanna cache
class EnemyBehaviour : MonoBehaviour
ScriptableEnemy enemyPreset; //enemies just reference this for per type info
public void Initialize(ScriptableEnemy newPreset)
enemyPreset = newPreset;
then you could just spawn variants via differing scriptableobjects and 1 prefab, like
EnemyBehaviour newEnemy = Instansiate(enemyPrefab);
newEnemy.Initialize(whateverEnemySoYouWant);
(super rough pseudo)
Ok I think I did a bad job communicating my goals.
What I initially envisioned in my head, just roughly, is being able to cache like a child GO of the ragdoll's armature indexed by name.
For example, when the left bicep becomes damaged enough for the limb to fall off, I would query a data structure with "bicep.L" (the name of the bone) then I would receive the corresponding bone in the ragdoll.
This would be useful because then I could go down the chain of bones and copy the joint components that connect the bones as well as the rigidbody. So I would have the bicep and the rest of the arm of the ragdoll because that part of the enemy was damaged enough.
I just tested it and I can't reference a child of a prefab from a scriptable object, so maybe this idea won't work?
Sorry if I just threw a big curve ball to this question π
what happens when you try?
Just doesn't allow the assignment in the inspector, like it doesn't turn blue on hover
You would need a script in the prefab that then provides "easy" access to its children
You should be able to traverse the whole prefab without instantiating it however
A serialised reference can only be to the prefab asset itself so this is expected behaviour
Alright, so say on the 'Ragdoll' component that's on the root of the prefab, I could have a function to query by name to get the GOs I need?
are you sure?
this might just be a drag and drop issue
make a helper function on an empty or something that queries the whole single prefab reference and stores its children however you want
[CreateAssetMenu(fileName = "ScriptableEnemy", menuName = "ScriptableObjects/ScriptableEnemy", order = 1)]
public class ScriptableEnemy : ScriptableObject
{
[field: SerializeField] public GameObject Target;
[field: SerializeField] public List<Transform> Bones { get; private set; } = new List<Transform>();
private void OnValidate()
{
if (Target == null) return;
Bones = Target.GetComponentsInChildren<Transform>().ToList();
}
}
Im like 98% sure
seems serialized when i opened the so up in vs code? dunno how to test fully
A prefab is an asset so we are referencing the asset
You would have to test if this is true or not with editor code
the children of the prefab are not sub assets thus i think this is not possible
This would never work anyway as a prefab stage (when we open a prefab to edit) is not the same as the prefab asset
I see
Target: {fileID: 3228641908602560799, guid: 35a3ad93f07f636488be5a93440abcec, type: 3}
<Bones>k__BackingField:
- {fileID: 7715963414774346853, guid: 35a3ad93f07f636488be5a93440abcec, type: 3}
- {fileID: 8041979215210558262, guid: 35a3ad93f07f636488be5a93440abcec, type: 3}
the serialized data, dunno if this confirms or denies anything
Perhaps we should go with the empty in scene approach?
Hmm interesting id have to try this out myself but I think this is not something a beginner should try
A scene is not ideal for things you want to load and access at runtime is it? you would have to load in the scene to get stuff from it
not if you make it don'tdestroyonload
I don't really plan to have the gameplay be in multiple different scenes, and if so, it would just mean I need that empty with the helper component to exist in every scene where gameplay does occur?
It has to have been loaded to do that and that doesnt help then does it
well unless you're trying to spawn stuff the first frame I don't see the issue
If you simply want it in the scene for easy access then thats a different story
but again is a poor solution to just using a prefab and learning how to do it properly
its really not hard to make a script to provide easy access to other objects
fair, but what in coding isn't a poor solution to an otherwise trivial problem?
If we go with Batby's solution all we would need is to make it a dictionary with the keys being the names of the bones and then the values being the transforms of the bones with that name.
Then as long as that data is saved in the SO then the problem is pretty much solved. I can query the bone and get it's children from the transform reference.
correct but also unity is shit and doesn't serialize dicts so you would either need to find a solution to that or store them serialized as a little data type then make the dict at runtime or something
name to name mapping isnt bad but if you keep doing find by names at runtime it may get a little slow
not if it's an occasional query
And yea to do that it would need to be done in code manually as a static dictionary
you could do a god damn linear search with no performance hit if it's just once
or using ayellowpaper's serialized dictionary shoutout that guy
yea thats why i said "keep doing find" ffs
I said occasional, that's within your parameters
Does OnValidate only run on serialized fields? If so maybe I could just populate the dict with a function that runs on an editor button press?
honestly just chuck this bad boy in https://assetstore.unity.com/packages/tools/utilities/serialized-dictionary-243052
I don't see why not π
Man you guys are dedicated, thank you SO much to @timber tide @sour fulcrum @grand snow @spare mountain for this gracious help, I seriously appreciate it!
I'll try the serialized dict and I'll post here if it doesn't work.
I unable to know why unity is showing CS0246 error on newly created URP projects:
That doesnt exactly look newly created... does this happen before you add any scenes or assets?
Yes, that error occurs while creating new project and ask me to enter with safe mode
upgrade all of your packages to the latest version and delete your library folder
ok
how do I fix my rotation? it only works acording to world position
you can transform to local rotation via the functions on Transform
Sorry im dumb. You would transform the direction, rotate the rotation with another (Quat * Quat) or use a matrix to transform the rotation
okay
but what do you actually want to do? what should the rotation be in relation too?
Transforming the look rotation input is probably easiest
right now when i try to turn right for example it will, but I cant turn right again with that same control because im already at right
if im making any sense
you are moving in world space and making the transform look in that direction. Is this third person?
yah
then i dont understand what you mean by "turn right"
like if I try to turn my character in the right direction it turns but then i cant move in that direction again with "d", because I have already reached right
sorry I realise how confusing my wording in I'll try to think of something better to
To me this isnt a concept you can have when you press a direction and move in that only
You would have to have A+D rotate the body and W+S move forward (but local to the body)
(similar to first person where W+S go forward/back locally and mouse X rotates the body)
k I think ima just do it so my mouse movement controls the rotation
Ah yea 3d third person controls are a tad different. Do you want movement to be relative to the camera?
yah
In the case where camera rotation around the player does not automatically rotate the player we need to make movement input relative to the camera transform (but flattened to the 2d movement plane)
okay I'm going to try to fix the turning
If you want what i described above i can try to help with this
Hi ! So i recently started facing a big glitch. I have no idea how to fix it despite looking on the internet (maybe idk how to type the right keywords). I hope it is quite common and so you'll be able to help me π
that's a known bug with the rotation tool having way higher sensitivity than it should
i don't remember if it was fixed
try updating to the latest patch version
Sadly, i can't. I tried watching on the net but did not found anything.
Is there know solution to fix that ? I'll be very grateful..
a solution to an editor bug would be to update to a version of the editor where that bug has been patched
Why cant you update though?
We are doing a JAM and it will end tommorow. Im very afraid that it would create more news bugs than anything to change version π
patch versions are generally mostly bugfixes
and if you have vcs (you should) then you can always safely revert
Hey, I'm using Quaternion.RotateTowards to rotate my player's physical body (not the actual player object), is there a way to make that rotate independent of framerate?
use Time.deltaTime in the max rotation
okay, that's what I figured, but I thought it was gonna be more complicated
I've really gotta stop thinking so hard about this stuff π€¦
don't assume stuff would be more complicated than it is
you're just creating fake problems for yourself to stress over lol
I will never forget the 4 hours wasted just to realize it was 4 lines that could just be removed π€¦
Its a thing you want to learn early on (how to make things framerate independent)
The examples may already show this too
I know how, but for some reason I keep thinking it's more complicated
thankfully not!
how do I make it so my character isn't hopping around?
use mp4 instead of mkv so it embeds in discord
are you projecting your movement onto the xz plane/normal plane?
yah
ok
!code
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
those are both of my scripts
well not the jump script but those are the movement ones
- you are not doing this, and combined with the fact that you're tilting your entire character up/down, that means you're moving upwards/downwards when you move forwards/backwards as well. usually you would have the player only yaw, and just the camera would pitch
- you're moving the transform even though you have an rb. that will cause desyncs
okay ill use the rigidbody to move and try to not tilt the player just the cam
Does anyone know of any good resources on making a tik-tak-toe win checking algo?
What is a tic-tac-toe game?
tic tac toe* i missspelled it
if you get three symbols in a row, you win
check if any given row, column, or diagonal has all same elements
there's not much to it
I already know which one it is, it's just that I'm impressed to see this typical game in Unity.
The not much to it is the thing i'm struggling with
well you clearly know what to do
The board expands so i can't reference a static pattern
which detail of the how are you stuck on
It has to be dynamic based on the starting grid tile
ah. there it is
In my case, I'm making a GMod game.
what's the win condition exactly?
I plan to have a different win condition in this game, but i still need to check if three or more are in a row
My goal is to have a method with a specified length that will check in horizontal and vertical angles
ok then you can basically do the same thing kinda
go through each possible line, see if there's a sequence of n in a row
I understand the theory, it's the execution i'm having trouble with
what part of it exactly
The pathing for each node in the sequence. Checking just one angle from the center is easy, the first loop could be the node itself, then it moves one right, and goes down one, then repeates for x length. The issue is checking all vertical angles, then all horizontal angles in a way that isn't really dumb
you could also check for opposite sides of the tile that was just placed
I was thinking this, it should be possible to check around the last modified tile
hey i need to ask and learn something
ask away
When creating a player character for a 2d game, is it best practice to use -scale.x or flipX of the sprite renderer? if it makes a difference, the player will probably have a weapon pivot child, which will have the weapon sprite and muzzle child
using the flipx property on the sprite renderer does not affect the actual object, so any child objects will not rotate with the sprite
modding discussions are not permitted here. ask in the game's modding community for help
Oh, I'm sorry, I didn't know.
well.. I wanted to learn
to program
Was i pinged
So then I'd imagine it would be best to use -scale.x? Only thing is I'm worried this would create issues when aiming the weapon or instantiating projectiles but no idea
I was going to ask about code, to modify something, but they told me that modding wasn't allowed, sorry.
a more reliable alternative would be to rotate the object by 180 degrees instead, that prevents issues where some things may not work correctly with negative scale
ahh cheers I will give that a go
I have recently picked up Netcode for Entities (and Unity, Iβm relatively new), and am having some trouble. Iβm making a dedicated server game, which I have had a lot of trouble finding guidance for. To get the connection running, I have a ConnectionManager Singleton MonoBehavior in the scene, that has this start function:
public class ConnectionManager : MonoBehaviour
{
public string address = "127.0.0.1";
public ushort port = 7979;
// Start is called once before the first execution of Update after the MonoBehaviour is created
private void Start()
{
Application.runInBackground = true;
#if UNITY_EDITOR
switch (EditorMultiplayerRolesManager.ActiveMultiplayerRoleMask)
{
case MultiplayerRoleFlags.Client:
StartClient();
break;
case MultiplayerRoleFlags.Server:
StartServer();
break;
case MultiplayerRoleFlags.ClientAndServer:
StartHost();
break;
default:
throw new ArgumentOutOfRangeException();
}
#else
#if DEDICATED_SERVER
StartServer();
#else
StartClient();
#endif
#endif
}
For my testing, Iβm just running it as host becuase it means I donβt have to have as many editors open.
Hereβs my StartHost code:
private void StartHost()
{
var server = ClientServerBootstrap.CreateServerWorld("ServerWorld");
var client = ClientServerBootstrap.CreateClientWorld("ClientWorld");
SetupWorld(server);
var serverDriver = server.EntityManager.CreateEntityQuery(typeof(NetworkStreamDriver)).GetSingletonRW<NetworkStreamDriver>();
serverDriver.ValueRW.RequireConnectionApproval = true;
serverDriver.ValueRW.Listen(NetworkEndpoint.AnyIpv4.WithPort(port));
var clientDriver = client.EntityManager.CreateEntityQuery(typeof(NetworkStreamDriver)).GetSingletonRW<NetworkStreamDriver>();
clientDriver.ValueRW.RequireConnectionApproval = true;
clientDriver.ValueRW.Connect(client.EntityManager, NetworkEndpoint.LoopbackIpv4.WithPort(port));
}
private static void SetupWorld(World newDefault)
{
foreach (var world in World.All)
{
if (world.Flags == WorldFlags.Game)
{
world.Dispose();
break;
}
}
if (World.DefaultGameObjectInjectionWorld == null)
{
World.DefaultGameObjectInjectionWorld = newDefault;
}
SceneManager.LoadSceneAsync("EntitiesSubscene", LoadSceneMode.Additive);
}
This does successfully make a server and client and connect them, but there are issues around the baked entities. My Entities Subscene in the editor has a βPrefabsβ object that has a singleton prefabs component that houses my prefabs so I can instantiate them. When I run the game, itβs gone, along with everything else in my entities subscene.
In some tutorials, Iβve seen people say that you should load the entire scene instead of just the entities subscene, but if I do that, my game gets stuck in an infinite loop reloading itself, because when the scene is reloaded, so is the connection manager, which runs the start function, and reloads the scene again.
Am I doing something dumb with how I load the subscene? Am I approaching the dedicated server system entirely wrong? Iβm not quite sure how to move forward at the moment.
sorry for the wall of text lol
been troubleshooting this for some time now, havent made much progress, thought I'd ask for help
Before you look how to work with netcode you should look at how to work with the entities/dots stack, this all sounds like you are missing knowledge how to work with the base stack you want to build your network layer on
otherwise you might find more success with netcode for gameobjects
I did my research on how DOTs works, I feel comfortable with actually working with it, my problem is with actually setting up the entities subscene when there are multiple worlds
Then you would know that anything not baked in the subscene will not transfer over to gameplay
well it is baked in the subscene
it even gives me the baking preview
showing that the component is there
let me grab a screenshot real quick
then you should find it in the entities hierarchy
everything in the subscene wanders to the entities hierarchy, i think you can find it under "windows", don't have an ecs project to verify rn
(unless it has changed since I worked with the dots stack last time)
I should've said, Ive already checked the entity heirarchy
that's how I confirmed that this was my issue
why is the entities subscene there twice?
I was trying to make a characterspawner system that would spawn in characters for players who don't have one yet, it required Prefabs for update, but it never updated
query said it wasn't there
that's because I use the sceneManager to load the entities subscene after starting the host
let me try removing that
every tutorial I followed told me to
i dont think you should load the subscene additively
i am not sure about netcode for entities, never worked with that, but that looks definitely wrong π
I thought so too
let me see what happens here
from my understanding
what happens is that when you dont use the automatic connection (which only works for testing)
whats the "all=" infront?
can you just look for prefabs without the all if that brings up anything?
you have to create the client and server worlds manually, and delete the default editor world, then load the subscene to reintroduce the baked objects to the worlds you created
also should be any= from my understanding
because not all your components contain "prefabs"
it does this
Hmm at this point it looks like this issue is better posted in #1064581837055348857 or #1390346492019212368
there will be people in either that know about the specifics of both better
I tried posting in networking but then I realized there had been no posts for 30 days and nobody responsed to my post for quite a while, so I took it as dead, took down the post, and put it here instead
plus, since I'm pretty new, I thought itd make sense to put this in a beginner channel
I'm not a new programmer but I'm new to unity and DOTs
huh? networking is about 1 post each day
maybe discord is just lying to me then-
I have it sorted by date posted
I swear, everything I touch breaks
I always have the weirdest issues with tech
and I decided to make it worse by swapping to linux :P
In that case, Ill put my post back into networking and give it a couple days instead of 6 hours
I'd try in dots, tertle is a godsent for any dots related questions, I just dont know if he has knowhow about networking for entities
alright, Ill try that, tysm!
π discord is trying to tell me it's been even longer since a post has gone in #1062393052863414313
Ima just ignore that
yeah people mostly use the general discussion chat in there
but its still 1+ post a day π
Hey, was just wondering if anyone knew of any big issues related to why an IDamageable script isn't working with trigger collisions in 6.3? I could give more info if needed
I dont think unity includes an idamageable by default, is that your own / third party code?
Just some code off a tutorial. It's worked just fine in a previous version, that being 2021.3.14f1 but with the new parameters for layer overrides on colliders, I'm guessing it has to do with those
I mean we can't really help with code you copied from some tutorial when we dont know the code π
Yeah I didn't wanna fill up the chat with shit unless prompted so hang on
!code
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
using UnityEngine;
using System;
public interface IDamageable
{
public void TakeDamage(float damage);
}```
I mean that script itself does nothing yet, if you just use OnTriggerEnter to call that function the behaviour most likely hasn't changed, you should recheck the tutorial steps on the new editor version
using UnityEngine;
using System.Collections;
public class DamageAll : MonoBehaviour
{
[Header("References")]
public LayerMask ignoreLayerMask;
public string excludedTag = "Untagged";
public GunData gunData;
private void OnTriggerEnter(Collider collision)
{
collision.CompareTag("Player");
{
Debug.Log("Touched the thing");
}
if (collision.gameObject.CompareTag(excludedTag))
{
return;
}
if (((1 << collision.gameObject.layer) & ignoreLayerMask) != 0)
{
Debug.Log("Touched the thing");
PlayerHealth playerHealthComponent = collision.GetComponent<PlayerHealth>();
IDamageable destructibleObjectComponent = collision.GetComponent<IDamageable>();
if (playerHealthComponent != null)
{
playerHealthComponent.TakeDamage(gunData.damage);
}
if (destructibleObjectComponent != null)
{
destructibleObjectComponent.TakeDamage(gunData.damage);
Debug.Log("Target took damage.");
}
}
}
}```
that is not even valid code π€¨
Do you know of any good tutorials for the newest version by chance?
Wdym
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
β’
Visual Studio (Installed via Unity Hub)
β’
Visual Studio (Installed manually)
β’
VS Code
β’
JetBrains Rider
β’ :question: Other/None
then you will see whats wrong
Wait what's wrong with it
tutorials are good for many editor versions, unity is pretty upwards compatible, details can change but rarely so big that you cannot find it afterwards
follow the ide configuration and you will immediately see what is wrong
i take it back, its actually valid and runs but there should be atleast a warning displayed π
Oh
Wait, a warning for what where?
Man why you gotta make me think I'm going crazier than I already am, lul
Because you will not get help here unless you have your ide configured and can spot basic errors through that π
I have visual studios
i might have been too early with this, my own ide doesnt warn me π
The extra braces(scope) around the debug log are valid, but meaningless. Other than that I can't see any issue. Though I'm reading from mobile, so I might have missed something. π€
collision.CompareTag("Player");
{
Debug.Log("Touched the thing");
}
The compare tag should be in an if
otherwise it does absolutely nothing
Aah, I see.
Debug logs are there just to find a clue
I thought it would give a warning cause it doesnt use a return value
turns out my own ide doesnt even mark this
All-in-all, this worked perfectly in a 2021 version I had, and using this in 6.3 has it not working
Well, at the very least your debug log doesn't help debug the issue, but makes it more confusing.
if you do the tutorial step by step again it should work again
depending on the way you updated it might have broken your layers
I'm confused by what you mean, because I can see it displaying the log in the console when the objects collide
thats why there is no warning π
your comparetag is not used in an if
i just runs without using the output
I know, but that shouldn't matter for the overall problem
true, but will still confuse you with wrong log outputs
as i said, just follow the tutorial again and it should fix itself
I wasn't confused by the debug logs
i didnt say that, i said they could/"will" confuse you down the line cause you are getting wrong logs
Just need to figure out the main problem
Because the logs mean that that something touched something. Regardless of it's player or not. If something else in your scene(aside from the object you're debugging) has this script, then you'll get false positives.
Another issue is that you have several logs printing the same thing which would prevent you from understanding which one of the logs actually prints.
It doesn't matter. I've already verified that the IDamageable script simply isn't working in the newer version
What classes implement that interface?
Because if that's all you have, of course it wouldn't work.
A destructible object class and a few others
Well, then you'll need to debug those. See if their TakeDamage method is being called at all, and whether the logic in them is correct.
I have done so
Can you show us how
I'll investigate this further in my own time. I'm fairly certain it's the newer version
Well im on the newest version and my IDamageable interface works fine lol
Unity updates breaking user code sounds like a creepypasta.
Every copy of Unity is personalized 
I keep getting an error for object not set to an instance of an object. I get the component and have it attached in the inspector I'm trying to access the player class data through the game manager class and it's assuming the component is on the actual game manager
Can you show us the code?
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
So, my Unity is really starting to get sluggish and has to load with even changing tabs. All I really have at this point is my character, so I'm not too sure why it's having such a hard time. Is there something that I can look at to fix this?
What are your pc specs?
really good π
lemme get specifics
but I got it to run hefty games, and it doesn't struggle too bad
Your task manager show anything when running the unity editor?
yeah, unity is eating most of my memory
restarting the editor seemed to help... for now at least
If you mean built games made by other people, you can't. If you mean your own project, you can use the debugger in Rider or Visual Studio
Could be something, could be nothing tbh
i dont have any code errors in my actual code it just happens when the game actually attempts to play
If your gamemanager doesnt have a Player class on it, then getcomponent wont do anything.
You either need a direct serialized reference or to find your Player in the scene with tags
Wait
Why does it have the Player class on it?
Your Game manager and Player game objects both have the Player class?
i was trying to simplify it by routing everything through the gameManager it seemed like the correct thing to do it all worked perfectly until to much was going on so i refectored to simplify now i m lost lol
Thats not really how that works
If you want to reference your Player class on your Player gameobject in the manager you need some direct reference to that instance of said class
You cant just add the Player class to the different game object as a component, thats a completely different instance
!learn
:teacher: Unity Learn β
Over 750 hours of free live and on-demand learning content for all levels of experience!
so do i set the reference in the player class and the use that reference in the manager
No you get a reference to the Player inside of the game manager
i have a reference to the player inside the game manager on lines 7 and 8
thats a reference to a player
like a empty plastic box with the label "Player" on it
you have to actually put something in the box
Not even empty
They did assign it a value, the player script on the gamemanager object....
Decompilation isn't an allowed topic here.
Well, technically, it's illegal. Or I guess against tos. So of course unity wouldn't allow such a topic on the official server.
The rules explain it pretty well, read them next time
Ok
Is it bad practice to stack a bunch of different functions into single scripts?
Like having Pause Menu, Inventory Menu, and NPC Interaction Menus all be in the same script?
I'm just thinking of doing it this way because they all have a lot of crossover with things needed to be filled out (variables and such), so I thought it'd make it easier, but I worry that it'll start having some noticeable detriments to performance.
Performance, unlikely. Organizing and maintaining, definitely.
If they need to share functionalities like opening up, closing, etc., then you can either have them inherit from a base Menu class, or use interfaces to assign functions.
If these functions all require the same variables, consider setting them as global variables and placing them in a common centralized area, such as a completely independent class. Of course, this is not mandatory, as it depends on which method you think is easier for you to understand, as everyone's thinking logic is somewhat different
It is recommended to place functions with different functionalities in different locations, which is in line with the principle of division of responsibilities
The simplest way for different classes to call each other is to store references to other classes in their own fields for future use, but this is not conducive to decoupling. Decoupling means that the direct hard coded links between different classes are minimized as much as possible (which is often necessary and very effective). Hard coding means that any data or anything is written directly in the code file, for example, var time="12:30". In this example, the soft coded method is var time=Timestampystem. GetTime()
A decoupling solution that is beneficial for beginners to understand and is very effective is the event bus. The name is not important, but it roughly means that the links between different classes are implemented by informing the event bus as much as possible, and the event bus finds each other and calls each other's functions on its own. In this way, the chaotic links between different classes are simplified into any class being only linked to the event bus and not to any other class. This becomes a very simple star structure (star structure refers to any individual being only linked to the core, while the core is connected to any individual. If an individual wants to send a signal to another individual, they can only send the signal to the core first, and the core finds the target and passes the signal over)
That makes sense. For the most part, why I feel the need to keep it all in one script is because it's all menu related, so a lot of the functions are overlapping. However, I worry I'm slipping out of just menu stuff.
Initially, it was just the pause menu, then I added the inventory, and because it used the same controls and objects and needed to check what each other was doing, it made sense. Now, I'm adding the interaction stuff, specifically interacting with NPC's and the Hacking mini-game, which I want to run off the same system, but they also have overlap with menu stuff. So, I was thinking it'd be better just to make a dedicated script for interactions, since I generally want them all to function the same.
The core implementation idea of event bus is: a dictionary with keys as class types and values as functions, used to store various target functions, and class types are used to distinguish signal types. Here, using class types is just one implementation method.
For example, when you want to get the time in the player script, the simple approach is: var time=Timestamp system. GetTime(), while the decoupling approach is: first write "EventBus. Set<IWannaGetTime>(OnGet Time)" in the class initialization function, which means you inform the event bus that you have registered a function with the class signal type IWannaGetTime. Then, when you need to get the time, write "EventBus. Send<IWannaGetTime>()", which means you notify the event bus that you want to know the time data, and the event bus itself will find the time system and let it send the time data, so your OnGet Time function It will be automatically called by the event bus after the time system calls' EventBus. Send<IWannaGetTime>(timeDataValue) '
As a learning project, you can simply divide the script based on responsibilities and not worry about anything else for now
im trying to make an airsoft game for vr, if anyone can help pls dm me.
how can i fix an object spiralling when being rotated. i understand its because the pivot isnt in the center, but with a pivot go at 0,0,0 and the mesh at 0, -0.49, 0, when rotating the pivot the child still spirals
is my best bet using RotateAround? i am aware that i can edit the meshes pos in blender but i cant open the mesh file not sure why
!collab not the place
:loudspeaker: Collaborating and Job Posting
We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
β’ ** Collaboration & Jobs**
Hello, Im have an RTX 5080 (blackwell) and I starting to thinks that I can't connect Ml agent to my gpu, is there any way to use ml agent with an rtx 5xxx gpu ???
Child objects are going to rotate when the parent does, if you just want to rotate the child individually then do that instead
Otherwise yea you'll just need to fix this in blender somehow.
seems like ur confused about the transform things, the rotation of child objects is also affected by the parent object, and the rotation values are divided into global rotation and local rotation. As you said, the rotation axis can be determined during rotation. I suggest that you take a screenshot of the structure of your object and explain how you want it to rotate, so that we can help you determine how to rotate it correctly
Anyone here faced this issue?
https://discussions.unity.com/t/serializefield-drag-and-drop-not-working/1709881
you are trying to drag them to a script instead of a script instance, setting default values for a script can only be done with prefabs (things that live in your project folder, instead of a scene)
if you put that script on an object in the scene you can drag scene objects into it
Ohhhhh, yea got it. 
I cant send a screenshot right now but i simply want it to rotate how u would expect any new object to rotate. Like creating a sphere and rotating it. its position stays the same. When i do transform.Rotate(..) it spirals, presumably because of the -0.4 on the y axis
rotations come from the pivot, so if the thing isn't "centered" on the pivot, it's going to move
how can i center the pivot
the pivot is the actual position of the object, position stuff relative to the pivot as desired
have the mesh be at 0,0,0 if it's already centered
you said it wasn't, previously
so i have a pivot parent at 0,0,0 that gets rotated, and child mesh at 0, -0.4, 0
sorry for the confusion
yeah the child isn't at 0,0,0...
so the only way to center the pivot is for the child to be at 0,0,0 too? is there no other wa
Do you mean that when you rotate the parent object, the child object will both rotate and move slightly due to some coordinate offset of the child object? I think you can directly rotate the sub object
AAA
Learn how to coding is hard or not?
I have 0% knowledge of coding and i wanna learn on my mobile 
Hard

though it depends on what programming language you pick
but there are concepts that are shared globally and some of them might be hard to pick up
And it's seems i need to learn something before start learning coding
C#
learn code is ez
no need talent
you learn a skill like anything else
I started to learn programming concepts when I was in elementary school
You just need to find a simple and high-quality instructional video to help you understand what programming is, and leave the rest to time
programming concepts
what does that even mean really
As a beginner, I suggest that you have a basic understanding of C, but not learn it(just know there is a language called C thats already enough), because most languages are similar to C. Then you can choose a simple and easy to learn language to start learning, such as C#
it means programming concepts
LOL
thats vague. like what?
absolutely no reason to get into C, just to learn C#
- have basic understanding
- "not learn"
?
You need nothing from C in C# they are different languages
okay
If you wanna shoot yourself in the foot. Learn c first. If you wanna shoot yourself less often in the foot. Learn c++ but when you do shoot yourself in the foot with c++ itβll hurt alot more.
then skip it
Let's not pick words anymore, just remember the last sentence I said, my friend. Learn -->> C#
π
start from the Pins in this channel, take your time. Lots of practice and thats it
don't overthink it
You don't need such high concepts in the beginning, theory is good but you can learn along the way.
Lots of compsci graduates know the big concepts but have 0 skills in coding anything worth anything. thats a fact
from phone, i think u will need a app to learn the basic way to code
There are some programming software for teaching purposes on mobile phones, but they have very few functions and only provide basic functions. Moreover, because mobile phones are mostly based on Android or Apple environments, rather than real Windows environments, some effects may be different, and the final output of the compiler may also be different
facts, Logic is probably the main thing you need. That applies across anything besides programming tbh
problem solving and all
this is going to suck tbh. coding requires a lot of symbols that a mobile keyboard just isn't great for. there'll be some editors that try to make it easier, but it's not gonna equal a proper keyboard (or even an ipad keyboard with easier access to symbols)
Hey guys
So i have bin struggling for like a few weeks making an inventory system with Drag And Drop
I have an working inventory but only the different interactions like adding an item removing one stuff like that
Also i have an Drag and Drop Code but it is hard to connect these two mechanics any ideas or Youtube Tutorials?
yep, thats wut i mean before, but if think they are diff, its fine, then skip it, go to lean C#
if your goal is to learn c#, why would you learn c just for that purpose
i didnt say that, well, skip it
learning c can be useful. but there are more effective ways to learn
any ideas or Youtube Tutorials?
start small and build your system up, you might be jumping into something way over your skill level
u missunderstand wut i tried to say
i mean, you did say this
I suggest that you have a basic understanding of C
and if u didnt get it, its fine, just skip it
tbf .. that != learn
it's still wrong, but it doesn't mean that
well, i said "learn C#"
sure, but you don't need that either
What about w3school website.. is it good for learning?
sure
very low skill floor, very low skill ceiling. there are better resources
its okay.. but the microsoft site is better tbh
like the ones in the pinned message, as you've been directed to
check pins π
but also it really is like a whole new language. it's going to be tough no matter what
I already have and i mean it is way out off my Skill level bc i never done something like that i have no Clue but i think i found an good Tutorial :D
I could show you my Code that i have rn for just the Inventory and you could rate and juge it if you would like 
i found an good Tutorial π
this is a mistake
why?
you're essentially copying someone elses system
when you build it up yourself you will know exactly how it works
that can be a good way to learn for some people..
If you must make me 100% clear about what my previous sentence meant, then my basic idea is that different languages have different ecosystems, environments, grammar, and logic. But most languages share some similarities, perhaps in terms of ecology, environment, grammar, and logic. For example, both Java and C # languages can write desktop programs, and their ecosystems have certain intersections. The syntax of Java and C # is also very similar, and their logic is also very similar. They are both object-oriented OOP languages
true but you could be learning a shitty way of doing it, how does a beginner know its "good"
check multiple different ones then create something of your own from there
Yea but i am not new new in coding i understand whats happening but i have no clue how to connect those mechanics bc i never done that before
And as we all know, languages like Java, C++, and C # all contain concepts of variables, objects, classes, and polymorphism
i mean following a tutorial just to get your bearings isn't bad tbh.
following a tutorial blindly as gospel, that would be bad
C language appeared very early and has undergone many years of development. Many languages have also borrowed different parts from C language and upgraded, improved or completely different from it
we splitting atoms lol all i said it check multiple sources of how they do it and build it up yourself
The most basic functions or concepts of C language include variables, functions, pointers, and header files
this way you know how to "connect everything" cause you built it
@maxy I think you can stop now bud
Variables and functions exist in many languages, so as a beginner, it is important to first understand what C language is and its basic concepts, such as variables and functions. This is a good starting point for teaching, but it does not mean learning C language. Learning C language means a deeper understanding of its operating mechanism, library files and functions, as well as various miscellaneous features or hidden techniques
@ornate cosmos what are you trying to prove here man
but c# you dont have to deal with pointers..
you can but you don't have to..
you do not need to learn C variables and functions. they work differently from C# variables and functions.
Usually, it only takes 5-10 minutes to introduce C language, followed by a brief introduction. It is understandable for beginners to understand C language, as it allows them to learn about the differences and design ideas of different languages anytime and anywhere
stop the c rant
it is a detour that is wholly unnecessary.
If you still don't understand what I mean, then as I have mentioned many times before: Skip it
we're trying to stop you from giving bad advice here tbh
bro I was working in a kitchen pre-2018 .. I did not learn C before learning c# to use unity..
@ornate cosmos Stop with chatGPT dump already
so stop suggesting it lol
i already said it, u didnt listen it
yeah this sounds like a bot dump
that is totally wut i type
we're listening and we think you're wrong
if u say so π
u said i mean learn C language, but i never say learn it, if thats how u understand it, thats ur problem, not mine
just fell into the self verification trap again, skip wut i said
brother, just stop.
alright then, let me be clear
it is important to first understand what C language is and its basic concepts
taking time to understand C concepts is unnecessary to learn c#, bordering on harmful.
you're deluding yourself into thinking we don't understand what you're saying.
yes, C # has a GC system and other advanced features to help developers develop programs. Basically, you don't have to personally touch pointers, but you can also write some code about it through unsafe. This part is what comes later
i already clear the meaning wut i said, so yeah
no-one was in doubt
this is a unity discord. So the topic is unity, you need none of this to use Unity. Period.
but why are you forcefully keeping this conversation ??
someone mentioned learning programming earlier, so I brought up this point without any problem
except that it's unnecessary and misleading...
i didnt, i already lets skip
someone just always missunderstand my meaning
then skip and stop the rant bruh
no-one has misunderstood
thats annoying
the irony
i skiped, we can keep saying it if still misinterpret my meaning
Maybe if everyone stopped replying to Maxy on this topic, it could stop.
lmfao at the fact they also blocked me, so apparently they're just not interested in good teaching practices lmao
this kind of situations often experiences such incidents LOL
!warn 1203931102432206868 Enough with the off-topic. Stop spamming the channel.
@maxy_0102 warned
Reason: Enough with the off-topic. Stop spamming the channel.
Duration: Permanent
hey, where can i ask a question about shader graph?
that would be #1390346776804069396
thank you
I'm looking for some free 3D RPG weapon asset packs that include multiple types (swords, axes, bows, etc.). Does anyone have any recommendations from the Asset Store or itch.io?
this is a code channel, and couldn't you just search around for stuff that fits your needs
oh okay
sorry
Curious, are IEnumerables a type of interface?
you could look this up, docs will say
by convention, interfaces start with I
Good idea.
Ok i watched the tutorial on pins
And got new things 
Frustration

And one last thing

Do you recommend watching the tutorials and then try to test what your learned on the PC
Or test while learning?
And what the first thing that you all recommend trying.. making your own test game? Or try modding games?
Start with Junior Programmer Pathway, or Essentials even if you new to the engine. It mixes practical work with examples.
I'm not only new at engines
I'm new at the entire programing 
So what the first language i need to learn to make the rest easy to learn
Also if i will only use my mobile
Should i surrender
?
I'm having withdrawal symptoms because I can't post a gif on it...
C# is pretty easy.
You're not gonna learn this stuff overnight, sometimes it takes years of learning. Lower your expectations a bit.
You can use mobile for learning if you at least use a bluetooth keyboard or something it will be easier, now days they have working online compilers you can use to practice
Years!!!

GG for me
You should start with https://learn.unity.com/pathway/unity-essentials
It will guide you through the very basics and into programming.
A bonus to have done some pure C# course first though.
what did you expect exactly ?
Maybe a few months you can get a basic app going but it depends on how much dedication / time you have
I barely speak native English
And in this case.. anything take years with people take centuries with me... Specially if it was full of math
most of the math you need to know is basic elementary school stuff
the computer & language is doing the heavy lifting for you
Thank god 
Courses have videos and fully written as well (usually AFAIK), with code examples attached, so everything is translatable.
You can't run Unity on mobile.
I know
they want to learn programming first which you can do on mobile
sites like w3schools have online console / compiler you can use to run code
Just making sure, because.. ye know..
ya get a used laptop or build something later if you wanna run unity
I didn't mean it, just a joke
I already 2+ years with Unity :)
Sorry, didn't see I replied to the wrong message. It was meant for Rawad55.
Yeah i saw multiple YouTube videos
Most of them agree on one thing
Python is beginner friendly
the hardest part of learning to code is the Logic, problem-solving aspect. choosing a more "beginner friendly" language doesn't change that
Dare i say fuck python, ugly language
Based on the fact that you can only use your mobile phone, learning Python may be more practical for you. Of course, if you can find some good C # teaching software on your phone, then you can learn C#
The learning difficulty of Python and C # is relatively low, at least lower than that of C++
Python may not make you give up easily, because you only need to start learning directly from the form of print ("hello"), while in C #, you need to try to remember the class first, because the default template of C # has a class, followed by a static main method entrance. However, the new version of C # also supports top-level syntax support (perhaps not called that name, but it is probably like Python, where you can directly write code that can only be written in methods). In addition, methods and functions are similar. Functions in a class are called methods or behaviors, and their translations may be different
this dude posts canned AI responses
"translations" yea smells like ai
you can litterally ctrl-f their previous messages and see the striking difference in how its written lol
don't bother it will post more canned responses and block you like they did some of us
In addition, methods and functions are similar.
dead giveaway this is ai as well
C# does call them methods but function is a valid name too
the "in addition, " part i meant
if non-native speakers are not allowed to use the translator
Except its obviously not just translated but ai rewritten or written entirely by ai
brother you type different than how you posting canned responses
and these are simple things
im sure they are, is that why you used AI to write them out
punctuation for one
okay
can we not ..
i understand why u say that now
Im sure you understand a lot
just in case, cuz in my here people always say these names
top-level syntax is horrid
The internet is full of generated ai content. You cannot trust it anymore that its humanly written
lol u actually believe its AI not translation
crazy
yep i dont use it, just metion it if wanna use it
its very obviously translated with Ai
!warn 1203931102432206868 This is your last warning to stop spamming AI responses and off-topic for this channel in general. Delivering you via warnings since you are blocking moderation messages.
@maxy_0102 warned
Reason: This is your last warning to stop spamming AI responses and off-topic for this channel in general. Delivering you via warnings since you are blocking moderation messages.
Duration: Permanent

@ornate cosmos You were told not spam off-topic. You blocked a moderator and continuing ignoring moderation, great move.
Next off-topic message from you and you are off the server.
I wanted to write transform but it modified that automatically to TransformBlock and added that using, currently in vs code using C# for Unity Dev
if unity's transform/Transform don't show up in the autocomplete, then sounds like you have not configured your ide.
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
β’
Visual Studio (Installed via Unity Hub)
β’
Visual Studio (Installed manually)
β’
VS Code
β’
JetBrains Rider
β’ :question: Other/None
yeah i wrote transform but when i clicked spacebar it converted into TransformBlock
3ede
what?
you may want to consider disabling "Accept Suggestion On Commit Character"
I made this video to show my friend so sorry if itβs not the most appropriate but i could really use some help figuring out why this is happening
I check the colliders and everything and nothing is touching the cube I have no clue what the issue is or why itβs only happening here
I put the ground layer on that red thing in the back and itβs doing the same thing π I think my jumpy jump is cooked
π Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
π Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
also "my jumpy jump is cooked" is not a good description of whatever it is you're trying to show in the video
My bad
Essentially Iβm trying to fix my jump, for some reason at a very random spot around the cube it bounces like x10 the normal amount
The jump feels bad already and I want to fix that, but right now Iβm just trying to figure out why itβs doing this and how to stop it
use the physics debugger to view your raycast, or draw it in the scene to view it so you can make sure it is actually at the position and direction you expect it to be
Oh how do I use the physics debugger!
True
βΉοΈ da line wrong
π why da line wrong
Let me see something
well it's going from transform.position which means that whatever object you have the component attached to is not at the position you expect it to be. or the mesh is positioned incorrectly. make sure your tool handle is set to Pivot rather than Center so you can see the actual position of an object when you have it selected
https://docs.unity3d.com/6000.3/Documentation/Manual/PositioningGameObjects.html#:~:text=Gizmo handle position toggles
Thank you! This has been very informative
Going to work on fixing it now
Ok thank you again I fixed it and now all is well (except for the slow falling stuff but Iβll fix that later)
the slow falling might be caused by unity's default gravity being low
Would I have too increase the mass in order to fix that or is there a different way for me to go about it?
No, you'd either make your objects smaller or make the Physics.gravity greater
Drag/damping can also affect this
i did see in the original code that was shared that you are setting the linear drag to something specific when grounded and, presumably, the intention was to set it to something else while not grounded but you never actually do that in the code
Oh dang your right I forgot to add that
If Iβm being real I only added that cause I saw it in a tutorial and it made my character not slide off the map when I moved
Iβll look up more on making the gravity greater since i kinda like the scale of everything so far
Ok thank you all! I need to adjust a few multipliers now for the speed of when moving while in the air but the speed at which the thing comes back down is all fixed!
Appreciate it yall!
Can anyone explain to me how to make a script interact with another script
Tutorials explain it too overcomplicated
you can access the public fields and methods by simply creating a reference
But like
What does it mean to create a reference
- get a reference to an instance of the other script you want to interact with
- call its public methods, properties or access its public variables with the
.operator
you basically introduce one script to another
use the SerializeField class for example
you show one script the other exists
There are many ways to get a reference. What does it MEAN though? It's just a way to know which particular object you're interacting with. For example if I said "go in the house", you would need to know the address of the house I'm talking about to be able to go into one, right? A reference is like the address of the particular house.
i think you said it better
So i just type the same variable the public script has?
It wont take it as its own variable hopefully?
no
Choose the best way to reference other variables.
Man i have alot of terms to learn 
If its still confusing then id recommend learning some basic c# outside of unity
SerializeField as an 'attribute' not a class
-# i mean, it is also a class, used as an attribute, no?
I thought serializefield is just a way to change private variables in the editor instead of in the script the entire time
The attribute tells unity that a private field should be serialized (public ones are by default)
yes, serializefield allows private variables to be assigned in the inspector. ideally that is how you provide the reference to the object you are attempting to reference
*other ways are available β’ *
Oh do i just basically call out the name of the script and name it like a variable 
(Scriptname) (variablename);
go learn properly
Thats atleast what i understood
public class MyCoolScript <--- MyCoolScript is now a Type, the Type class
Interestingly enough my teacher never taught me about references as he only ever used 1 class & more often than not just the main method when teaching
Had to learn it myself through just understanding
You can certainly learn that all in Main() but when you go to learn OO you do need to make some classes
Yeah you do learn that each thing refers to something else but i more meant how to juggle them between each other though i guess you'd need multiple classes to do this
Yea you need to make a class to learn you can then use fields and functions on a class/struct instance
wow i have a crazy math thing that is breaking my head right now. i have this beam of light that is aiming with a rotation of X -22 y 0 and z 30. and i want it to move in a similar way to simulate a disco light. but i can t find the mathematical way to do it. every attempt i make either with my logic or with copilot it just starts moving way off. here are 2 pictures so you get some persective on what line i want to move this on. any ideas?(think of the drawn line as drawn on the board!!!)
crazy thought, couldn't you just use an empty GameObject and use transform.LookAt to look at this object and just have the objects move across the floor instead of worrying about rotations?
wdym.
like a circle and make the cylinder follow it?
you have new gameobject you give it some code to move around in straight lines within the bounds of the floor
you then take the light and you in update tell it to transform.LookAt that gameobject that's on the ground
i didn t know i can do that wow you just saved me a lot of time i had my trigonometry book ready !
here example of what i mentioned (ps i know i'm i shouldn't just give answers so sorry ~_~)
can be written in ~5 lines of code
I wanted to ask if there are any people who can help me, have a problem with c# script create..
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
!ask
:thinking: Asking Questions
:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #πβfind-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.
-# For more posting guidelines, go to #π±βstart-here
Oop slightly too slow lol
double kill was about to be a triple
bots still dont have a cooldown huh
yeah... maybe fogsight forgot about it lmao #1455286033255104552 message
I want to insert a script in general but when I go to scrikping and type "empty c# script" it tells me I have to download an app that supports C#, so I downloaded but Mac doesn't support this app joar have no idea what to do but it's also the first time.
As a macbook user I recommend VScode
is there any method to render a ui go with images on top of others without changing hierarchy order
I mean I could child canvas but surely there's an easier way?
I have a problem with my script where it won't allow me to use Collider.gameObject.CompareTag("Player"), but I need to somehow make sure the method in the if statement only runs if the collider is only the player, so that only the player can collect things for a score. Help with this would be greatly appreciated.
Collider is the type
you should probably brush up a bit on basic c#
wait, so the collider is type of function?
I'm a little confused, im very new to coding
Use the variable name; not type.
no..Collider is a type the function has as a parameter
private void OnTriggerEnter(Collider other)
//Relative to methods:
Accessor return-type method-name(variable-type variable-name)```
I don't get it how you have it correct for the Previous tag check & Destroy but not the function you're trying to use it on
Well, I thought I could use collider just like other
So a paramater is a variable for one of the colliders or things involved in the method
then you want to only run this on the player that has this script ?
The word collider there is just telling you what the variable other is
it's a type eg. a class, enum, struct etc.
just how you declare a variable like public string _myString the word string there is the type
saying that the variable called _myString is a string
are you saying this collection script should only run if its a player ? do other objects have this script
No other objects have the script
which is probably bad
but I need it for the score
Because if I dont have the same script for each I dont know how I would reset the score variable when the monster or enemy gets to the player
yes but only player collects the coins, why does it need to check a Player tag
if this is on the player do another tag check, if its enemy then reset the score or whatever
Im trying to make it check a player tag so when the enemy destroys the coin it doesnt add to thte score
if enemies dont have this script how would they even destroy anything in the first place
Enemies do have this script
why do enemies have a Gold* collection script
I used improper grammar here
I meant "no, other objects have the script"
enemies collect gold also ?
Because I need them to reset the score variable and I don't know how to make it so a different enemy can reset the score without being in the same script with the score variable
No, they destroy it
or, i want them to
so enemy touches gold and destroys it then resets player score?
So the enemy touches gold and destroys it the gold just gets destroyed, if the enemy touches the player then they get destroyed
You can just use a public method for this
make a separate script for enemies that does that
Oh, I didn't know you could reference other variables in other scripts
it will simplify everything instead
I have a lot to learn
That... thats a pretty big part of it yes
I will see if this fixes my problem, thank you.
I think you need to brush up on some c# basics imo
youre lacking some essential knowledge here
I know, I use those turtorials on the unity website for code beginners, and I've just been also doing projects that aren't completely guided by them because it helps me learn a lot that I don't realize through all of the guided turtorials.
try to fully understand every word you type if you're ever doing something you don't understand
before you can learn how to do anything you need to learn the language
and what the words mean
that would be like trying to write a novel without knowing the english language if that makes sense
Yeah, ill do that, thanks for the advice.
must've dont something wrong in your code, as i just tested this. in both orientations and well i got a possible result of negative for each
guess this looks easier to read
Assuming rotation is z axis right
Rotation is whatever axis the function Vector2.SignedAngle outputs (technically it outputs as just a float and not an actual axis so its the axis the user designates it)
But i would think so
Ah, 2d. An image of your data used and result might help to clarify misunderstandings.
Iβm a beginner in game design and canβt get any textures to look pleasing does anyone know if thereβs code I can implement or simply just settings Iβm missing?
This looks like mostly a lighting issue to me π€
I tried messing with scene lighting but it really emphases the wierd looking materials
To me it looks like js another shitty unity game scene and idk what I can change
The textures donβt really show In that ill send another Hol up
It's kinda hard for me to tell with just one screenshot with poor (quality, not your ability) lighting
I think it has charm, but idk if you're going for that
Yea Iβll try that o send some more
(this stuff isn't code related)
Is there a way to use a specific collider when calling OnCollisionEnter?
Shader codeπ€
collision layer matrix, but people tend to filter the results themselves by either checking tag or ideally checking component
Batby is right that this should prolly go in #π₯βpost-processing or #1390346776804069396, but as a final note, this looks like the textures are extremely low resolution. Have you made sure all the settings are correct after importing them?
Like I said Iβm new to straying from actual code to visuals and have no clue on settings or anything of that nature
Youre a beginner and youre making a game inspired by metro exodus?
A beginner to visuals yes code no
would it be better to use a SphereCast over a Trigger Collider if I'm trying to detect for certain objects within a radius of the player?
better is always a weird term but a sphere cast is probably easier/simpler
okay, I'm just trying to consider how fast these things are gonna pile up and how much can the game take before it starts to get sluggish π
also consider an overlap sphere rather than a spherecast if you just need to check a radius, no need to cast the sphere in a direction
helpful, okay. The spherecast was just my first thought because I'm already using that for ground detection and wall detection.
thankkkss:)
Hi, sorry to come back after a long time and I doubt your gonna see this, but I had to do a bunch of stuff and didn't finish fixing that problem, now that I did what you told me to do I put all the script into two different scripts, one for the drill and one for the player. But now it says there's an error, is there a way to tell the computer which public variable I'm looking for, I don't understand how to make the computer find it.
If someone else could help and knows how to fix this it would be much appreciated too.
You're pretty clearly trying to use a variable that doesn't exist
Yeah, this is my fault because I didnt provide enough context, but I have two scripts and I'm trying to access the score variable from another script.
Then you'd need to be accessing it from a reference to an instance of the other script
You should look at code examples and instructions on how to do this
I looked it up and watched a video on it and I think I understand it now.
I wasn't completely sure what my problem was in the first place
thank you.
have issue accessing Camera.main. Have 2 scenes.
- at start loaded with camera (tag: MainCamera)
- script which looks for Camera.main
For some reason script cant find camera
What issue is happening?
If Camera.main is returning null, it means there is no active camera with the MainCamera tag when you called it.
issue is that active camera has Camera.main tag
Sounds like you are mistaken about that
Feel free to show your code, whatever errors you may be receiving, and your scene setup if you want further help
you want me to show code? okay, CameraTransform = Camera.main.Transform
show the camera in inspector too
actually more specifically chuck a Debug.Break(); after the line above (unless you have pause on error enabled)
and then show the camera
The single line of code with no context isn't really very helpful, no
all code is maybe 5 lines and most of it is accesing CameraTransform
Ok so why are you so resistant to share it? I explained above all of the things that I'd need to see if you want me to help you figure this out
You have a multiple scenes game though, so it's highly unlikely there are only 5 lines of code involved
found solution, thanks
That line already was the error my guess π
It's late, so I'm losing my mind a bit.
For some reason, this isn't working when I have the second line of transformations.
It works perfectly without it, but I need it to be clamped between -90 and 90.
The errors wasn't provided but likely so as the transform property should be lowercase
rotation property returns a quaternion; not what you're expecting. You're likely expecting the euler value which can be acquired from the euler angles property.
Another camera was made by accident
But it isn't recommended to work with the interpreted value as it's merely one of the many angles the stored quaternion can be
transform.rotation.z or y or x are never ever something you should be touching
It's recommended to store your own vector 3 variable (the representation of your angle) and to modify/clamp that variable. You'd then apply that to your rotation
so modify a vector3 value and then put that inside Quaternion.Euler()?
Well.. normally folks would have a Vector3 field and apply all arithmetic/changes to that field (variable). Then do what you've suggested.
yeah that
it's like 3am, I'm just doing some finally cleaning up before I crash π
and .Transform did not give you an issue? interesting
okay, I must be dumb because this is eluding me π
what are you trying to do with the secondary rotation set
just clamp the rotate towards so it doesn't rotate on a specific axis?
I'm trying to clamp the rotation on the Y axis between -90 and 90
I tried swapping them out for Vector3, basically just copying the documentation and it still doesn't work
Vector3.RotateTowards works on direction vectors, not euler angles
this is literally copy paste from the documentation, and it's even the use case I'm wanting it for π
that doesn't really matter when you're using it wrong
Using it wrong by doing exactly what the documentation says?
oh yeah why you change to vector3 method
if i say i have an angle of 2, that could be in radians or degrees
if you had one value in radians, and another value in degrees, you would not be able to directly use them together, even though they're both floats
same thing here. you have a Vector3 direction, but that can be represented in eulerangles or as a direction vector.
RotateTowards expects and returns a direction vector, lookVector is a direction vector, but then you treat the result newVector as euler angles
you aren't calling the method incorrectly, you're utilizing the method incorrectly.
it's like you're trying to get the opposite angle of some input angle by adding 180. that doesn't work if the input is in radians
okay, that's a lot of words. I was using Euler instead of LookRotation.
https://docs.unity3d.com/6000.3/Documentation/ScriptReference/Transform-eulerAngles.html
You had the idea with the first but you are using the transform quaternion values
your clamp doesn't work.
I know
problem is I feel like you run into gimbal with what you're doing
the kinds of issues you hit when not understanding units properly, huh
it's returning the difference between the variables, not the raw rotation
yeah this isn't for input is it