#πŸ’»β”ƒcode-beginner

1 messages Β· Page 742 of 1

spice ivy
#

ohhh alright I'll look up about this timer stuff thanks

#

well i never thought about that

teal viper
#

Yes. You usually want ui decoupled from the game logic. The ui can just set some kind of index that some manager would read and use it to spawn the right character later.

spice ivy
#

ohh yeah i understand a stage system seed > sprout > littleplant > Fully grown I'll see which one looks better

signal vine
chilly vigil
chilly vigil
# chilly vigil

i don't konw what string is off becuse llline 23 seems right to me. it is from tutoirall i followed

cosmic dagger
#

If not, then it is empty. You don't assign a default name in the script . . .

chilly vigil
cosmic dagger
#

Did you read my previous message and check the variable?

slender nymph
ivory bobcat
chilly vigil
ivory bobcat
frigid sequoia
#

If I am using this system to hold the data of the damage dealt, if I clear the damageLog, do the recountEntries, that no longer have any reference to them, keep occupying space in memory or it's fine?

burnt vapor
#

So yes, clearing the list would eventually have the GC collect it when it runs

frigid sequoia
#

I guess it's not worth for me to even try to do it manually right?

burnt vapor
#

One thing you could do is improve how memory is managed. Things like class pooling or using structs can help since references are less abundant and you reuse them for different purposes, but this is also specific to what you need and might not fit your use case (i.e. I believe you can't serialize a struct like you have there, and it can't be shown in the Unity editor (probably could with a lot of extra steps though))

#

The best thing is to have the GC run as little as possible. Every run slows down your application.

#

But know this is mandatory. Realistically you can't work without the GC ever running

red rover
#

When assigning a listener to this button, I am using the iterator variable

