#πŸ’»β”ƒcode-beginner

1 messages Β· Page 811 of 1

grand snow
#

Yea you can use that to say init and load data and then its all ready and in memory for use.

solar hill
#

Smart, glad i asked lol

#

cuts down on the 10 singleton gameobjects i already have 😭

grand snow
#

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

finite flower
#

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 😭

grand snow
#

The power of indexes

rough granite
#

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

slender nymph
#

"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

rough granite
#

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

finite flower
#

only 3

#

for now, I might add more, but I doubt it

#

depends on what I need

clever path
#

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

wintry quarry
twin pivot
ashen trail
#

guys I get why the rotation on my character is messed up but idk how to fix it HELP!>

brisk edge
#

what are you trying to do? and is your rigidbody kinematic or dynamic?

ashen trail
#

dynamic i think

brisk edge
#

do you want to rotate your character with force (simulating physics), or just set its rotation?

ashen trail
#

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

finite flower
#

I solve this by rotating an object that represents the player rather than it's actual body

#

but that has it's own problems

ashen trail
#

I guess I'll try that thanks

finite flower
#

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 πŸ˜…

brisk edge
ashen trail
#

thanks

coarse ibex
#

How do i move an object down with an anim? or better how do i run an anim inside C#?

naive pawn
#

referring to the animator system?

#

for the latter you would generally use .SetTrigger or .Play

chrome tide
#

and for the animation itself, you could simply move the object's transform while recording the clip.

coarse ibex
#

how do i disable looping

#

if its ever on

sour cape
#

can anyone remember how u open package manager to get the samples tab?

naive pawn
coarse ibex
#

how do i play a sound through C#

naive pawn
#

look this stuff up, man

chrome tide
coarse ibex
#

now its too quiet

#

lemme look up how to change dat

#

tried 100000 and its still quiet

#

what

chrome tide
#

audiosource volume is a 0-1 float. maybe your clip is just so quiet or you have the 3d blending configured incorrectly.

coarse ibex
#

should i send the audioclip?

chrome tide
#

just judge by yourself if it's loud enough. if it is, then it's the issue with the audiosource config.

coarse ibex
#

if im using 2D, does it work? ( audiosource )

chrome tide
#

yes

coarse ibex
#

ok

worn nymph
#

can the order of the array of material on a meshrenderer be relied on?

coarse ibex
chrome tide
worn nymph
sour fulcrum
#

the inspector will show renderer.sharedMaterials iirc

#

I could be mistaken

worn nymph
sour fulcrum
#

they start off the same

#

depends if your touching them

coarse ibex
short hazel
#

"triggers" as in the sound plays and you can hear it, I guess

chrome tide
chrome tide
#

i don't see anything wrong here either

short hazel
#

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

coarse ibex
rough sluice
#

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

chrome tide
coarse ibex
chrome tide
coarse ibex
#

and i don have one

chrome tide
#

we really have no insight in the technical aspects of the game you're modding so it's hard to help

chrome tide
#

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

coarse ibex
sour fulcrum
coarse ibex
#

i know

sour fulcrum
#

well you don't

#

because you we're asking about modding πŸ˜›

naive pawn
#

one can know and still ask

coarse ibex
#

not modding just help with audio

naive pawn
#

that's called either arrogance or ignorance, generally

sour fulcrum
#

this is one of the reasons (plural) we can't help with modding, because you don't know about the game your developing

naive pawn
coarse ibex
#

anyways nvm

scenic iris
#

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);
        }
    }
}
verbal dome
red rover
#

Is there any documentation about what you can/can't do with references to prefabs in a monobehaviour?

naive pawn
#

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

red rover
#

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.

rough granite
red rover
#

Yeah I'm aware of the docs website πŸ˜… I was looking for any pages about accessing prefabs from runtime but couldn't find any

sour fulcrum
#

those changes would stay yes

rough granite
#

couldn't say much about accessing them but i do know it's possible to make them during runtime

red rover
sour fulcrum
#

not as confident there but i would assume so

#

exiting play mode doesn't touch assets period afaik

red rover
#

I see. tysm for the answers!

hexed terrace
#

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 ?

sour fulcrum
#

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

sour fulcrum
fervent abyss
#
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?

sour fulcrum
fervent abyss
#

its not about the network

timber tide
#

Well, debug what you're getting from player_i, and debug all the dot accessing chain in GetNetworkPlayer

red rover
#

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...

sour fulcrum
#

random two cents but this feels like something you could just handcraft or cache/populate in editor somewhere, no?