void Start()
  for (int i = 0; i < buildOptions.Length; i++)
  {
    print(i);
    newBuildTile.GetComponent<Button>().onClick.AddListener(() => StartBuilding(i));```
But when I print it later it always gives me the max index of the loop for some reason, as if it's overriding all the events for the previous loop iterations??
```cs
public void StartBuilding(int option)
{
  print(option); // Always gives me buildOptions.Length```
red rover
#

Ohhh I see, so it's basically just keeping a reference to the iterator, and calling upon it's final value when printing it.

#

Thank you very much!

hexed terrace
bitter pine
#

for some reason when i execute this, the rotation of said door goes to (-90, 0, -90)

vital otter
plush zealot
#

After dashing twice I get this error message that interrupts the game test (im assuming this would be the game crashing in a finished build)
in this script at line 431 I have a function that should make the momentum carried after a dash slow down smoothly to feel nice. This works flawlessly on my Laptop but not on my home pc for some reason.... the laptop runs on Ubuntu and the PC on Windows 10 not sure if that's relevant

#

this is the formula I use to slow down the momentum after the dash

candid coral
#

So i need some assitance with this because i just cannot find a consistent answer because of the fact that unity changed its input system and people are either using the old one or they have made their own

#

this is the movement script ive written

#

and these are the sprites, I just want it so that when the direction keys are pressed the currently show sprite is swapped to the one of the direction the player has pressed

#

where you see sprite render.sprite = upsprite thats an attempt i made to get the sprite renderer to change sprite so ignore that

plush zealot
#

you can just change the x scale *-1

#

so just put a - before it and it will flip it around for left and right

#

for the new input system I can recommend "game code library" 's tutorials on youtube they helped me understand it too

candid coral
#

my sprites arent asymetrical. so something on the right hand side of the player sprite wont be on the left so i cant just invert the sprites

#

so the cat sprite facing the camera is the walking downwards and the one facing away is walking upwards. its a top down isometric

plush zealot
#

fair enough

#

well I can show you a method of handling input if you want using the player input component

#

the sprites you can do in different ways

#

either with an animator or if you really just wanna change the sprites you can load them out of the resource folder

candid coral
#

the resource folder one is what im looking for. the game doesnt have any actual animations. its just static images facing cardinal direction

#

could you point me in the right direction so i can figure this out please

plush zealot
#

you can do this:
image.sprite = Resources.Load<Sprite>("CatSprites/CatfacingLeftSprite")

#

the path starts in your Resource folder meaning anything you wanna load this way you want to put in the resource folder

#

hope that helped

eager elm
#

loading a sprite every frame is probably not ideal. You can just reference the 4 sprites and assign them in the inspector:

public Sprite upSprite;
public Sprite downSprite;
etc...

The assigning you did with spriteRenderer.sprite = upSprite; should work fine, you just have to add the other 3.

shell sorrel
#

the input handling is kind of flawed as well since more then 1 key can be pressed at a time

candid coral
#

i did the old input method of input.getaxisraw and all that but i believe im using the new system. but apparently not

eager elm
#

well, you want errors if you are missing a sprite, no? Better than wondering why it doesn't work.

shell sorrel
versed stump
eager elm
shell sorrel
runic hedge
#

Hello fellow humans, I need to learn a bit of C# to work in Unity, I need for college, do you recommand looking for an tutorial that can teach me C# or are there any good tutorials that teach you specifically for Unity?

shell sorrel
#

can have the input system normalize it for you or just do it in code after

rocky canyon
radiant voidBOT
grand snow
#

BUT will not teach you c# because thats its own thing as a programming language

runic hedge
#

Oh alright, thanks! I will start learning from there!

plush zealot
runic hedge
#

I don't know literally anything about coding πŸ’€

grand snow
#

Yea then you wont understand anything!!!

#

please dont

runic hedge
#

At the end of the block they will interview me how I made it, so I can't pass it xP

grand snow
#

I already know my stuff so im good

runic hedge
#

Even if I use ai I need to understand what the ai is doing

grand snow
#

Yea then you try to make it do something with some obscure lib and it just makes up non working code

#

yea i do πŸ˜†

shell sorrel
#

AI rubbish can only do the easy parts, and then just leaves you without the proper background to handle real issues

grand snow
#

I guess you can go talk to claude then instead of us

fickle plume
#

@wooden cypress This is a learning community, don't send people to LLMs. If you are just here to troll you are welcome to leave.

queen adder
#

Does anyone know how i can call CloudCode from a Server sided Entity System?

#

All the functions seem to be async and public void OnUpdate(ref SystemState state) I cant make this async cause of ref

bitter pine
#

how do i fix raycasts going through walls? below is my raycast hit script (all thats needed)

#
if(Physics.Raycast(ray, out hit, interactionDistance, interactionMask))
{
    InteractionText.text = "Press '" +InteractionKey.ToString() + "' to interact.";
    if (Input.GetKeyDown(InteractionKey))
    {
        RcHitOBJ = hit.transform.gameObject;

        if(RcHitOBJ.gameObject.CompareTag("Door"))
        {
            DoorMain doorScript;
            doorScript = RcHitOBJ.GetComponent<DoorMain>();

            doorScript.OpenCloseDoor();
        }

        if (RcHitOBJ.gameObject.CompareTag("Holdable"))
        {
            DropHeldItem();
            
            HeldItem = RcHitOBJ.name;
            
            RcHitOBJ.gameObject.GetComponent<Rigidbody>().isKinematic = true;
            RcHitOBJ.GetComponent<BoxCollider>().enabled = false;
            RcHitOBJ.transform.parent = objectHoldStorageLocation;
            RcHitOBJ.transform.localPosition = Vector3.zero;
            RcHitOBJ.transform.localRotation = Quaternion.Euler(0, 90, 0);
        }
    }
}```
rocky canyon
#

well right now ur using a mask to only hit those in that mask

#

so if ur walls aren't included it shouldnt be hitting them anyway

#

thats the reason.. its going thru the walls.. as well

bitter pine
#

what i mean is if im behind a wall and i have a door on the other side, it will allow me to open the door

rocky canyon
#

yea.. b/c its only hitting the layermask which i guess the doors included..

#

its going to ignore walls (if they're not included in the mask)

bitter pine
#

how would i remedy that

shell sorrel
rocky canyon
#

you would ^ include w/e u want in the mask
and then check each object and see if its a wall (ignore)
or something with the doorscript (open)

#

a TryGet works well here

bitter pine
#

TryGet?

rocky canyon
#

its like a GetComponent.. but better (it'll only run the code block if it can get that component)

queen adder
#

Damn its so backwards, to call async functions via an authoratitve server i'd have to make a mono behaviour and do the async call there, then my server sided system would have to just poll that monobehaviour through a singleton :S

#

Spaghetti

twin oriole
#

Hello, I found one error when I update to the 6.2 version today.
I tried to edit an array within another array in a scriptableObject file in the Unity interface. It all bugged, and the console displayed an error. The console error and the ScriptableObject code are in the link below because they are large: https://paste.mod.gg/zycabokifqer/0

bitter pine
#

alright, i think i got it. how do i check if something is a certain layer?

#

would i do if(hit.transform.gameObject.layer == interactionMask)

rocky canyon
#

not exactly.. a layerMask is not the same as a layer

bitter pine
#

bc this wont work for me, i have multiple things using this interaction raycast. its not just for doors its a general interaction raycast

grand snow
#

Thats true, a layer mask is meant to signify potentially multiple layers

#

yes it can either be an int for its index or an int where a single bit is the layer.

bitter pine
#

so how am i checking if its in a layer?

#

yes, i did that it didnt wanna work 😭

rocky canyon
#
    void Update()
    {
        // Create a ray from the camera through the mouse position
        Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);

        // Shoot the ray into the scene
        if (Physics.Raycast(ray, out RaycastHit hit, rayDistance, rayMask))
        {
            EdgeHud currentEdgeHud;
            if (hit.collider.TryGetComponent(out currentEdgeHud))
            {
                Debug.Log("Found an EdgeHud on: " + hit.collider.name);
            }
        }
    }``` if u use a `TryGet` u can compare and find out if the hit has a certain Script
bitter pine
rocky canyon
#

like in this example its looking for a scritp called EdgeHud ^ if it finds one it can do something with it if not it just continues code

grand snow
rocky canyon
bitter pine
#

thats what it is rn

rocky canyon
#

so 1 script could call a function from every script w/ the same interface ..

just giving a bit of knowledge.. u don't have to use it.. but TryGets are better than GetComponents <-

if u end up using GetComponents its teh same line of thinking

bitter pine
#
{
    RaycastHit hit;
    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

    if (Physics.Raycast(ray, out hit, interactionDistance))
    {
        if(hit.transform.gameObject.layer == 6)
        {
            InteractionText.text = "Press '" + InteractionKey.ToString() + "' to interact.";
            if (Input.GetKeyDown(InteractionKey))
            {
                RcHitOBJ = hit.transform.gameObject;

                if (RcHitOBJ.gameObject.CompareTag("Door"))
                {
                    DoorMain doorScript;
                    doorScript = RcHitOBJ.GetComponent<DoorMain>();

                    doorScript.OpenCloseDoor();
                }

                if (RcHitOBJ.gameObject.CompareTag("Holdable"))
                {
                    DropHeldItem();

                    HeldItem = RcHitOBJ.name;

                    RcHitOBJ.gameObject.GetComponent<Rigidbody>().isKinematic = true;
                    RcHitOBJ.GetComponent<BoxCollider>().enabled = false;
                    RcHitOBJ.transform.parent = objectHoldStorageLocation;
                    RcHitOBJ.transform.localPosition = Vector3.zero;
                    RcHitOBJ.transform.localRotation = Quaternion.Euler(0, 90, 0);
                }
            }
        }
    }
    else
    {
        InteractionText.text = "";
    }
}```
#

that is the function rn, i go check it in game (the function is being called in update) it doesnt work. yes 6 is the interaction layer

grand snow
#

Is your mouse locked or unlocked?

bitter pine
#

locked

grand snow
#

I forget if its forced into the screen centre when locked

rocky canyon
#

it is

bitter pine
#

it is

grand snow
#

Cool then lets presume the raycast is hitting someone else, the layer is not set on the object with the collider or the distance is too small

#

Perhaps some Debug.Log() s will help or you can try to use a Debugger if comfortable

rocky canyon
#

Debug.Log($"Always debug your hits: {hit.collider.name}");

bitter pine
#

i shall figure this out later cuz i gtg

rocky canyon
#

if(hit.transform.gameObject.layer == 6)
doorScript = RcHitOBJ.GetComponent<DoorMain>();

hardcoding layer comparisons and using GetComponent
yet :

yes, im not adding a script to everything i wanna interact with so this is a no go
in regards to using TryGet..

odd.. that statement doesn't make any sense as that's what you would need to do w/ the GetComponent

(if u have more interactables.. for example)

is the hit a door?
is the hit a switch?
is the hit a lever?

each interactable would need a new block of logic

shell sorrel
#

i just make Interactable a interface, can use TryGetComponent to check if something can be interacted with then each thing can implement that interaction how it wants

cosmic dagger
#

Use an interface so that every interactable has a standard method to call . . .

rocky canyon
#
public class Door : MonoBehaviour, IInteractable
{
    public void Interact()
    {
        Debug.Log($"Interacted with {gameObject.name}");
        Debug.Log($"Its a Door");
    }
}

public class Switch : MonoBehaviour, IInteractable
{
    public void Interact()
    {
        Debug.Log($"Interacted with {gameObject.name}");
        Debug.Log($"Its a Switch");
    }
}```

and then:

```cs
public class InteractRaycast : MonoBehaviour
{
    public Camera mainCam;
    public float rayDistance = 100f;

    void Update()
    {
        Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit hit, rayDistance))
        {
            if (hit.collider.TryGetComponent(out IInteractable interactable))
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    Debug.Log("Found an interactable on: " + hit.collider.name);
                    interactable.Interact();
                }
            }
        }
    }
}```
shell sorrel
#

well i would key check first unless you are changing UI or something

#

and return early as needed to reduce nesting

rocky canyon
#

i think he's misunderstanding...
i mentioned TryGet and he says nah, im not adding code everytime..

but then rocks the layer comparisons and GetComponents anyway

#

but he'll sort it out later πŸ‘

rocky canyon
#

hmmm I just realized something
protection level doesn't seem to matter on functions within interface
is that an accurate assumption?

#

public void
private void

shell sorrel
#

it does in some cases like if internal

#

but yeah not really, now there are two ways of implementing the interface though

rocky canyon
#

well i mean its not concerning for basic use?

rocky canyon
shell sorrel
#

like when implmeneting it you can do it publically or do InterfaceName.MethodName to do it in such a way you can only see the method from the interface

rocky canyon
#

All methods declared in an interface are implicitly public.

#

ohh okay.. so I can't actually put private void Interact()

#

i mean I can.. but the raycast script that calls Interact() doesn't compile

#

learn something new everyday

shell sorrel
#

well think about it

#

would need public or internal

rocky canyon
#

ignore me.. coffee still in standby

shell sorrel
#

now there is a trick to hide the method for things that have only the concrete class and not the interface

#

can be useful sometimes if do not want to clutter up auto completions

#

and guide people on usage more if its only used from your own lib code

rocky canyon
#

A. cs hit.collider.TryGetComponent(out DoorMain currentDoor);
B. cs hit.collider.TryGetComponent<DoorMain>(out var currentDoor);
C. cs hit.collider.TryGetComponent(typeof(DoorMain), out Component comp); DoorMain currentDoor = comp as DoorMain;

πŸ“Œ This is something I need more experience with..
the whole generic stuff.. dynamic type, known type, & so on

shell sorrel
#

just always use the generic ones

#

A and B are the same thing

rocky canyon
#

this is my go-to

#

just seems to most simple

shell sorrel
#

C is mostly for cases where you get a type a different way and need to pass it

rocky canyon
#

ahh okay

shell sorrel
#

like if you got it via reflection etc

rocky canyon
#

yea.. lol we'll hold off on that a bit longer πŸ˜…

shell sorrel
#

A and B are the exact same thing

rocky canyon
rocky canyon
#

i get those two... it was really C. i struggle with

shell sorrel
#

both are creating it

#

not creating it would be if you declared it above and did not add the type / var part in

rocky canyon
#

ohh u right.. my screenshot is where it just uses an existing one

shell sorrel
#

yeah existing or not is just about how you want it scoped

rocky canyon
#

as long i dont need to use the C one too often im good lol

#

thanks for the insight passerby πŸ‘

#

i always look for tryget snippet to copy and paste.. and they always
seem to be more complicated than the one i use

#

TryGetComponent(out whateverReference)) is the one i can never find..

have to start off with auto-complete in the IDE and just remove the bits until i get clean syntax πŸ˜…

naive pawn
#

class members default private, interface members default public

#

so just like private in classes technically doesn't do anything, same for public in interfaces

rocky canyon
#

yup yup.. thats the part i learned today

#

interesting.. i never even knew

#

how do we check if a raycast hit is null or not?

hexed terrace
#

hit.transform == null

rocky canyon
#

i can't think this morning 😩 a

rocky canyon
frail hawk
#

!learn

radiant voidBOT
hexed terrace
#

or hit.gameobject

rocky canyon
lunar coral
#

all those 3 scripts work together for this

hexed terrace
#

and the error is in which one

lunar coral
rocky canyon
#

once u pick it up.. do u destroy the "pickup" object?
and if so.. is there any of ur code that might still be trying to access it?

hexed terrace
lunar coral
rocky canyon
hexed terrace
#

that is not what I asked for, only half

#

Click on the error... it displays more information (the call stack) in the section below

frail hawk
#

could it be this line? currentBattery = null;

#

after he destroys the object

hexed terrace
#

no, that's setting the currentBattery null, not trying to use it. It wouldn't cause an NRE on this line

lunar coral
#

I'm sorry I forgot to include this

hexed terrace
#

assuming invincible is the same game object across the two classes

lunar coral
#

OH yeaaaaaa

#

tyy so much,I forgot this one was in the Update() function and I wasn't even looking at it

hexed terrace
#

that error wasn't very clear (it may show further down that's cropped out which one of your classes it starts in). I worked it out from the UnityEngine.GameObject.SetActive(System.Boolean value)

lunar coral
#

....I'm really sorry

#

my brain is cooked after school

hexed terrace
#

there you go.. class and line πŸ˜‰

rain solar
#

if i move the frustum, causing a bunch of chunks to be queued in the async chunk loader thread then i do a 180 flip with the frustum so now all those chunks that are being loaded are no longer needed, how should i handle the logic to prevent the queue from getting clogged or loading data that is no longer needed?

rocky canyon
# bitter pine i shall figure this out later cuz i gtg

#πŸ’»β”ƒcode-beginner message

soo, whenever you get back to working on this check out what I mentioned and then the replies afterwards from other people.. You can build it however you want, of course, I just wanted to clarify what i was saying a bit..

Here's the setup for using Interfaces and a TryGetComponent() --

  • ur interactable objects can just use an interface like: public class Door : MonoBehaviour, IInteractable and public class Lever: MonoBehaviour, IInteractable
  • they must all share similar methods since its an interface.. you can have a method called Interact()
  • the TryGet() would call Interact() on any script that uses that interface (this way ur not remaking the code over and over... when you have a new object thats Interactable you simply make it use the IInteractable interface or w/e you call it..
    IInteractable currentInteractable;
    RaycastHit hit;

    void Update()
    {
        Ray ray = mainCam.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out hit, rayDistance))
        {
            if (hit.collider.TryGetComponent(out currentInteractable))
            {
                Debug.Log("We successfully cached the Interactable");
            }
            else
            {
                currentInteractable = null;
            }
        }
        else
        {
            currentInteractable = null;
        }
    }
  • when the raycast successfully "gets" the Interactable you just cache it (store it in a variable)
  • then u can use Input to check if theres something cached.. and if there is u just call the method on it (Interact())
rocky canyon
rain solar
#

i guess its not a pipe if its between threads

#

sender thingy mechanism

rocky canyon
#

ahh yes, the sender thingy πŸ˜„
is async chunk loading considered beginner?

rain solar
#

i thought my one sentence question was because it involved no code and is just abstract implementation ideas

rocky canyon
#

maybe someone smarter than I has an answer.. i know very little about async or chunking.. πŸ€ good luck tho

grand snow
rain solar
#

its limited by disk read speed so i cant load an infinite amount at one time. The issue is how does a non-needed chunk know its no longer visible/needed after its already been called for load

grand snow
#

perhaps you dynamically update some kind of priority on them as the camera moves and you can use that to kill off those who go below a threshold

#

e.g. angle from view

rain solar
#

once i send it to the load thread i dont think i can like update the priority cause its no longer existing on the main thread

grand snow
#

ofcourse you can

#

its not a seperate process

#

presuming these are not stack allocated only

rain solar
#

so every time the frustum moves, i mutex lock the entire queue and validate each one again?

grand snow
#

then you can infer this data without any writes when refreshing what loads can be kept

#

Perhaps then you can dequeue, check if the load should even happen, if not discard and continue

#

which then removes the need to do extra work to each queued item

lunar coral
#

hi, what could be the reasons InputGetKeyDown(KeyCode.M) doesn't get detected?

#

All my Inputs work well except for M, and the problem doesn't come from my keyboard

cosmic quail
slender nymph
slender nymph
#

consider logging both conditions

cosmic quail
lunar coral
#

and yes I'll try to restart the editor

lunar coral
slender nymph
lunar coral
#

and I've also tried to see if M KeyCode gets detected by logging it

lunar coral
#

it's set to true Once I pickup the redbull GameObject

#

and regarding the KeyCode,I logged it and it doesn't work

slender nymph
#

log both conditions at the same time, do not rely on the inspector because you won't see if the condition is false for a frame or two. and if it is and those frames happen to be the ones you initially press the M key (because it checks for initial press, not if it is currently pressed) then the if statement will be false

lunar coral
slender nymph
#

also you don't happen to be using some non-qwerty keyboard layout, right?

lunar coral
#

I'm not from the USA...

hexed terrace
#

qwerty isn't just for that third world country!

slender nymph
# lunar coral I'm using Azerty...

see that's useful information that you should provide up front when dealing with input issues like this. i'd bet if you pressed the key that would be the M key on a qwerty board it would work because you probably have Use Physical Keys enabled

lunar coral
#

but I don't think it'd change something, this is only for the first letters that it changes something

rocky canyon
#
        if (Input.GetKeyDown(KeyCode.M))
        {
            Debug.Log("Input has been snatched!");

            if (PlayerInventory.instance.hasRedbull)
            {
                Debug.Log("Player has Redbull!");
            }
        }``` try it this way (same logic but nested instead of combined)
#

ohhh Azerty πŸ‘€

lunar coral
#

Well I think someone hacked my pc

lunar coral
#

the one I put got deleted

#

and the one I didnt got there

#

@rocky canyon @slender nymph

rocky canyon
#

sir?

lunar coral
#

the logs don't work

#

neither of the two

rocky canyon
#

well.. thats not good

lunar coral
#

NAHH

#

I mean M only

#

the INput one

slender nymph
#

and have you tried pressing the key where the M keywould be on a qwerty keyboard?

rocky canyon
#

is this a new issue?

#

like, ur saying all the keys work but the M key?

lunar coral
#

","

#

sorry for the time I've wasted but I saw 4 malwares in malwarebytes so I've just deleted them

#

but yea M is , in azerty, it's annoying, are there solutions?

slender nymph
lunar coral
bitter bobcat
#

hey folks, think yall can help me out ?

hexed terrace
#

!ask

radiant voidBOT
# hexed terrace !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

bitter bobcat
#

it is, just a second

rocky canyon
# lunar coral but yea M is , in azerty, it's annoying, are there solutions?

DebugKeypress/ Input class

        // update
        foreach (KeyCode kcode in System.Enum.GetValues(typeof(KeyCode)))
        {
            // debug/print each *Down* Keypress
            if (Input.GetKeyDown(kcode)) Debug.Log($"Pressed: {kcode}");
        }```

little helper function that prints out the input keycodes /enum
but yea the issue i believe is what boxfriend has keyed in on
lunar coral
#

and yea it fixes it

#

but my commands for moving still are ZQSD instead of WASD

rocky canyon
#

Azerty guys.. amirite πŸ€ͺ

lunar coral
rocky canyon
#

i think its neat.. i'd be awful at typing and working with one tho πŸ˜…
i didn't even know that was a thing that boxfriend was talkin about

#

well.. i kinda did but never woulda guessed that was the case

compact hare
#

how do i reference TextMeshPro UI in code
public Text ScoreText; doesnt work

hexed terrace
compact hare
#

it says type or namespace couldnt be found still

hexed terrace
#

so add it

grand snow
#

πŸ’‘ use your ide to help

hexed terrace
#

it should have auto added it when you typed that, have you got your IDE configured?

bitter bobcat
#

I have this glitch where Im constantly jumping and moving backwards I think it has something to do with the code aspect

compact hare
#

thanks!

hexed terrace
compact hare
hexed terrace
#

!vscode

radiant voidBOT
bitter bobcat
hexed terrace
#

There's a handy guide for you

compact hare
#

thanks!

bitter bobcat
#

think yall can help me out ?

compact hare
hexed terrace
#

I can't help beyond pointing you to the link... VSCode is / was a pain in the ass to get working with Unity. I'm on Windows so just use VS

compact hare
#

yea no need im fine working like this

hot wadi
compact hare
#

if anything ill switch to vs later on

hexed terrace
compact hare
#

i guess im an old school guy

#

i guess its alright for now cuz im using a tutorial and just remembering and typing it out

bitter bobcat
#

I can still move whilst jumping and moving backward

#

but the jumping and moving backward is unpromted

#

unprompted

#

the moving backward thing is fixed, but the jumping is still an issue

hot wadi
bitter bobcat
#

alright, how do I mitigate this