red rover
#

Two cents appreciated, and you're probably right.

#

How would you go about that?

timber tide
#

You can use OnValidate to serialize these parts, but otherwise can just do it in awake.

sour fulcrum
#

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

timber tide
#

Do some hiearchy search downwards from the armature

sour fulcrum
timber tide
#

I mean the idea is there in your post, you just need to cache it yeah

red rover
#

Right, and where would I cache it?

timber tide
#

probably not a big issue anyway, can't expect the zombies to have thousands of limbs now

sour fulcrum
#

probably just wherever this swap is actually taking place, which i assume is somewhere enemy code related right

timber tide
#

I'd stick some script on the armature

#

reference it from the enemy controller

sour fulcrum
#

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

red rover
#

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

grand snow
#

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?

sour fulcrum
#

yeah SO over empty in scene

grand snow
#

Then its just 1 reference to a shared asset that then points to many things

red rover
timber tide
#

prefab variants work too

#

I assume you'd have different type of body parts if you have a different zombie variant

red rover
#

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.

red rover
grand snow
#

prefab variants offer no perf benefit, it just helps asset creation

timber tide
#

The benefit is that you can have some root prefabs where you provide default values or fallback onto

grand snow
#

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 😒

timber tide
#

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

red rover
#

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

timber tide
#

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

sour fulcrum
#

this kinda thing has many levels to how well you can cook it up so land on whatever you feel

red rover
#

I'll just need to weight the pros vs the time cost of refactoring for the different options.

grand snow
#

Scriptable objects are custom assets with serialised data. Prefabs are gameobjects with components serialised as an asset.

timber tide
#

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

grand snow
#

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

timber tide
#

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.

sour fulcrum
#

doesn't have to be done in awake

timber tide
#

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

sour fulcrum
#

unless you do

sour fulcrum
timber tide
#

Yeah true, you can do some additional work to serialize it like that

red rover
#

Holy moly my head is going to explode lmao

grand snow
#

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

timber tide
#

But full SO workflow you can basically have a single prefab and just use SOs to construct these objects

#

good object pooling solution

grand snow
#

Oh i like that

#

Spawn base prefab, pass reference to some EnemyConfig scriptable object instance to set up

red rover
#

Wait what would SO's have to do with being setup at runtime?

#

If I'm understanding right

grand snow
#

Scriptable objects are assets with data so something can be initialized with that as its data source

sour fulcrum
#
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)

red rover
#

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 πŸ˜…

red rover
#

Just doesn't allow the assignment in the inspector, like it doesn't turn blue on hover

grand snow
#

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

red rover
#

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?

sour fulcrum
#

this might just be a drag and drop issue

spare mountain
sour fulcrum
#
[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();
    }
}
grand snow
sour fulcrum
grand snow
#

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

grand snow
# red rover

This would never work anyway as a prefab stage (when we open a prefab to edit) is not the same as the prefab asset

red rover
#

I see

sour fulcrum
#
  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

red rover
#

Perhaps we should go with the empty in scene approach?

sour fulcrum
#

yeah lines up with the fileid's in the prefab

#

i think my thing works ngl

grand snow
#

Hmm interesting id have to try this out myself but I think this is not something a beginner should try

grand snow
spare mountain
red rover
#

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?

grand snow
spare mountain
grand snow
#

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

spare mountain
#

fair, but what in coding isn't a poor solution to an otherwise trivial problem?

red rover
#

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.

sour fulcrum
#

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

grand snow
#

name to name mapping isnt bad but if you keep doing find by names at runtime it may get a little slow

spare mountain
grand snow
#

And yea to do that it would need to be done in code manually as a static dictionary

spare mountain
#

you could do a god damn linear search with no performance hit if it's just once

sour fulcrum
#

or using ayellowpaper's serialized dictionary shoutout that guy

grand snow
spare mountain
red rover
sour fulcrum
red rover
#

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.

rough sluice
#

I unable to know why unity is showing CS0246 error on newly created URP projects:

solar hill
#

That doesnt exactly look newly created... does this happen before you add any scenes or assets?

rough sluice
wintry quarry
ashen trail
#

how do I fix my rotation? it only works acording to world position

grand snow
#

Sorry im dumb. You would transform the direction, rotate the rotation with another (Quat * Quat) or use a matrix to transform the rotation

ashen trail
#

okay

grand snow
# ashen trail 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

ashen trail
#

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

grand snow
ashen trail
#

yah

grand snow
#