hot wadi
#
{
    if (Input.GetButton("Jump") && canMove)
    {
        moveDirection.y = jumpPower;
    }
}
else
{
    moveDirection.y -= gravity * Time.deltaTime;
}```
bitter bobcat
#

doesnt work

#

do I need to add a rigidbody or ?

cosmic quail
bitter bobcat
#

then how do I proceed ?

cosmic quail
bitter bobcat
#

how ?

cosmic quail
hot wadi
#

It works fine for me most of the time. I just find it weird to multiply the entire input axis with the direction vector

bitter bobcat
#

yeah, mayhaps, I used the code ya gave me, and it didnt work, I added a rigidbody to the capsule and it just started spinning

hot wadi
#

U can just put those 2 values as float for x and z of the direction vector

#

May be u should put a Debug.log message to check when it jumps

bitter bobcat
#

it might be sold

#

solved

soft lotus
#

Is this the right place to ask questions about popular assets such as DoTween?

#

Or is there some other chat, or maybe, an official server that would be better suited for such questions

steel lantern
#

When I call Instantiate to create a new object from a prefab at the same position my Player is at, the new object's OnCollisionEnter gets called immediately. I've tried right after the Instantiate disabling the collider on the instantiated object but it still happens. What is the way to do this? My torpedoes must be allowed to swim.

wintry quarry
#

Disabling the collider should work, as should using Physics.IgnoreCollision

steel lantern
#

I've set collider.enable = False right after the Instantiate call though.

wintry quarry
#

You can also use layer based collisions

wintry quarry
#

or maybe there's more than one collider on the prefab

#

etc

steel lantern
#
GameObject weaponGO = Instantiate(config.prefab, startPos, startRot); 
WeaponController controller = weaponGO.GetComponent<WeaponController>();
if (controller != null)
{
    Collider weaponCollider = weaponGO.GetComponent<Collider>();
    if (weaponCollider != null)
    {
        weaponCollider.enabled = false;
    }
}
wintry quarry
#

the outer if statement and GetComponent seem pointless

#

Can you show screenshots of the prefab inspector

#

Debug.Log would help you here too

steel lantern
#

Well I did trim down the code a bit so you didn't have to look at the non-collider things.

wintry quarry
#

basically it's very possible this code will do nothing, depending on how your prefab is configured in the engine

steel lantern
wintry quarry
#

Does TorpedoController derive from WeaponController?

steel lantern
#

Yes

wintry quarry
#

And does the object have any other colliders, perhaps on child objects?

steel lantern
#

oh.. hmm... good question. Its from the asset store (I have no artistic or animation ability). I'll look at that.

#

dang it. All day I've been messing wthi this πŸ™‚ Thanks.

wintry quarry
steel lantern
#

So is the right thing to do to spin through the instantiated object finding all the colliders and disabling them?

wintry quarry
#

Well for one, are you sure you need more than one collider?

#

Something like a torpedo I would expect to maybe have a single capsule collider on it

steel lantern
#

I guess I do not.

#

I didn't realize it already had one.

wintry quarry
#

for two - I would make this the responsibility of the TorpedoController or WEaponController itself

#

it's pretty common to have an Init() method on a script that you call immediately after instantiation

steel lantern
#

Yes I have one of those.

#

Thanks for the help!

maiden drum
#

Why does Shader.Find("Universal Render Pipeline/Unlit")
return null in a build, but not in the editor?

grand snow
maiden drum
#

that's probably right, unfortunately i can't find it in the always include shaders section

#

any idea what's it called?

grand snow
#

have a material asset pre made and modify it

#

or you use a shader variant collection asset to ensure certain shaders + variants are included

#

best way is to have a material ready made to use/modify as that is most reliable

maiden drum
#

gotcha, so instead of shaders.find i'll just use my material?

grand snow
#

Yea (e.g. via serialized var) and that then introduces a dependency that ensures the shader + variant needed is kept

fathom tartan
#

Yo any 2d programmers here?

#

I tried to make my sprite character move with a script but it didn't work

hardy wing
grand snow
#

We dont make monobehaviours so for them its the second best way to perform an Init with args

#

you could have a factory that spawns and does the init so it wraps both steps

ivory bobcat
static terrace
#

In Android Version of Unity, how can I write a file into the User's Download folder? Like downloading a file

static terrace
#

and I need the External Storage Permission yes, I saw two methods to check and request, but how do I make it wait till the User accepts/denies

loud remnant
#

It's been 3 hours, ive tried everything, not a single download works.
Turned off windows security
idk what to do now

loud remnant
#

πŸ’€

static terrace
fathom tartan
#

Yeah I am just gonna rewrite the code with "input.GetKey", it will be easier that way.

carmine summit
#

trying to make a shader that indexes from a table:

#ifndef GETLAYERCOLOR_INCLUDE
#define GETLAYERCOLOR_INCLUDE

uniform float4 layerColors[10] = {
    float4(1, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0),
    float4(0, 0, 0, 0)
};

void GetLayerColor_float(float2 UV, out float4 LayerColor)
{
    LayerColor = layerColors[0];
}

#endif```
`layerColors[0]` makes the output float4 black (all zeroes) but doing `LayerColor = float4(1, 0, 0, 0)` outputs correctly; how come layerColors[0] isn't returning the element at index 0?
#

(this is a custom function in a URP shader graph)

carmine summit
#

oh

#

apologies

river sandal
#

Hi im looking to find a way to track the players last frame not the current frame, but the one before that is there a way to do that?

eternal needle
river sandal
#

then ill be able to track the speed of a vr controller

slender nymph
#

grab its location at the start of Update before you move it. that will be its position from the previous frame. then after you move it you can use its new position and the previous one

#

or grab its position in LateUpdate if you don't have control over how it moves

eternal needle
# river sandal then ill be able to track the speed of a vr controller

I dont use VR but id really assume there's a way to get the speed if thats something commonly needed.
Otherwise there's a few ways to go about it. you just need to make a Vector3 for the last frames position and write the value as the last thing you do in update or write it in late update

river sandal
#

should i use start(); ?

slender nymph
#

i didn't say before Update, I said at the start of Update. as in, the first thing you do in Update

river sandal
#

So now im getting a curious

#

is there a way to grab it from the last frame

#

it probably wouldnt be useful now that im imagining it

slender nymph
#

i feel like you didn't actually comprehend any of what was told to you

slender nymph
#

then your question has been answered

river sandal
#

right i was just curious

#

if you COULD grab the last frame

#

but i got my answer anyways

#

so thanks

slender nymph
#

grab its location at the start of Update before you move it. that will be its position from the previous frame
literally the first thing i said

river sandal
slender nymph
#

of course, this is dependent on you getting the location before you do whatever moves its location that frame

river sandal
slender nymph
#

no, LateUpdate is the end of the frame

river sandal
#

i see

#

so update is the first part of the frame and lateupdate is at the end

slender nymph
#

if you store its current location in LateUpdate then when you get it in the next Update it will be the previous frame's position no matter what

river sandal
#

ill need to make the numbers very sensitive if its happening withen the same frame

#

thanks

sudden cypress
#

Hi

#

Can I learn to code 3d games here

slender nymph
#

!learn

radiant voidBOT
sudden cypress
#

Wow

#

Nice

#

Thanks

rancid cloak
#

Idky I’m having trouble with this but is there any good way to define tiles over a sprite - like say ur positioning shapes which are sprites like these into a grid you’ve defined and need to check if they can be placed in grid bounds without overlaps

#

Needs to be checked dynamically too tho like if ur generating shapes to be placed in a grid

night mural
#

or whatever shape you want

#

you do need to know their 'grid size' which you probably want to just set manually because there aren't that many shapes and that's simple

haughty forge
#

Hello, how to script to avoid copyright, it feels hard to do my own, idk how to code.

teal viper
teal viper
haughty forge
#

Ok

hot wadi
#

We copy codes all the time atwhatcost

naive pond
#

There is a first person movement script that's on the assets shop. Idk if I should just apply that script to my "bean player character" or would it be better to make the first person movement myself?

frank beacon
naive pond
#

Thank you so much for the help

naive pond
#

I've ran into a problem and I can't seem to fix it on my own so im just going to ask a question on how I would go about fixing this.
Am I allowed to share a picture of my problem?

keen dew
#

Yes. Unless it's code, in that case πŸ‘‡

#

!code

radiant voidBOT
naive pond
#

It is an error message that im trying to show but I have no idea how to add a comment? With a line number? Idk what that even means im just so tired and my head hurts

naive pawn
#

it just means adding a little // <== line [n] here in your code, signifying where the error came from

#

if it's not an internal/editor error, the error message will tell you what file and line it came from

#

start with showing the error

naive pond
#

Like in a picture? And also where do I put the error message do I put it where the word "line" is? I need you to speak to me in crayon eating terms please, my brain is so worn out from trying to figure out code it's also like 3:00 am

wintry quarry
naive pawn
#

that will lead to much higher productivity in the future

naive pond
#

Yeah you're right I need to rest first before I try to do anything more. Thank you I'll talk later

grand snow
#

There are no good official docs on urp lit shaders (non graph) so you may have to look at lit/simple lit and fudge in support if you are willing to try yourself

warm rover
#

hello could someone teach me c# pls?

naive pawn
warm rover
#

wich one do i click? there are like 8 links 😭

hard pecan
hard pecan
#

annoyedeline I said just click one links at the time

warm rover
#

im not gonna watch a tutorial or read a tutorial 😭 i allready know my dumbass will run into a stupid issue that the tutorial doesnt cover. and ill get softlocked. i tried following tutorials EXACTLY once. and ran into an issue 😭

#

or i'll prob make a typo in the code and just brick the whole project and spend 30 minutes finding the typo 😭

hard pecan
frosty hound
hard pecan
#

trust

hard pecan
#

I know about unity and I am new to it but I do know about c sharp

tender mirage
#

Hey there. I'm kinda stuck with an error saying "Optional parameters must appear after all required parameters"
i don't get why that's happening, am i doing something incorrectly?

This is a very basic fade in script that i'm working on.

[ContextMenu("Fadeout")]
private void LaunchFadeIn()
{
    //only fade if not currently fading
    if (IsFading == false)
    {
        
        StartCoroutine(FadeIn(2, new Color(0.5f,0.5f,0.5f)));
    }
         
}

public IEnumerator FadeIn(float Duration = -1, Color FadeinAmount)
{
    IsFading = true;

    float Elapsed = 0;

    if (Duration == -1)
    {
        //Default duration
        Duration = 3;
    }


    Color CurrentColor = BackgroundRenderer.color;

    
    //Fade amount
    Color FadeAmount = new Color(0.5f, 0.5f, 0.5f);

    while (Elapsed < Duration)
    {
        Elapsed += Time.deltaTime;

        float Progress = Elapsed / Duration;

        BackgroundRenderer.color = Color.Lerp(CurrentColor, FadeAmount, Progress);


        yield return null;
    }


    IsFading = false;

    yield return null;
}
hard pecan
#

with this code

#

I kinda not the best at knowing the parameter

tender mirage
#

Yes, the function parameters are invalid

FadeIn(float Duration = -1, Color FadeinAmount)
hard pecan
#

but i'll let the mod and admin awnser that

frosty hound
tender mirage
#

Thanks alot, i really appreciate that

hard pecan
#

beside I think you will get better at this coding

tender mirage
#

is that so?

frosty hound
#

Try it. Your FadeIn function.

tender mirage
#

i will.

tender mirage
#

also thanks alot!

frozen crypt
#

Does Someone have a basic Tutorial for a 3d movement System i cant seem to find one

#

well i can find one but they are all ass

rocky canyon
#

most tutorials are gonna be ass
they're usually geared to just get u up and running and to start familiarizing urself with the concept ur working on
no tutorial is ever gonna be 1:1 exactly what you need

its up to you to expand on it urself and adapt it to what u want

#

player controllers are a big deal.. between that and the camera movement its probably the most important part of the game..

takes time to make one fit ur game.. if its from scratch, a template, or even a bought asset..

rocky heart
#

hey why is unity saying the type ro namespace IEnumerator could not be found IEnumerator OnRightArrowRelease()
{
if (horizontalInput = 1)
{
horizontalInput = 0;
}
else
{
horizontalInput = -1;
}
yield return null;
}

rocky canyon
rocky heart
#

ooooh

#

lemme try

#

ok thx

naive pawn
#

!ide

radiant voidBOT
civic gust
#

Hi. How to optimize drawing through a script? I have c# logic, was trying to draw it on a texture2D, but updating it every frame is very slow. I read people suggested to use Graphics.Blit or maybe shaders? I can't figure out how to connect it to a c# logic, and a bit lost. Blit function takes texture as an argument, so I will still have to set pixels first and I can't see the point there.

valid violet
#

You can update picture only on draw, when you draw

#

For example when you selected brush and pressed left mouse button

civic gust
#

I'm updating it through texture.SetPixels and texture.Apply. But doing it every frame will give me 20fps

valid violet
#

Why do every frame you just need to paste on draw

#

If you are not drawing texture is not changed nothing to update

civic gust
#

because it updates and moving every frame. I'm doing pixel stile particles with physics, something like falling sand or snow

timber tide
#

graphics blit is the idea yeah

civic gust
#

but I want it to be a pixel style and a plane picture, or look like it

timber tide
#

modifying the texture cpu side is slow af

valid violet
#

So you do not need to save texture at the end, you can use shader instead

civic gust
#

can you help me with how to use blit? Some example would be great

pseudo frigate
#

how come only two variables are exposed in the inspector here?

civic gust
timber tide
#

Well, like hunter said are you sure that a shader wouldn't suffice here? There's reasons to modify the texture if you were to stick it into other shaders later on in the pipeline

grand snow
cosmic quail
grand snow
#

That was a thing?

pseudo frigate
cosmic quail
#

yep, that's the exact version

grand snow
#

Ha well time to update!

pseudo frigate
#

oh rip lol, well that explains it

#

thanks

cosmic quail
# grand snow Ha well time to update!

that's the last lts for 2022 though, they made more where they fixed it but that one requires unity pro πŸ˜†
sorry, enterprise or industry* not pro

pseudo frigate
#

its just some visual bug through where theyre not showing? i guess i can deal with that. not sure if upgrading to another version would cause more problems

grand snow
#

Ah dang is 2022 already out of support

cosmic quail
rocky canyon
#

ya its visual.. as long as u can access ur public variables from elsewhere in ur IDE its fine..

#

except for the annoying inspector

cosmic quail
#

they made a 62f2 for 2022 but i doubt they fixed it there

valid violet
#

@civic gust You can use shader to display changes but you will also need to save draws into texture

grand snow
#

That's for the cve fix

valid violet
#

You can create compute shader to write to the texture using GPU instead of CPU.

grand snow
#

Probably too complex for them but yea a compute shader is the way to got to produce a texture

sage mirage
#

Hey, guys! How to create a camera-based crouching system like a simple one? Whats the main formula?

grand snow
rocky canyon
#

cameraOffset = crouchHeight;

sage mirage
#

There are different approaches probably you can do it with Cinemachine Cameras as well but is it meaningful to do so?

grand snow
#

You need to explain more about your current setup to get better help if you still need it

sage mirage
#

No I am just wondering because I have made crouching system only with character controller once

#

and I had the camera as a child of the player

#

its the easiest setup for crouching

#

if you have camera as a child

#

with camera I wanted to create

#

camera-based crouching system without character controller like only the camera to move down and up

#

I have searched some people suggest lerp others suggest to use move towards method

#

for this to happen

grand snow
#

well those are just choices you can make then

static terrace
#

How do I let the user choose a file on Android? Like on Windows you can click on something, it will open the File Explorer and let you choose a file and give it to the app. I want that but in Android.

languid pagoda
#

Question. Lets say all my code is split up into different assemblies via assembly definition files and lets say for example I build my project out to an exe for windows, if I decide I want to update the "PlayerController" assembly can I just essentially drag and drop the one modified dll? or does the entire game have to be redownloaded?

grand snow
#

It probably would work if class definitions did not get changed but if you are using something like steam it will just handle efficient updates for you

still ingot
#

Is there a way to properly connect keyboard controls to ui button for main menu screen? I tried and the keyboard only works when you click on the mouse button i would like it to just work once the game or project runs?

slender nymph
#

in the editor you need to focus the game window by clicking into it. a build should typically receive focus as soon as it launches

languid pagoda
#

So my plan was to have a post build script that will loop through every file in the output build and generate a sha256 hash and generate a json file. That json file will live on a webserver where the files will download from and then also on the client. The client will send a webrequest passing their json in and the server will compare what the player has versus what the server has and download the needed files. but just wondering if there is anything that will have to be changed each time regardless if the filehash changed or not.

grand snow
#

look up library linking

#

anyway if you have a dynamic file update system then the problem solves itself

#

because if one dll doesnt change hash then we know it didnt change

languid pagoda
#

going to do some reading into library linking

#

Is my overall concept correct on how things like this are handled though?

grand snow
#

maybe itch.io is a better platform if you want an alternative

languid pagoda
grand snow
#

I think as long as you only care about the most recent version it should work as you describe

crimson pike
#

how do you guys organize your namespaces for runtime classes/enums/interfaces etc