then i dont understand what you mean by "turn right"

ashen trail
#

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

grand snow
#

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)

ashen trail
#

k I think ima just do it so my mouse movement controls the rotation

grand snow
#

Ah yea 3d third person controls are a tad different. Do you want movement to be relative to the camera?

ashen trail
#

yah

grand snow
#

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)

ashen trail
#

okay I'm going to try to fix the turning

grand snow
#

If you want what i described above i can try to help with this

errant breach
#

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 πŸ™

naive pawn
#

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

errant breach
#

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..

slender nymph
#

a solution to an editor bug would be to update to a version of the editor where that bug has been patched

errant breach
#

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 πŸ˜…

naive pawn
#

patch versions are generally mostly bugfixes

#

and if you have vcs (you should) then you can always safely revert

finite flower
#

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?

naive pawn
finite flower
#

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 🀦

naive pawn
#

don't assume stuff would be more complicated than it is

#

you're just creating fake problems for yourself to stress over lol

finite flower
#

I will never forget the 4 hours wasted just to realize it was 4 lines that could just be removed 🀦

grand snow
finite flower
#

I know how, but for some reason I keep thinking it's more complicated

grand snow
#

thankfully not!

ashen trail
naive pawn
#

use mp4 instead of mkv so it embeds in discord

ashen trail
#

ok give me a sec

#

i sent it

naive pawn
#

are you projecting your movement onto the xz plane/normal plane?

ashen trail
#

yah

naive pawn
#

might just be that the terrain isn't flat then

#

perhpas show code

ashen trail
#

ok

naive pawn
#

!code

radiant voidBOT
ashen trail
#

those are both of my scripts

#

well not the jump script but those are the movement ones

naive pawn
#

share it properly please

#

but i can immediately see 2 issues

naive pawn
# naive pawn are you projecting your movement onto the xz plane/normal plane?
  • 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
ashen trail
#

okay ill use the rigidbody to move and try to not tilt the player just the cam

mild lake
#

Does anyone know of any good resources on making a tik-tak-toe win checking algo?

astral flame
#

What is a tic-tac-toe game?

mild lake
#

tic tac toe* i missspelled it

mild lake
naive pawn
#

there's not much to it

astral flame
mild lake
#

The not much to it is the thing i'm struggling with

naive pawn
#

well you clearly know what to do

mild lake
#

The board expands so i can't reference a static pattern

naive pawn
#

which detail of the how are you stuck on

mild lake
#

It has to be dynamic based on the starting grid tile

naive pawn
#

ah. there it is

astral flame
#

In my case, I'm making a GMod game.

naive pawn
mild lake
#

My goal is to have a method with a specified length that will check in horizontal and vertical angles

naive pawn
#

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

mild lake
#

I understand the theory, it's the execution i'm having trouble with

naive pawn
#

what part of it exactly

mild lake
#

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

naive pawn
#

you could also check for opposite sides of the tile that was just placed

grand snow
#

I was thinking this, it should be possible to check around the last modified tile

feral wyvern
#

hey i need to ask and learn something

solar hill
#

ask away

mental terrace
#

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

slender nymph
#

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

feral wyvern
#

well.. I wanted to learn

#

to program

solar hill
#

UnityChanThink Was i pinged

mental terrace
feral wyvern
slender nymph
mental terrace
frosty pecan
#

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

silk night
#

otherwise you might find more success with netcode for gameobjects

frosty pecan
#

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

silk night
#

Then you would know that anything not baked in the subscene will not transfer over to gameplay

frosty pecan
#

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

silk night
#

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)

frosty pecan
#

I should've said, Ive already checked the entity heirarchy

#

that's how I confirmed that this was my issue

silk night
#

why is the entities subscene there twice?

frosty pecan
#

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

frosty pecan
#

let me try removing that

#

every tutorial I followed told me to

silk night
#

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 πŸ˜„

frosty pecan
#

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)

silk night
#

whats the "all=" infront?

frosty pecan
silk night
#

can you just look for prefabs without the all if that brings up anything?

frosty pecan
silk night
#

also should be any= from my understanding

#

because not all your components contain "prefabs"

silk night
#

there will be people in either that know about the specifics of both better

frosty pecan
#

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

silk night
#

huh? networking is about 1 post each day

frosty pecan
#

maybe discord is just lying to me then-

silk night
#

your sorting maybe

frosty pecan
#

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

silk night
#

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

frosty pecan
#

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

silk night
#

yeah people mostly use the general discussion chat in there

#

but its still 1+ post a day πŸ˜„

frosty pecan
#

got it

#

Ill try my luck in there then

#

thanks man

wet heath
#

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

silk night
wet heath
#

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

silk night
#

I mean we can't really help with code you copied from some tutorial when we dont know the code πŸ˜„

wet heath
#

Yeah I didn't wanna fill up the chat with shit unless prompted so hang on

solar hill
#

!code

radiant voidBOT
wet heath
#
using UnityEngine;
using System;

public interface IDamageable
{

    public void TakeDamage(float damage);

}```
silk night
#

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

wet heath
#
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.");
            }
        }
    }
}```
silk night
#

that is not even valid code 🀨

wet heath
wet heath
silk night
radiant voidBOT
silk night
#

then you will see whats wrong

wet heath
#

Wait what's wrong with it

silk night
silk night
#

i take it back, its actually valid and runs but there should be atleast a warning displayed πŸ˜„

wet heath
#

Oh

#

Wait, a warning for what where?

#

Man why you gotta make me think I'm going crazier than I already am, lul

silk night
#

Because you will not get help here unless you have your ide configured and can spot basic errors through that πŸ˜„

wet heath
#

I have visual studios

silk night
#

i might have been too early with this, my own ide doesnt warn me πŸ˜„

teal viper
#

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. πŸ€”

silk night
#

otherwise it does absolutely nothing

teal viper
#

Aah, I see.

wet heath
#

Debug logs are there just to find a clue

teal viper
#

Well, technically it's still valid code.

#

From the compiler perspective

silk night
#

I thought it would give a warning cause it doesnt use a return value

#

turns out my own ide doesnt even mark this

teal viper
#

It probably should, you're right.

#

It's weird that it doesn't though.

silk night
#

it does if you mark comparetag as pure

#

ide thinks it has sideeffects

#

and shuts up

wet heath
#

All-in-all, this worked perfectly in a 2021 version I had, and using this in 6.3 has it not working

teal viper
#

Well, at the very least your debug log doesn't help debug the issue, but makes it more confusing.

silk night
#

depending on the way you updated it might have broken your layers

wet heath
silk night
silk night
#

i just runs without using the output

wet heath
#

I know, but that shouldn't matter for the overall problem

silk night
#

true, but will still confuse you with wrong log outputs

#

as i said, just follow the tutorial again and it should fix itself

wet heath
#

I wasn't confused by the debug logs

silk night
#

i didnt say that, i said they could/"will" confuse you down the line cause you are getting wrong logs

wet heath
#

Just need to figure out the main problem

teal viper
#

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.

wet heath
#

It doesn't matter. I've already verified that the IDamageable script simply isn't working in the newer version

teal viper
#

Because if that's all you have, of course it wouldn't work.

wet heath
teal viper
#

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.

wet heath
#

I have done so

solar hill
#

Can you show us how

wet heath
#

I'll investigate this further in my own time. I'm fairly certain it's the newer version

solar hill
#

Well im on the newest version and my IDamageable interface works fine lol

teal viper
#

Unity updates breaking user code sounds like a creepypasta.

solar hill
slate nebula
#

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

solar hill
#

Can you show us the code?

radiant voidBOT
finite flower
#

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?

solar hill
#

What are your pc specs?

finite flower
#

really good πŸ˜…

#

lemme get specifics

#

but I got it to run hefty games, and it doesn't struggle too bad

finite flower
#

old now, but I've never had a problem

solar hill
#

Your task manager show anything when running the unity editor?

finite flower
#

yeah, unity is eating most of my memory

broken pivot
#

Hello

#

I'm new here and

#

I need a tool that can debug C# games

finite flower
wintry quarry
solar hill
slate nebula
solar hill
#

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?

slate nebula
#

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

solar hill
#

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

radiant voidBOT
slate nebula
#

so do i set the reference in the player class and the use that reference in the manager

solar hill
#

No you get a reference to the Player inside of the game manager

slate nebula
#

i have a reference to the player inside the game manager on lines 7 and 8

sour fulcrum
#

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

solar hill
#

They did assign it a value, the player script on the gamemanager object....

teal viper
#

Decompilation isn't an allowed topic here.

broken pivot
#

Why?

teal viper
#

Well, technically, it's illegal. Or I guess against tos. So of course unity wouldn't allow such a topic on the official server.

solar hill
#

The rules explain it pretty well, read them next time

finite flower
#

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.

frosty hound
#

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.

ornate cosmos
#

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)