#

or do you even use namespaces outside of editor stuff?

grand snow
#

well if you do that make sure you have authentication otherwise anyone can pirate and steal the game

#

there is a reason why people pay for platforms to do this stuff for them

languid pagoda
#

Oh I understand but 40% is crazy talk.

#

But its not like your game cant be stolen/pirated automatically just because its on steam.

#

Hell there are multiplayer games that are being pirated and steam is being abused to support multiplayer still by utilizing steams default appid (spacewars)

grand snow
#

no but if you implement this yourself then you have more things to consider

maiden drum
#

Is there any way to average out profiler metrices?

languid pagoda
maiden drum
#

oh dang it, it's good for analysing frame drops but oftentimes script take differing times so it's hard to know which one is slow

languid pagoda
#

frame drops usually caused by gc spikes

#

profile that first, especially if you're having a hard time pinpointing a script thats taking too long to execute

maiden drum
#

will do, thanks

languid pagoda
#

no problem. are you instantiating or destroying many objects at once in your game? what can happen is you can spawn 200 game objects destroy them but they will persist in memory until the gc does a sweep. Later in the game you might spawn 10 more objects and hit some limit that tells the gc to run and that is when youll get the frame drops.

lusty prawn
#

does anyone know a solution when tiles sometimes have a one pixel gap when the camera is in a certain position?

#

looks very glitchy

lusty prawn
#

camera moves very odd then

languid pagoda
#

Yeah thats one big drawback with pixel perfect camera it restricts smooth movement

#

Chances are you can fix this with your import settings, is your filter mode on point?

lusty prawn
#

point (no filter)

languid pagoda
#

what about pixels per unit?

lusty prawn
#

32x32

#

so 32

languid pagoda
#

ok so your import settings make sense

lusty prawn
#

my temporary solution rn is i made it 31 ppu but it looks a bit odd

languid pagoda
#

You sure its just not low quality art assets?

lusty prawn
#

maybe.. but i think it just happend when i begun the project i didnt have it

languid pagoda
#

what happens if you manually set the resolution in the playmode window

#

dont touch the zoom just adjust the resolution and leave it where it is then press play

lusty prawn
#

in the camera?

#

or the pixel perfect camera comp

#

tbh ive tried everything even ai cant help me

languid pagoda
#

set a resolution

#

if its on auto it might misalign things

lusty prawn
#

alr i tried it on 1920 x 1080 which it was on which doesnt work and 4k also but i still have it

languid pagoda
#

weird

#

are the sprites from a sheet?

lusty prawn
#

yeah

#

this is what hapends btw

languid pagoda
lusty prawn
#

wdym

thorn vine
#

Hello everyone ☺️

versed stump
leaden hazel
#

HELLPPPPPPPP HELP ME HELPPPPPPPPPPPPP PLSSSSS ME NO SPEAK ENGLISH ME ON MAC BOOK HELP ME PLESSSS

true nacelle
#

I'm trying to get to grips with the new Input System Package after initially learning the Input Manager, I'm mostly there with the basics I think, but there is one issue I'm having. I have a Button ActionType that is triggering both on key down and on key release, so each time I press space bar the event happens twice. Does anyone know a solve for this?

leaden hazel
leaden hazel
#

but ok for mac?

rich adder
#

this isnt a platform thing. Its a new C# extension feature thing

leaden hazel
#

ok I will try tanks

earnest wind
#
AndroidJavaClass intentClass = new("android.content.Intent");
AndroidJavaObject intentObject = new("android.content.Intent");
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_VIEW"));

AndroidJavaClass uriClass = new("android.net.Uri");
AndroidJavaObject fileObject = new("java.io.File", FolderPath);
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("fromFile", fileObject);

intentObject.Call<AndroidJavaObject>("setDataAndType", uriObject, "resource/folder");