finite flower
#

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.

ornate cosmos
#

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

ornate cosmos
jagged ravine
#

im trying to make an airsoft game for vr, if anyone can help pls dm me.

sinful zinc
#

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

rough granite
radiant voidBOT
# rough granite !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**

pulsar marsh
#

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 ???

eternal needle
ornate cosmos
# sinful zinc how can i fix an object spiralling when being rotated. i understand its because ...

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

shrewd dock
silk night
sinful zinc
naive pawn
#

rotations come from the pivot, so if the thing isn't "centered" on the pivot, it's going to move

naive pawn
#

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

sinful zinc
#

it i

#

is

naive pawn
#

you said it wasn't, previously

sinful zinc
#

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

naive pawn
#

yeah the child isn't at 0,0,0...

sinful zinc
#

so the only way to center the pivot is for the child to be at 0,0,0 too? is there no other wa

ornate cosmos
#

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

broken pivot
#

AAA

#

Learn how to coding is hard or not?

#

I have 0% knowledge of coding and i wanna learn on my mobile catto

sour fulcrum
#

Hard

broken pivot
chrome tide
#

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

broken pivot
#

And it's seems i need to learn something before start learning coding

ornate cosmos
#

no need talent

rich adder
#

you learn a skill like anything else

ornate cosmos
#

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

rich adder
#

programming concepts
what does that even mean really

ornate cosmos
#

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#

ornate cosmos
#

LOL

rich adder
#

absolutely no reason to get into C, just to learn C#

ornate cosmos
#

i mean dont learn C

#

translation just missunderstand my meaning at the begining

chrome tide
#
  • have basic understanding
  • "not learn"
    ?
ornate cosmos
#

okay

#

If you don't know the difference, just pretend I didn't say it and learn C#

rich adder
#

You need nothing from C in C# they are different languages

ornate cosmos
#

okay

tender mirage
#

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.

ornate cosmos
#

then skip it

#

Let's not pick words anymore, just remember the last sentence I said, my friend. Learn -->> C#

#

πŸ™‚

rich adder
#

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

ornate cosmos
naive pawn
#

gonna get out ol' reliable...

ornate cosmos
#

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

rich adder
#

facts, Logic is probably the main thing you need. That applies across anything besides programming tbh

#

problem solving and all

naive pawn
cunning bramble
#

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?

ornate cosmos
# naive pawn

yep, thats wut i mean before, but if think they are diff, its fine, then skip it, go to lean C#

naive pawn
#

if your goal is to learn c#, why would you learn c just for that purpose

ornate cosmos
#

i didnt say that, well, skip it

naive pawn
#

learning c can be useful. but there are more effective ways to learn

rich adder
ornate cosmos
#

u missunderstand wut i tried to say

naive pawn
#

i mean, you did say this

I suggest that you have a basic understanding of C

ornate cosmos
#

and if u didnt get it, its fine, just skip it

hexed terrace
#

it's still wrong, but it doesn't mean that

ornate cosmos
#

well, i said "learn C#"

naive pawn
broken pivot
#

What about w3school website.. is it good for learning?

sour fulcrum
#

sure

naive pawn
rich adder
naive pawn
#

like the ones in the pinned message, as you've been directed to

rich adder
#

check pins πŸ“Œ

sour fulcrum
#

but also it really is like a whole new language. it's going to be tough no matter what

cunning bramble
rich adder
#

this is a mistake

cunning bramble
rich adder
#

you're essentially copying someone elses system

#

when you build it up yourself you will know exactly how it works

hexed terrace
#

that can be a good way to learn for some people..

ornate cosmos
#

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

rich adder
#

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

cunning bramble
ornate cosmos
#

And as we all know, languages like Java, C++, and C # all contain concepts of variables, objects, classes, and polymorphism

naive pawn
#

i mean following a tutorial just to get your bearings isn't bad tbh.

#

following a tutorial blindly as gospel, that would be bad

ornate cosmos
#

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

rich adder
#

we splitting atoms lol all i said it check multiple sources of how they do it and build it up yourself

ornate cosmos
#

The most basic functions or concepts of C language include variables, functions, pointers, and header files

rich adder
#

this way you know how to "connect everything" cause you built it

hexed terrace
#

@maxy I think you can stop now bud

ornate cosmos
#

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

naive pawn
#

@ornate cosmos what are you trying to prove here man

rich adder
#

you can but you don't have to..

naive pawn
#

you do not need to learn C variables and functions. they work differently from C# variables and functions.

ornate cosmos
#

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

chrome tide
#

stop the c rant

naive pawn
ornate cosmos
#

If you still don't understand what I mean, then as I have mentioned many times before: Skip it

naive pawn
#

we're trying to stop you from giving bad advice here tbh

rich adder
#

bro I was working in a kitchen pre-2018 .. I did not learn C before learning c# to use unity..

ornate cosmos
#

nice

#

then skip it

fickle plume
#

@ornate cosmos Stop with chatGPT dump already

rich adder
#

so stop suggesting it lol

ornate cosmos
#

i already said it, u didnt listen it

rich adder
#

yeah this sounds like a bot dump

ornate cosmos
naive pawn
#

we're listening and we think you're wrong

ornate cosmos
#

if u say so πŸ™‚

fickle plume
#

Riiight

#

Next time I will start muting

ornate cosmos
#

just fell into the self verification trap again, skip wut i said

rich adder
#

brother, just stop.

naive pawn
#

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.

ornate cosmos
# rich adder but c# you dont have to deal with pointers..

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

ornate cosmos
naive pawn
#

no-one was in doubt

rich adder
chrome tide
ornate cosmos
naive pawn
#

except that it's unnecessary and misleading...

ornate cosmos
#

someone just always missunderstand my meaning

chrome tide
naive pawn
#

no-one has misunderstood

ornate cosmos
#

thats annoying

naive pawn
#

the irony

ornate cosmos
hexed terrace
#

Maybe if everyone stopped replying to Maxy on this topic, it could stop.

naive pawn
#

lmfao at the fact they also blocked me, so apparently they're just not interested in good teaching practices lmao

ornate cosmos
#

this kind of situations often experiences such incidents LOL

fickle plume
#

!warn 1203931102432206868 Enough with the off-topic. Stop spamming the channel.

radiant voidBOT
stone oar
#

hey, where can i ask a question about shader graph?

stone oar
#

thank you

versed harness
#

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?

naive pawn
tender mirage
#

Curious, are IEnumerables a type of interface?

naive pawn
broken pivot
#

Ok i watched the tutorial on pins

#

And got new things UnityChanAssetStore

#

Frustration notlikethis atwhatcost

#

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?

fickle plume
#

Start with Junior Programmer Pathway, or Essentials even if you new to the engine. It mixes practical work with examples.

broken pivot
#

I'm new at the entire programing notlikethis

#

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 atwhatcost ?

midnight tree
#

I'm having withdrawal symptoms because I can't post a gif on it...

rich adder
fickle plume
rich adder
broken pivot
#

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

rich adder
#

most of the math you need to know is basic elementary school stuff

#

the computer & language is doing the heavy lifting for you

fickle plume
hexed terrace
broken pivot
rich adder
#

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

hexed terrace
#

Just making sure, because.. ye know..

rich adder
#

ya get a used laptop or build something later if you wanna run unity

midnight tree
fickle plume
broken pivot
#

Yeah i saw multiple YouTube videos

#

Most of them agree on one thing

#

Python is beginner friendly

naive pawn
#

the hardest part of learning to code is the Logic, problem-solving aspect. choosing a more "beginner friendly" language doesn't change that

rough granite
#

Dare i say fuck python, ugly language

heavy mortar
#

yeah python is one of the ugliest

#

thats why i love C#

ornate cosmos
#

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

rich adder
#

this dude posts canned AI responses

frail hawk
#

or maybe he is an ai bot

#

we will never know

grand snow
#

"translations" yea smells like ai

solar hill
#

you can litterally ctrl-f their previous messages and see the striking difference in how its written lol

rich adder
# solar hill

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

solar hill
#

methods and functions

#

lol

grand snow
#

C# does call them methods but function is a valid name too

rich adder
ornate cosmos
# solar hill

if non-native speakers are not allowed to use the translator

solar hill
#

Except its obviously not just translated but ai rewritten or written entirely by ai

rich adder
#

brother you type different than how you posting canned responses

ornate cosmos
#

and these are simple things

solar hill
#

im sure they are, is that why you used AI to write them out

rich adder
#

punctuation for one

ornate cosmos
#

okay

hexed terrace
#

can we not ..

ornate cosmos
#

i understand why u say that now

solar hill
#

Im sure you understand a lot

ornate cosmos
versed fjord
#

The internet is full of generated ai content. You cannot trust it anymore that its humanly written

queen adder
#

oh nvm

#

i hadn't realized

ornate cosmos
#

crazy