AndroidJavaClass unity = new("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
currentActivity.Call("startActivity", intentObject);
#

i might need to make a dev version to see the errors

#

my original question since i asked in wrong channel

#

ignore the "using", i was testing smth but its not there anymore as i dont need it (edited the message)

grand snow
#

With that much JNI id just write this in java and invoke that

earnest wind
grand snow
#

Not sure, you want to open a file picker? Did you add the required permissions?

#

I do remember this stuff changed at some point so dont use an old api

earnest wind
#

smth like how u do it here

#
Application.OpenURL("file:///" + LevelPath);
#

but on android

grand snow
#

android doesnt really do such a thing

fathom tartan
#

how do I fix this(Doing a 2d game right now)

slender nymph
earnest wind
#

😭

grand snow
#

because they tried to move away from apps having full access to all files so its better controlled now

tough lagoon
#

File provider examples

tough lagoon
random patrol
#

I updated my unity 6.0, and now I am getting errors about packages missing Unity Sentis?

#

Library\PackageCache\com.unity.ml-agents@2b4ded88494d\Runtime\Academy.cs(11,13): error CS0234: The type or namespace name 'Sentis' does not exist in the namespace 'Unity' (are you missing an assembly reference?)

#

What even is Sentis?

rich adder
#

now is called "Inference Engine"

rich adder
#

delete the packages related to it first if you have any

fathom tartan
#

yo guys why isn't the sprite editor showing upp?

ivory bobcat
fathom tartan
#

alr

river sandal
#

Hi i was trying to make a hand walking system. This script is supposed to track the distance from your hand from the last frame. I was wondering if I needed to declare currentHandPos again on LateUpdate;? I am on my school laptop so im not able to test it right now.

using UnityEngine;
using UnityEngine.InputSystem;

public class MyScript : MonoBehaviour
{
    private Vector3 lastHandPosition;
    private Vector3 movementSpeed;
    private Vector3 handDelta;
    private Vector3 currentHandPos;
    private Vector3 newPos;
    private float distance;
    public Rigidbody playerRigidbody; // PUBLIC
    private float movementMultiplier = 1.3f; // adjust value to change movement power
    // called immediately when the script is loaded or something, before start.
    void Awake()
    {

    }

    // called first other than Awake
    void Start()
    {
    
    }

    // Can call at a fixed interval? How can that be useful lol.
    void FixedUpdate()
    {
        
    }


    void Update()
    {
    lastHandPosition = transform.position; // the current position so it becomes the last position in the next frame
    }

    void LateUpdate()
    {
        currentHandPos = transform.position;
        distance = Vector3.Distance(currentHandPos, lastHandPosition) / Time.deltaTime;
        handDelta = currentHandPos - lastHandPosition;
        float movementForce = distance * movementMultiplier;
        Vector3 moveDirection = -handDelta.normalized;

        if (handDelta.magnitude > 0.01f)
        {
            playerRigidbody.AddForce(moveDirection * movementForce, ForceMode.VelocityChange);
        }
    }
}
#

i would assune LateUpdate(); -> Update();

#

because Update(); runs every frame, same as LateUpdate();

teal viper
river sandal
teal viper
#

Yes

river sandal
#

πŸ™

teal viper
#

You should put everything in update and set last position at the end of the logic.

#

Ah, you're moving via physics...

#

If you're moving via physics you should be doing all of it in fixed update

trail sky
#

Howdy yall!

river sandal
# teal viper You should put everything in update and set last position at the end of the logi...

right but I wanted to get the current frame and then when that frame passes it gets the hand position of the frame how would i do that without Update(); and LateUpdate();

CurrentHandPos -> NextFrameHandPos // then of course you just subtract them to find the total then apply the velocity

now im at a halt and i dont see how can i use fixedupdate. it seems useless since it can only update at a fixed interval. How can I get the current frame then save it, and then get the the next frame?

#

i was thinking of using a float then saving it

river sandal
#

I do have one question, would FixedUpdate(); be better at physics? If so can I just set the Interval to 1. So its better at physics and moving at the same time as Update();?

neon forum
#

for a multiplayer online game, how can I tell the host to spawn objects from the client? Or is there a way to enable distributed authority?

trail sky
#

I have heard FixedUpdate(); is speficly ment for physics
-# im not entirely sure, theres people with more knollage for sure

slender nymph
#

make sure you've also updated all packages

tough lagoon
# river sandal I do have one question, would FixedUpdate(); be better at physics? If so can I j...

Sorta.
Yes, FixedUpdate runs on the physics execution time (runs a lot less often).

Most of the time just multiplying what you are doing by Time.deltaTime and doing it in Update is fine. It makes non-physics changes smooth, allows for input to be processed properly on the frame it starts/ends, etc.

Most physics operations are also fine to execute from Update as they are applied on the next FixedUpdate anyway (with a couple gatchas). But there are some scenarios where running it in the physics loop is important.

It's just rarely needed in practice and mostly misused (imho).

cosmic dagger
naive pawn
tough lagoon
#

And the input state may have changed

#

I.e. missing presses and releases

naive pawn
#

exactly. it's not "getting input faster", it's getting input correctly

tough lagoon
naive pawn
#

fwiw i feel like it's kinda misleading to say you should just do everything in Update

#

rigidbodies have interpolation to make them not jittery even as they actually update in the fixed timestep

tough lagoon
#

So tell them to do something else

naive pawn
#

things that are bound to the fixed timestep, ie most physics stuff that isn't just an assignment, should be done in the fixed timestep

tough lagoon
#

If you have a practical reason you suggest they use fixedupdate, my suggestion is to tell em.

naive pawn
#

randomunityencounter already gave a sufficient answer tbh

#

i'm specifically telling you that your advice is misleading

tough lagoon
#

Ok πŸ˜‰

hazy thicket
#

doing ld58 rn, and im having trouble getting a rotation working, i have two vector3 world positions, and im trying to rotate an object on its local X axis to line up with the positions, feel like ive tried everything

winged ridge
#

.localRotation may help

timber trellis
#

is there a way to capture a windows desktop screen and duplicate it inside of unity ? i cant seem to have any luck finding something similar online, other than a couple of japaense libraries

winged ridge
#

In what sense? As in a live capture so if they move the mouse on desktop it moves in the editor or in game

#

For that your best bet is to look into C# and .Net libraries, unity itself wouldn't handle it since it's likely a system method

tough lagoon
hazy thicket
timber trellis
#

thats one of the japanese libraries i came across. i did some digging and i found the creator discussing it in a forum and according to him the performance was unsatisfactory so he didnt work on it further. Idk should i still try it ?

tough lagoon
timber trellis
tough lagoon
timber trellis
#

Hmmm oke doki. I’ll get on it as soon as i get back from uni 🫑

winged ridge
timber trellis
winged ridge
#

People don't use it because they don't understand it or think it won't work, the best way to do any screen capture is the way the Developer of the code wrote... Any hack around will not be as good or flexible

random patrol
sour fulcrum
random patrol
#

Because then you would fallow actual standards for the language instead of making up stupid stuff

#

?= doesn't work because of their stupidity

#

What is insane is that I have lost 2 days fixing my project because they wanted to change thier ML package name

sour fulcrum
#

ok

timber trellis
rich adder
winged ridge
#

Alongside a backup before and after the upgrade

slender nymph
#

that's what the version control is for. just revert to the previous version if updating broke things

languid pagoda
#

how are multiplayer games on steam preventing people from stealing accounts if steam ids can be spoofed. I am not using steam just wondering what auth options we have

winged ridge
#

In theory, many authentication options, such as the whole Google play etc.. but a steamID isn't necessarily there to be a level of security, more a entry in a large database

random patrol
rugged beacon
tender mirage
#

I thought this would've gotten every gameobject without tags, but it's giving me a null error instead.
i want to grab every gameobject that doesn't contain any tags.

GameObject[] AllNonetags = GameObject.FindGameObjectsWithTag(null);
#

i'm guessing getting the scene might be a better idea

gentle bone
tender mirage
#

I'll test it out although i already wrote a scene manager get all root parts script.

leaden hazel
#

guys help plssssssssss

grand snow
#

the vs code bug strikes again!

#

the obj folder should be deleted. update vs code and the visual studio package in project.

leaden hazel
#

how do I do that I need more detail

grand snow
#

All assets for your project are in Assets/. Delete the "obj" folder in Assets/.
Update vs code if there is an update as its c# extension is making these files incorrectly.

leaden hazel
#

do I update vs code by deleting and downloading?

#

Cannot update while running on a read-only volume. The application is on a read-only volume. Please move the application and try again. If you're on macOS Sierra or later, you'll need to move the application out of the Downloads directory. This might mean the application was put on quarantine by macOS. See this link for more information.

#

what the

grand snow
#

no fuckin idea πŸ˜†
delete the obj folder for now and I believe there is a setting in the c# extension you can disable to prevent it happening again

bitter pine
#

hey, so ive been touching on interfaces, now it doesnt go through walls if u were here last time. but how do i get the name of the interface object?

#

ah, nevermind just remembered hitinfo is a thing πŸ˜…

grand snow
leaden hazel
#

alright thanks

grand snow
bitter pine
bitter pine
#

would it be better to use hitInfo or the interface to get the object?

grand snow
#

Get it from hitInfo because its easily accessable without a cast

bitter pine
#

ok

grand snow
#

as you see you already access the gameobject

bitter pine
#

ye, so it would be the same?

#

is it possible to get it from the interface?

grand snow
#

get the gameobject once and store in a var

bitter pine
grand snow
#

You can like I said but we can avoid doing that in this context

#

Its best to avoid repeated accesses with unity properties as many go to native code

bitter pine
#

ok

#

would a spherecast or a direct cast be better for interacting?

grand snow
#

But if you need to elsewhere you can do:

GameObject g = ((MonoBehaviour)interactable).gameObject;
bitter pine
#

thanks

#

idk if ill need to use that

grand snow
#

In the context shown above you dont

bitter pine
#

but ill keep it saved just in case

#

πŸ‘

bitter pine
#

so like how a raycast points out, i want a sphere to be at the end of said raycast checking for an object in the general area, so that the player wont have to look at the object exactly to pick it up

grand snow
#

A raycast can be first used to look for an interactable, if not then if you hit the floor/some surface you can sphere cast there to find something close by.

high wigeon
#

So I'm using VS code but for some reason it doesn't identify errors. How do I enable that feature?

grand snow
#

!vscode

radiant voidBOT
grand snow
high wigeon
#

Thank you

bitter pine
#

so, my interaction does work. but it wont interact with some parts of the object

#

like say my door for example, it works on the upper half but not the bottom half?

cosmic quail
rocky canyon
#

easy enough debug the raycast hit and see what it says when u hover the bottom half

cosmic dagger
echo copper
#

guys, who's free rn?

cosmic dagger
echo copper
#

okay

cosmic quail
bitter pine
bitter pine
#

how would i stop that?

cosmic quail
cosmic dagger
bitter pine
echo copper
#

i have this problem. if sonic stands on the joint of the platforms, he shakes like in the video. how to prevent this type of shaking? if you need the code, i'll send it

#

please

bitter pine
# echo copper please

just fix the ground, when the character leans down it goes straight onto the flat surface, making it flat again

#

then it loops

rocky canyon
#

it appears its trying to angle b/c of something
and then trying to stay upright b/c of something else..

u have two ground/check thingies affecting it at once

bitter pine
#

make the ground connect properly and it will work

#

atleast im pretty sure

echo copper
#

okay, thanks, i'll try

rocky canyon
#

well it depends looks like he has two rays far away from each other

#

even if the ground is conncted.. if hes standing on the edge like that (1) is gonna have 1 normal and the other has another normal..

echo copper
rocky canyon
#

u could blend them.. or have 1 take priority

bitter pine
#

why are you using 2?

echo copper
rocky canyon
#

green one says slant to match the ramp
the red one says nah bitch u standing upright

echo copper
#

i have the priority

bitter pine
#

why not just use 1 and put it in the middle

rocky canyon
#

^ that would be the easiest solution

bitter pine
#

just check what floor your on then change to that angle

rocky canyon
#

or u could take both of em abnd blend them togther.. so it tilts halfway between both of em

cosmic quail
echo copper
rocky canyon
#

ahh okay

bitter pine
cosmic quail
bitter pine
cosmic quail
rocky canyon
#

just select all the layers u want to detect but the player layer

bitter pine
#

ohhhh

#

i completley forgot u can select multiple layers for a layer mask 😭

rocky canyon
#

easier that way than inversing the whole mask

echo copper
#

just in future, how to prevent this shakin. i checked the other engines and they has this shake prevent system, idk how does it works...

bitter pine
#

alright, i understand it

rocky canyon
#

its his tilt player to match ground normal

bitter pine
#

oh, its because the camera is connected to the player

#

so its gonna follow its axis

rocky canyon
#

he just has (2) of em working together.. w/ different normals causing it to jitter

bitter pine
#

so if he goes down then up again its gonna cause the camera to shake

#

i think if u lerp the camera it may work

#

or slerp

#

either one

rocky canyon
echo copper
#

if there are 2 normals and distances of these visors is the same, it will take the average angle

bitter pine
#

slerp is more linear where as lerp will slow then speed then slow back down again

rocky canyon
#

i think using an average is a good idea to test

#

see if it fits ur style

slender nymph
#

or just use the slope from the two hit points

bitter pine
#

because i did the layermask and it still wont select the top half

cosmic quail
rocky canyon
#

this is what it might look like if u used the average of all the raycast normals
@echo copper

bitter pine
#

i dont think i forgot anything

cosmic quail
rocky canyon
bitter pine
#

im doing the debug now

rocky canyon
#

it will reveal whats blocking it

bitter pine
#

making a debug cooldown so it doesnt print something every frame

#

making it wait 0.5s before firing

echo copper
#

well, the other engine has the same problem, but sonic isn't shaking. maybe just the sprite interpolates somehow. well, mb the engine detects these shakings. how to do it?

bitter pine
#

wait am i an idiot or am i an idiot?

#

i feel like im missing something

#

ive done cooldowns many times before but, i cant remeber whats wrong here

polar acorn
#

using System.Collections

bitter pine
#

brih

polar acorn
#

It used to be part of the default template but was removed in Unity 6

bitter pine
#

damn

#

ok

polar acorn
#

Since more cases don't need it than do

bitter pine
#

thanks, didnt realise

#

it was clearly telling me but i swore it was alr there

#

@cosmic quail

#

i firgured it out

#

feel like an idiot

#

its the triggers that are in front of the door that tell it what way to open :p

cosmic quail
bitter pine
#

its working now

#

one last problem though, that i need to fix

#

wait

#

no

#

i remeber now, it would only disable the door interact ui, not the text itself 😭

#

sometimes i just create the problems in my head and dont read my own spaghetti code 😭

rocky canyon
#

meh, thats how most of us learn the best πŸ™‚

#

being told not to do something a particular way doesn't hit as hard as
actually doing something the wrong way and realizing it urself later on πŸ˜„

gilded canyon
#

Is it just me or does declaring an array as public cause lots of errors and warnings in the inspector using unity 6000.0.58f2

rocky canyon
# gilded canyon Is it just me or does declaring an array as public cause lots of errors and warn...

its just .58f2 as well as a couple others ive seen...

public class s1 : MonoBehaviour
{
    public Transform[] transforms;
    public Vector3[] positions;
    public Color[] colors;

    [SerializeField] private Transform[] serializedTransforms;
    [SerializeField] private Vector3[] serializedPositions;
    [SerializeField] private Color[] serializedColors;
}

β†’ the editors are bugged out pretty bad..

πŸ“Œ (reset ur layout as a work-a-round)

gilded canyon
#

Classic unity

rocky canyon
#

yup, jank for now

gilded canyon
#

It works!!

rocky canyon
#

just to take a few nice long slow breaths before compiling 🀣
this editor is bout testing patience ;D

gilded canyon
#

I'd assume it would take them about a week or 2 to iron out the quirks

#

Till then this should do

rocky canyon
#

lets hope 🀞 that security thing has em probably running around like chickens w/ their heads cut off

languid pagoda
#

I am using WASMTime as a scripting runtime for my game. It will allow players to mod the game and create custom scripts while staying sandbox. The library is multiplatform but I am unsure how the folder structure works for unity, how do I lay out the folder structure for a native plugin to support osx, windows and linux?

rocky canyon
languid pagoda
rocky canyon
#

no clue.. some potential back door or something

#
Unity

A security vulnerability was identified that affects games and applications built on Unity versions 2017.1 and later for Android, Windows, and macOS operating systems. Unity has provided fixes that address the vulnerability and they are already available to all developers.

languid pagoda
#

Seems odd to me tbh, we aren't sandboxed with the code we can execute so idk what the ramifications of it could be

rocky canyon
#

no one's exploited it yet.. but thats why they went thru the trouble of notifying everyone..
update as soon as u can.. and if you've built with any of those versions and its possible might want to port it over to a different version and re-release

#

are susceptible to an unsafe file loading and local file inclusion attack depending on the operating system, which could enable local code execution or information disclosure at the privilege level of the vulnerable application

languid pagoda
#

so essentially if someone has a virus on their pc and my game installed the virus could exploit the bug in my game to execute code?

rocky canyon
#

thats all i really know
im in the process of moving everything over to 6000.0.58f2
but seeing lots of people with editor / visual bugs with that version

#

soo i really don't know what im going to do... just wait and see for a while i guess

languid pagoda
#

Honestly im just going to stay on my current version until they iron out the issues.

rocky canyon
languid pagoda
#

If someone already has a virus on their pc their cooked anyways

rocky canyon
#

ya, i don't think it means Unity will give u a virus.. but yea
like ur saying.. if u already have one it may make it worse

#

just don't go downloading so much 🌽 until its fixed πŸ€ͺ

cosmic quail
#

steam fixed it so if you upload your game there then it's patched anyways

slender nymph
#

steam did not patch the games. steam is only blocking the command line parameters only if the game is actually launched through the steam client

sage mirage
#

Hey, guys! I am making a camera-based crouching system. For one reason, my camera when I am pressing C button to crouch, it does tiny movements until the camera reaches the crouch height. I am not sure why. Also, another issue is that with my Update Camera Position By State method on Update() method the camera is falling down at the beginning of the game. Could you please review my code and see what is happening because I stuck?

https://paste.mod.gg/drcxzxvmcnyn/0

echo copper
#

what does that means?

rocky canyon
#

you overflowed ur stack πŸ˜„

void InfiniteLoop(){
     InfiniteLoop();
}```
#

check for Recursive update calls, coroutines calling themselves, or nested property getters

tough lagoon
# languid pagoda Seems odd to me tbh, we aren't sandboxed with the code we can execute so idk wha...

If i read it right, there are 4 risks, the main one being an exploit to essentially let someone load a DLL to your game and execute something in it. Most likely someone installs a free game, it checks everything on the system to find exploitable games, and sits on the info a while.

From there its a lot more open what they can do with an exploited version (download a Trojan through your game for example). But its not exactly an easy thing to exploit. And 95% of games will end up not patched anyway.

What steam and others is doing is blocking the URI command to launch the game with the request to load the DLL. It can't stop something from running windows command line to do it.

At least, from what little I've read, that seems to be the risk.

bitter pine
#

where do i go for UI help?

tough lagoon
#

It seems quite convoluted to me as a risk, versus the bad app from just infecting the system directly. But the disguise is what they are mostly worried about

rocky canyon
languid pagoda
tough lagoon
languid pagoda
#

I am actually as we speak embedding the webassembly runtime into unity so users can create/share scripts with each other without executing any malicious code.

#

Will allow users to create scripts in any language that can compile to wasm and be secure in knowing someone elses mods cant do anything fishy

tough lagoon
#

But its still restricted to the permissions the game has

languid pagoda
#

Any games allowing mods through c# reflection are going to be the ones that have the hugest risks

#

but yeah I guess this is only a problem for games with user created content

#

vr chat probably scrambling right now

tough lagoon
#

Plus, they will need an intimate knowledge of your code base to figure out how to exploit it in most cases. So security by obscurity for most small devs.

#

Yeah i can definitely see it being a risk for vrchat

#

But we won't know for sure until someone actually exploits it. People are crazy innovative πŸ˜„

rocky canyon
#

i'd rather have the exploit than my editor being incapable of drawing correctly half the time..
#firstworldproblems

tough lagoon
#

Haha true, or not knowing what the patched executables breaking

tender onyx
#

Not 100% sure if this falls under beginner or not, but anyway... I'm making a survival horror / FPS game and I'm tackling enemy AI. They can see and hear the player to find them, but I'm wondering about smell.

If I made an invisible particle system that trailed behind the player, could I have the AI interact with / follow the trail of particles? TIA

(Any guides, videos, etc. are appreciated!)

tough lagoon
#

So yeah, you could use a trail of particles

#

And, that way, you could also make the smell "visible" at some point in the game

tender onyx
#

Solid, thanks lloyd!

loud remnant
#

I've js finished the rollaball course
what course should I start now?

languid pagoda
loud remnant
#

how can I create a game out of that?

icy quarry
#

yo hello guys, how do I choose the gpu that my unity engine uses to run, rn its running the games in the editor on my cpu

#

my perfomance is terrible

languid pagoda
true pine
loud remnant
true pine
loud remnant
#

no

#

update the camera rotation and transform via code

true pine
loud remnant
#

and see if it works

true pine
loud remnant
true pine
#

I have pastebins for the mouse and movement scripts

loud remnant
languid pagoda
icy quarry
true pine
loud remnant
true pine
#

maybe I didn't word that correctly

icy quarry
#

anyone know the helper team here, i want to get my stuff fixed

true pine
#

I'm not good at expressing what I'm talking about

languid pagoda
icy quarry
true pine
#

it's really weird what's happening

loud remnant
#

oh, sry I couldn't be of help in some way

true pine
#

if I spam wasd while moving my mouse it freaks tf out, but then it just magically works normally for a few seconds

true pine
#

I don't get it either