ornate cosmos
solar hill
fickle plume
#

!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.

radiant voidBOT
ornate cosmos
#

classic white discrimination

#

its not my fault u guys ignorant

solar hill
fickle plume
#

@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.

sharp kindle
#

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

naive pawn
#

!ide

radiant voidBOT
sharp kindle
main lantern
#

3ede

sharp kindle
naive pawn
viral prism
#

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

solar hill
#

we would actually need to see your code

#

to help you

radiant voidBOT
slender nymph
#

also "my jumpy jump is cooked" is not a good description of whatever it is you're trying to show in the video

viral prism
#

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

slender nymph
#

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

viral prism
#

Oh how do I use the physics debugger!

#

True

#

☹️ da line wrong

#

😞 why da line wrong

#

Let me see something

slender nymph
viral prism
#

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)

solar hill
viral prism
#

Would I have too increase the mass in order to fix that or is there a different way for me to go about it?

verbal dome
#

No, you'd either make your objects smaller or make the Physics.gravity greater

#

Drag/damping can also affect this

slender nymph
viral prism
#

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

viral prism
viral prism
#

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!

stoic sage
#

Can anyone explain to me how to make a script interact with another script

#

Tutorials explain it too overcomplicated

frail hawk
#

you can access the public fields and methods by simply creating a reference

stoic sage
wintry quarry
solar hill
frail hawk
#

use the SerializeField class for example

solar hill
#

you show one script the other exists

wintry quarry
# stoic sage But like What does it mean to create a reference

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.

solar hill
#

i think you said it better

stoic sage
#

So i just type the same variable the public script has?

#

It wont take it as its own variable hopefully?

solar hill
#

no

slender nymph
grand snow
#

^ go read that πŸ“–

#

but its clear day 1 topics of programming were skipped

stoic sage
#

Man i have alot of terms to learn atwhatcost

grand snow
#

If its still confusing then id recommend learning some basic c# outside of unity

hexed terrace
naive pawn
#

-# i mean, it is also a class, used as an attribute, no?

stoic sage
#

I thought serializefield is just a way to change private variables in the editor instead of in the script the entire time

grand snow
#

The attribute tells unity that a private field should be serialized (public ones are by default)

slender nymph
#

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

grand snow
#

*other ways are available β„’ *

stoic sage
#

Oh do i just basically call out the name of the script and name it like a variable atwhatcost

#

(Scriptname) (variablename);

grand snow
#

go learn properly

stoic sage
#

Thats atleast what i understood

naive pawn
#

it's the Type and then the name, sure

#

but yes go learn properly.

grand snow
#
int a = 5;
int b = 7;
int c = a + b;
#
string foo = "BAR";
Debug.Log(foo.ToLower());
rich adder
#

public class MyCoolScript <--- MyCoolScript is now a Type, the Type class

rough granite
#

Had to learn it myself through just understanding

grand snow
#

You can certainly learn that all in Main() but when you go to learn OO you do need to make some classes

rough granite
grand snow
#

Yea you need to make a class to learn you can then use fields and functions on a class/struct instance

boreal ingot
#

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

rough granite
boreal ingot
#

like a circle and make the cylinder follow it?

rough granite
#

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

boreal ingot
#

i didn t know i can do that wow you just saved me a lot of time i had my trigonometry book ready !

rough granite
rough granite
south depot
#

I wanted to ask if there are any people who can help me, have a problem with c# script create..

radiant voidBOT
# naive pawn !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

slender nymph
#

!ask

radiant voidBOT
# slender nymph !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

slender nymph
#

Oop slightly too slow lol

rich adder
#

double kill was about to be a triple

solar hill
#

bots still dont have a cooldown huh

naive pawn
south depot
# naive pawn !ask

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.

naive pawn
#

the options for mac are vscode and rider

#

vs for mac was killed off quite a while ago

midnight tree
#

As a macbook user I recommend VScode

rocky wyvern
#

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?

wild cove
#

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.

rich adder
#

you should probably brush up a bit on basic c#

wild cove
#

wait, so the collider is type of function?

#

I'm a little confused, im very new to coding

ivory bobcat
rich adder
ivory bobcat
#
private void OnTriggerEnter(Collider other)
//Relative to methods:
Accessor return-type method-name(variable-type variable-name)```
rich adder
#

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

wild cove
#

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

rich adder
rocky wyvern
#

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

wild cove
#

Ohhhh

#

I get it now

rich adder
#

are you saying this collection script should only run if its a player ? do other objects have this script

wild cove
#

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

rich adder
#

yes but only player collects the coins, why does it need to check a Player tag

rich adder
wild cove
#

Im trying to make it check a player tag so when the enemy destroys the coin it doesnt add to thte score

rich adder
wild cove
#

Enemies do have this script

rich adder
#

why do enemies have a Gold* collection script

wild cove
#

I meant "no, other objects have the script"

rich adder
#

enemies collect gold also ?

wild cove
#

No, they destroy it

#

or, i want them to

rich adder
wild cove
#

So the enemy touches gold and destroys it the gold just gets destroyed, if the enemy touches the player then they get destroyed

solar hill
rich adder
wild cove
#

Oh, I didn't know you could reference other variables in other scripts

rich adder
#

it will simplify everything instead

wild cove
#

I have a lot to learn

solar hill
wild cove
#

I will see if this fixes my problem, thank you.

solar hill
#

I think you need to brush up on some c# basics imo

#

youre lacking some essential knowledge here

wild cove
#

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.

rocky wyvern
#

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

wild cove
#

Yeah, ill do that, thanks for the advice.

eager stratus
rough granite
# eager stratus

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

timber tide
#

Assuming rotation is z axis right

rough granite
#

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

ivory bobcat
#

Ah, 2d. An image of your data used and result might help to clarify misunderstandings.

somber escarp
#

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?

finite flower
somber escarp
#

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

finite flower
#

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

somber escarp
#

Yea I’ll try that o send some more

sour fulcrum
#

(this stuff isn't code related)

finite flower
#

Is there a way to use a specific collider when calling OnCollisionEnter?

somber escarp
sour fulcrum
finite flower
somber escarp
#

Like I said I’m new to straying from actual code to visuals and have no clue on settings or anything of that nature

solar hill
#

Youre a beginner and youre making a game inspired by metro exodus?

somber escarp
finite flower
#

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?

sour fulcrum
#

better is always a weird term but a sphere cast is probably easier/simpler

finite flower
#

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 πŸ˜…

slender nymph
#

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

finite flower
#

helpful, okay. The spherecast was just my first thought because I'm already using that for ground detection and wall detection.

south depot
wild cove
# solar hill You can just use a public method for this

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.

wintry quarry
wild cove
#

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.

wintry quarry
#

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

wild cove
#

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.

elfin pike
#

have issue accessing Camera.main. Have 2 scenes.

  1. at start loaded with camera (tag: MainCamera)
  2. script which looks for Camera.main
    For some reason script cant find camera
wintry quarry
elfin pike
wintry quarry
#

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

elfin pike
sour fulcrum
#

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

wintry quarry
elfin pike
wintry quarry
#

You have a multiple scenes game though, so it's highly unlikely there are only 5 lines of code involved

elfin pike
#

found solution, thanks

midnight plover
finite flower
#

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.

ivory bobcat
#

The errors wasn't provided but likely so as the transform property should be lowercase

ivory bobcat
elfin pike
ivory bobcat
#

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

wintry quarry
ivory bobcat
#

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

finite flower
#

so modify a vector3 value and then put that inside Quaternion.Euler()?

ivory bobcat
#

Well.. normally folks would have a Vector3 field and apply all arithmetic/changes to that field (variable). Then do what you've suggested.

finite flower
#

yeah that

#

it's like 3am, I'm just doing some finally cleaning up before I crash πŸ˜…

midnight plover
finite flower
#

okay, I must be dumb because this is eluding me 😭

timber tide
#

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?

finite flower
#

I tried swapping them out for Vector3, basically just copying the documentation and it still doesn't work

naive pawn
#

Vector3.RotateTowards works on direction vectors, not euler angles

timber tide
#

I would just rotate using Quaternion.AngleAxis

#

using some slerp

finite flower
naive pawn
#

that doesn't really matter when you're using it wrong

finite flower
#

Using it wrong by doing exactly what the documentation says?

timber tide
#

oh yeah why you change to vector3 method

naive pawn
# finite flower Using it wrong by doing exactly what the documentation says?

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

finite flower
#

okay, that's a lot of words. I was using Euler instead of LookRotation.

timber tide
naive pawn
#

your clamp doesn't work.

finite flower
#

I know

timber tide
#

problem is I feel like you run into gimbal with what you're doing

naive pawn
#

the kinds of issues you hit when not understanding units properly, huh

finite flower
#

it's returning the difference between the variables, not the raw rotation

naive pawn
#

yeah this isn't for input is it