#💻┃code-beginner

1 messages · Page 778 of 1

balmy tendon
#

when running the game normally, the "stunned =true" line runs when it should be impossible. however when debug mode is enabled, the exact same inputs lead to a separate outcome

solar hill
#

oh youre using visual scripting* ?

rich adder
#

Visual Studio is a code editor dude, you use C# to code not "Visual Studio code"

solar hill
#

i think they are using bolt

#

just not calling it the right thing 💀

#

and also yeah visual studio isnt a "programming method"

raven smelt
astral cedar
balmy tendon
#

i apologize if theres any info im not being clear about, just trying to fix an issue that to me shouldnt be possible?

#

ill do that, honestly i shouldve done that a while ago

naive pawn
#

the breakpoint pauses before that line runs

balmy tendon
rich adder
#

the breakpoint isnt hitting

naive pawn
#

the screenshot you showed just shows that the if was reached, but not which branch it took - you can step forward to see what happens next

rich adder
#

they saying when running with Attach Debugger the bool doesnt hit true

naive pawn
rich adder
#

do you have domain reloading on for Playmode

balmy tendon
#

yeah, regardless, in debug mode the game runs as intended

balmy tendon
rich adder
#

that means you didnt disable it so disregard that

balmy tendon
#

a relaunch of the project did not fix the issue

#

debug mode continues to work as intended

rich adder
#

its strange unless something obvious I'm not seeing rn could be a bug or something..

#

if you hit play doesnt do the same "Domain Reloading" and all that with progressbar

balmy tendon
#

pressing play reloads the domain yes

rich adder
#

prob wont do as much but worth trying deleting library folder ?

balmy tendon
#

where might i find that

rich adder
#

project root folder

#

have to close unity, and it will load a while and put you in new scene

#

i wouldnt be surprised if this somehow ends up being something messed up with 6.2 its been a buggy mess

balmy tendon
#

will deleting the library folder change any project preferences

#

and, thank you by the way

rich adder
#

nah it will not change any preferences
just refresh the cache for assets

balmy tendon
#

this is a particularly bothersome issue, and im grateful for the assistance

#

ok relaunched, library folder was recreated automatically, and the issue is the same

#

ill try in a newer editor version

rich adder
#

turn off Collapse from Console window, then try instead printing Debug.Log($"airtime : {airTime} stunned {stunned}");
before the if statement

#

and maybe one after

#

I mean this in non-debug mode on

#

see what kinda values you record

balmy tendon
#

alright, one moment

#

its outputting numbers significantly higher than any with debug mode on

#

700-800 range

#

now i have to wonder if its like, more updates per second without debug mode on?

#

because airtime is just a value directly related to the number of updates between grounded states

rich adder
#

where are you changing airtime

#

could be FPS related or alike

balmy tendon
#

in Update()

rich adder
#

show code

#

!code 👇

radiant voidBOT
balmy tendon
#
    {
        if (!stunned)
        {
            if (Input.GetKey(KeyCode.A))
                leftPressed = true;
            else
                leftPressed = false;

            if (Input.GetKey(KeyCode.D))
                rightPressed = true;
            else
                rightPressed = false;

            if (Input.GetKey(KeyCode.W))
                jumpPressed = true;
            else
                jumpPressed = false;
        }
        else {
            timeStunned += 1;
        }
        if (timeStunned >= maxStunTime) {
            stunned = false;
            timeStunned = 0;
        }
        if (!grounded)
        {
            airTime += 1;
        }
        else if (stunned) {
            airTime = 0;
        }
    }```
rich adder
#

yeah

#

frame-rate dependent

balmy tendon
#

ok, update is frame-rate dependent cool

#

is there a way to, make that a static value or something

rich adder
#

well yeah cause it runs every frame

#

you want to increase airtime / timestunned INDEPENDENT of framerate

balmy tendon
rich adder
#

use * Time.deltaTime whenever you want values to change overtime consistent regardless of fps

balmy tendon
#

can i throw it in fixedupdate() instead?

rich adder
#

this means it was running way faster than it does in debug mode, which makes sense cause debug mode has overhead

rich adder
balmy tendon
#

really i just put it in update because i knew it would increment always, and i was just gonna tweak values based on what felt good, so either way it should be fine, as long as its consistent

rich adder
#

there is no harm with doing it at your own pace than physics tick as long as you do it with * Time.deltaTime

balmy tendon
#

ok, ill do that then

rich adder
#

you can make it change with your own rate of increase

#

like airTime += Time.deltaTime * airTimeChangeRate

balmy tendon
#

wonderful, things work great now

#

thank you so much for your time i would've been here, literally forever

earnest wind
# balmy tendon ```void Update() { if (!stunned) { if (Input.Get...
void Update()
    {
        if (!stunned)
        {
            leftPressed = Input.GetKey(KeyCode.A)
            rightPressed = Input.GetKey(KeyCode.D)
            jumpPressed = Input.GetKey(KeyCode.W)
        }
        else {
            timeStunned += Time.deltaTime;
        }
        if (timeStunned >= maxStunTime) {
            stunned = false;
            timeStunned = 0;
        }
        if (!grounded)
        {
            airTime += Time.deltaTime;
        }
        else if (stunned) {
            airTime = 0;
        }
    }
#

I dont know if that was like a test code, but u can do that in the if(!stunned)

#

so you dont need to check for if Input.GetKey and set bools manually

balmy tendon
earnest wind
#

this basically runs every frame, so you need to multiply by the time taken between 2 frames

balmy tendon
#

yes, i know

earnest wind
#

ill edit the code just in case someone else sees this ig

#

ok done

#

why is nav thinking

rich adder
earnest wind
rich adder
#

I was talking about the deltaTime thing

earnest wind
ember shell
#

Hey guys

#

I wrote it on the general

#

But I have an issue on unity when I am using easyroads or similar assets and I do shift click to place roads nods it just doesn’t work

#

I really don’t know what to do

rich adder
#

this is a coding channel

ember shell
#

Yeah I know but no one seems to be interested or bothered

rich adder
# ember shell Yeah I know but no one seems to be interested or bothered

crossposting wont help that, also against server community rules..
has it ever occurred to you if someone doesnt answer it means they don't have an answer since this is very specific to your set up / asset? and you have not detailed anything else in the original question to help with that

meager siren
#

How would I put a text infront of an image

rich adder
#

also this is a coding channel

meager siren
rich adder
meager siren
#

well idk where it is

rich adder
meager siren
rich adder
earnest wind
#

he probably doesnt know what ui is either and knows just the word "UI"

meager siren
#

I just didnt look at it

#

you can both stop being rude now

earnest wind
meager siren
rich adder
#

it was sarcasm ui vs UI

earnest wind
earnest wind
meager siren
soft ibex
#

not sure if i should talk this here. but has anyone ever tried using AI-based IDE such as windsurf or cursor for unity? how good it is to boost the development?

p.s. i know the fundamental of coding, just want to speed up my development

rich adder
soft ibex
teal viper
#

The ides that you mentioned are not supported by Unity, so you wouldn't get any intellisense/error reporting and the AI agent might be missing a lot of tools.

soft ibex
#

ah i see. i've been using github copilot for some time and really love it. although i constantly keep hit the limit of free tier. i guess ill try to buy a subscription. thanks for your suggestion!

rugged beacon
teal viper
rugged beacon
#

i tried cursor about 3 months ago and it recognized everything

#

maybe the cursor community is bigger so more support idk
the extension are the same as using vsc

radiant voidBOT
#

success @alibinikram muted

Reason: Sending too many attachments.
Duration: 29 minutes and 51 seconds

sour fulcrum
#

put a log in oncollision enter

#

does it run?

#

that doesn't specifically answer the question i asked

crisp quest
#

i want to make an script in which makes my camera's forward to my player's forward

naive pawn
#

sounds like an x/y problem ngl
what are you trying to achieve?

crisp quest
#

like in which direction im moving my camera, i want my player's local forward towards it

#

like in FPS shooter games

naive pawn
#

are you making an FPS?

#

usually i see the camera as a child of the player for that

crisp quest
radiant voidBOT
#

success @rahul036560 muted

Reason: Too many messages with links sent.
Duration: 29 minutes and 51 seconds

tired python
#

i know that in order to call static methods, you don't need an instance of the type, but i don't know why i can't use the arguments of the method to set the fields inside the type itself.

wind forum
#

Hey, I was trying to hook up a function in the properties pane, but I can't figure out how to get them to show up. I have tried using actions, functions, and events, but none of them show up in the properties pane. I know it's possible because the button does it, does anyone know how to make it show up? For example I want to be able to set propertiy Foo to point to function Bar in the properties pane. Cheers

wind forum
# tired python i know that in order to call static methods, you don't need an instance of the t...

Static methods belong to the class, not the object, so they have no idea what the instance is. You can pass the instance in as an argument, or return a value you can use to assign to an instance.

More info from MS: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-classes-and-static-class-members

In your situation, you could set prefabDroplet as static since it should be global to all ShootBullet instances. It's not clear what targetPosition is though, I presume it's unique for each ShootBullet and so you should pass it as an arg. Just my guess based on your screenshot.

sour fulcrum
naive pawn
#

the inspector?

wind forum
naive pawn
#

sounds like you want UnityEvents?

wind forum
#

I'll give it a try

#

Perfect, cheers!

#

Well maybe not 100% perfect, any way to pass in an arbitrary lambda? Events will have some limitations

#

lambda is a poor choice of words, it has to be bound obviously lol

naive pawn
#

not sure what you're asking exactly

#

what are you trying to do?

wind forum
#

I have a list of buttons and I want to populate them with text, they might not have the same format of text, so I'd like to be able to point button 0 to function Foo, and button 1 to function Bar which can be called in code "buttons[i].text = descriptionsi"

midnight plover
#

Sounds like you want reflection

naive pawn
#

doubtful

wind forum
#

Hm, why would I want reflection?

naive pawn
wind forum
#

Yes, it's very easy to do in code, just use Functions

naive pawn
#

i don't think unity can serialize that, it's just UnityEvents, unfortunately

wind forum
#

Cool fair enough, I can live with that limitation. I just wondered if I missed something obvious

midnight plover
#

So you want your methods from your class to show up as some kidn of dropdown, right?

#

Or am I getting something wrong 😄

wind forum
naive pawn
#

i guess you could use reflection like how animation events does it, but.. that's kind of a fragile system. since you're in control, doing it yourself would probably be easier

midnight plover
wind forum
#

I definitely do not want reflection 😄

midnight plover
#

Do you want to assign them in runtime?

wind forum
#

No, I just want to be able to hook things up in the editor rather than in code

midnight plover
#

then why not use reflection

wind forum
#

In my experience reflection is super fragile in all situations

#

All I want is to be able to say Public Function<string> foo and point that to something in the editor

#

As Chris aluded, if Function was serializable then this would be doable easily

naive pawn
#

couldn't you just have the inverse relation, or an interface

midnight plover
#

I am using reflection to get a list of methods from my instance classes, I know I have an instance type at runtime. from there I can assign any method and call it in runtime through that instance reference without any issue

naive pawn
#

ah shoot, can't serialize interfaces.

#

couldn't you have a base class with a known virtual method, or an inverse relation

wind forum
#

Are you using the function names?

naive pawn
#

have the provider reference and update the button, or have the button (well, its driver script) reference the provider

midnight plover
#

But lets get to your setup. So you want to tie a function, that returns something to an object, that should receive it?

naive pawn
#

the important part is that it's easy to get wrong

wind forum
#

If it works that's good, I think I will not go down that path though 😅

naive pawn
#

that's the issue with reflection

obtuse yoke
#

...sorry to butt in i can see you guys are deep in the middle of something lol. Do any of you have any experience with the unity behavior package

midnight plover
#

Of course it is. But thats with everything in life, right 😄

naive pawn
radiant voidBOT
# naive pawn !ask https://dontasktoask.com

: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

naive pawn
midnight plover
obtuse yoke
wind forum
naive pawn
naive pawn
obtuse yoke
# naive pawn that just wastes both our time

ok.
I am trying to get some information out of a behavior subgraph, and bring it back into the 'parent' behavior graph.. and i cant see to work out how to do this, i've used shared blackboards.. and shared variables.. and... variable overrides...

..but i just cant work it out, and i cant see to find any good examples, that i can 'follow along' with
-so if anyone has any experience with this, any help would be appreciated.

naive pawn
#

i might be wrong, but i vaguely recall something about graphs not supposed to care about subgraphs

though, this is the code channel. behavior isn't exactly code, try asking in #💻┃unity-talk (though, not many people seem to be using it, so might take a few tries.)

wind forum
midnight plover
# naive pawn definitely not

As my questions have not been answered by him, I was just guessing what he might need 😄 Still not sure, what he was to tie together exactly. But if you got it and the solution, ill stay silent

tired python
#

how do you go about referencing a GameObject having the static type? is it compulsory to create another class which holds references to prefabs or is there some other way to do so?

sour fulcrum
#

A lot of people use Singletons

naive pawn
#

having the static type
what do you mean by that

tired python
#

modifier?

naive pawn
#

yeah modifier, it's not a type

sour fulcrum
#

static is not per object

where do you expect that to show

naive pawn
#

you can't serialize static fields

#

do you even need that to be static

tired python
#

ya, i just got to know that that's why i asked how do you reference one...although, if you do use singletons to refer to prefabs, then welp, les just say, i have a to redo a lot

naive pawn
#

I don't see why you'd need a prefab field to be static

tired python
naive pawn
#

why does Create need to be static

tired python
#

good question

naive pawn
#

also, you probably don't want GameObject there

#

use the type of the relevant component on that gameobject, so you don't have to do another GetComponent

#

i keep getting more confused as i read your code lmao

#

what exactly is ShootBullet

#

is it the thing shooting or the bullet itself

#

you should probably step back and design it more clearly

#

so, why is the bullet responsible for creating the bullet (it shouldn't be)

tired python
#

so...i have a unit, which has a collision check in it. if a collision occurs, its supposed to spawn this bullet object. so, this script, is attached to the bullet object in the heirarchy. i am trying to set it up such that, when its instantiated, the script attached to it changes its position by itself. if possible, i just want one script to do that.

naive pawn
#

you can't

#

you'll need an entry point anyways

#

you would have the script that calls Create currently be responsible for the instantiation and initialization

tired python
#

this video does something along these lines though...

🌍 Go to http://admix.in/ and Start Earning Revenue in under 24 hours!
✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=Hp0ovwSC4FE
Let's make some simple Tower Defense AI. Place towers and Fire Projectiles at Enemies in range. Upgrade Tower Range and Damage.

This video is sponsored by Admix

Grid System in U...

▶ Play video
naive pawn
#

is that a screenshot from the video, or...

tired python
#

i tried copying the video, and this is what i came up with...

#

said bullet in question

naive pawn
#

i'd rather not go through the entire video, got a timestamp?

tired python
#

🌍 Go to http://admix.in/ and Start Earning Revenue in under 24 hours!
✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=Hp0ovwSC4FE
Let's make some simple Tower Defense AI. Place towers and Fire Projectiles at Enemies in range. Upgrade Tower Range and Damage.

This video is sponsored by Admix

Grid System in U...

▶ Play video
#

dunno what exactly you wanna see though...

naive pawn
#

the "something along these lines"

tired python
#

for the result produced because of this, you can skip to 10:14

fallow ether
#

yo can someone explain what this actually means? i dont know the terms well enough to figure out what im actually supposed to do here yet

#

im trying to use the new movement system beucase how ive been taught is making my playing move backwards continously but becuase of that Im trying to apply it to an already extremely messy project that ive been hacking at

#

would scrap the entire project but its a group thing so aint an option

#

even on an entirely fresh scene its still doing it

timber tide
#

Don't use the new input system much but sounds like Unity has a singleton instance of a input map and the editor is complaining here that you should use a new standalone instance instead of that singleton asset

#

If you right click in your directory you can usually make a new input action map and use that

fallow ether
#

the guy im programming with unfortunately set it as that so I got no choice, what is really good is I resolved the error after turning my whole project upsidedown for it

#

turns out the input system wasnt offically assigned in the menu for it in scripts

#

had it assigned in project settings so kinda confused but hey works works

#

thanks Mao:))

real thunder
#

any drawbacks making a projectile shooting weapon using particles?

#

well physics wise

#

collisions... I see basic particle system uses simple spheres?

#

in general should I bother using a particle system or just use GameObjects?

#

pros and cons looks ambiguous for me

timber tide
#

Unity's particle system?

real thunder
#

yeah basic one

rough granite
#

Whats the contect where you want to use a particle system to detect collisions in a weapon

timber tide
#

It has rigidbody support, but I think it's limited. It doesn't have the more CPU heavy speculative modes (but I'd double check on that)

naive pawn
#

@tired python so seems like the tutorial you were following basically had a factory, with centralized assets.

if you don't have centralized assets, imo it doesn't make that much sense. besides, the logic could be deduplicated from other projectiles too if that's such a priority

don't treat tutorials as gospel, use them as learning resources. make stuff that suits your needs.
you gotta take some time to design your own systems

real thunder
#

stuff like flamethrower rocket launcher and a crossbow

tired python
naive pawn
#

yeah

#

which i honestly think is unnecessary

tired python
#

i looked into what you said about it being static, and i kinda think, if i do remove static, i might be able to implement it

#
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;

public class ShootBullet : MonoBehaviour
{
    [SerializeField] GameObject prefabBullet;
    Vector3 currPosition;
    Vector3 targetposition;
    public void Create(Vector3 spawnposition, Transform target)
    {
        GameObject projectile = Instantiate(prefabBullet, spawnposition, Quaternion.identity);
        
        ShootBullet shootbullet = projectile.GetComponent<ShootBullet>();
        shootbullet.Setup(spawnposition, target);
    }

    public void Update()
    {
        Vector3 direction = (targetposition - currPosition).normalized;
        if (Vector3.Distance(targetposition, currPosition) <= 10)
        {
            Destroy(gameObject);
        }
    }

    public void Setup(Vector3 spawnposition, Transform target)
    {
        targetposition = target.position;
        currPosition = spawnposition;
    }
}

naive pawn
#

it'd probably be easier to just.. not have Create

tired python
#
using UnityEngine;

public class EnemyCollision : MonoBehaviour
{
    [SerializeField] string EnemyTag;
    private GameObject target;
    private ShootBullet shootBullet;
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == EnemyTag) Debug.Log("Duck was detected.");
        if (!target) target = collision.gameObject;
    }

    private void OnTriggerStay2D(Collider2D collision)
    {
        Transform shootFromPosition = GameObject.Find("ShootFromPosition").transform;
        shootBullet.Create(shootFromPosition.position, target.transform);
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        target = null;
    }
}
naive pawn
tired python
#

so...how would you do it then?

naive pawn
#

why is there a single "shootfromposition"

tired python
# naive pawn why is there a single "shootfromposition"

so like, it's a child gameobject attached to the unit droplet whose position has been set, you wouldn't think that a droplet would spew water bullets at you from its eyes or head right, that's why, i want it to shoot the pellets from its mouth, which is where shootfromposition is set to.

naive pawn
#

so there's only one droplet ever?

tired python
naive pawn
#

ok, so how would you know which shootfromposition to use

#

use serializedreferences for that, not Find

tired python
#

or wait, lemme check

naive pawn
#

and you're making no distinctions between them in this code

#

is EnemyCollision supposed to be on your units?

tired python
#

oh ya, it's working aight

tired python
#

the towers

naive pawn
#

...you gotta name your stuff better

#

you aren't even using collisions

tired python
#

i am though

naive pawn
#

you're also shooting every fixedtimestep?

tired python
#

to figure whether there's a enemy within sight

real thunder
#

yeah that does not look very promising

naive pawn
tired python
naive pawn
#

so why is the thing that uses triggers, called collision

timber tide
# real thunder pros and cons looks ambiguous for me

My experience with it has been fine with anything but really high speed particles, but with the example of something like a flamethrower you might not want every single particle to apply damage if you're using hundreds of particles, which is where having your own collision checking would be more preferable as you can do it in larger shapes.

real thunder
#

well, I don't really know much examples but valve just went for using particles for a flamethrower

naive pawn
#

oh god there's so many issues with the code you showed...

timber tide
tired python
tired python
timber tide
real thunder
naive pawn
# tired python ``` using UnityEngine; public class EnemyCollision : MonoBehaviour { [Seria...

major issues:

  • you are using GameObject.Find to find objects by name, when there are multiple objects with the same name. this is unreliable.
  • shootBullet is never set.
  • you're trying to shoot every fixed time step, with no configurability.
    minor issues:
  • you're using Find using a hard-coded string. this is fragile.
  • you're using tags, which arguably could be replaced by component checks, or in this case, proper collision layer setup. the tag is fragile.
  • you're using Find every fixed time step, a potential perf issue.
  • the OnTriggerStay2D does not check if there is a valid target.

solutions:

  • use serialized references instead of Find.
  • get rid of Create, it's not doing you any favors.
  • serialize shootBullet and assign the prefab properly.
  • you probably don't need OnTriggerStay2D tbh - a question of design, really. the way you have it set up means it can't change targets when the current target goes out of range either.
  • set up collision layers properly instead of the tag check
naive pawn
naive pawn
naive pawn
#

2 would not work, since these are unity components. they have a lifetime managed by unity.

#

5 is not true

#

for 6, Find is an expensive operation, even more so with GameObject.Find.
OnTriggerStay2D is a message that runs continuously. you don't want to be running that expensive operation continuously for no reason.

tired python
#

i don't understand what you mean by this though "set up collision layers properly instead of the tag check"

naive pawn
#

for 7, OnTriggerStay2D will be called for each collider that's in the trigger. if one of the collider leaves the trigger, target gets set to null, but you'll still get OnTriggerStay2D messages from the remaining one

you can avoid this by just not using OnTriggerStay2D

naive pawn
polar acorn
tired python
naive pawn
#

you'd probably keep a list of all that are in range

tired python
naive pawn
#

sure, that'd work

real thunder
#

how does garbadge and memory allocation works?

Why does a RaycastNonAlloc exists for multiple hits but not for a one, and also, is it bad to create arrays of stuff inside a method just for a use inside of this method?

naive pawn
#

raycastnonalloc doesn't alloc because it needs you to alloc

real thunder
#

yeah I get that part

#

but why does a single hit raycast don't have non alloc version

#

then

naive pawn
#

because it doesn't alloc (i'll get to that, ill answer the other question first)

#

is it bad to create arrays of stuff inside a method
bad in general? no, not really.
one thing to focus on would be whether it makes sense for something to be an array, or if it could be something else - a struct, for example.

but in the context of perf, you would start worrying about garbage in 2 situations

  • you have a known "hot path", aka code that's executed a lot (hundreds to thousands to even start worrying, though). this could be in Update, or inside a loop inside Update, etc.
  • you start to have perf issues, and you've narrowed down the cause to excess garbage.
real thunder
#

I got a vague idea what every time I create something it allocates hence garbadge unless it's inside a method which means thing will get discarded instantly (heap/stack thingies, I got poor understanding but yeah)

verbal dome
#

Even if its an array of structs

real thunder
#

now I understand that bit better

#

so it's about reference types?

naive pawn
# real thunder but why does a single hit raycast don't have non alloc version

(this will be simplified to the relevant parts, cpus are really complicated)
in typical modern computers with modern programming languages, there's 2 areas of memory, the heap and the stack
the heap is just a blob of memory that can be allocated for various uses.
the stack is a structure that represents the call stack - when you call and return from functions, there's a FILO behavior, this is managed using the stack.

when stuff "allocates", this usually refers to allocating on the heap. reference types, eg classes, arrays, delegates, are stored on the heap, and their "value" is just a reference to that object on the heap

on the other hand, value types, eg structs, enums, are stored directly. if it's on the stack (eg a local variable) the value is on the stack. if on the heap (in a class, in an array) the value is on the heap

real thunder
#

that sounds like one could "cheat" by using a struct as an array

naive pawn
#

so when you create a struct to return, you're really just copying its actual values, rather than allocating stuff on the heap and returning a reference

naive pawn
real thunder
#

so an array?

naive pawn
#

what?

#

ah, right.

real thunder
#

I mean imagine if you know you would get 0-10 things

#

so instead of using an array u could use a struct?

#

with 10 things?

naive pawn
#

a struct as a concrete type has a fixed size.
an array as an instantiated value has a fixed size.

different scopes.

naive pawn
real thunder
#

well different situation

verbal dome
real thunder
#

that's, like, valid?

naive pawn
verbal dome
naive pawn
#

a struct has a fixed size as a type - if you need to store more, you have to change the entire type, whereas the array type can be of any length - just can't change after constructing

real thunder
naive pawn
#

you'd also need a ton of methods to return each one

real thunder
#

yeah

naive pawn
#

you can't selectively return different structs

#

that's the main issue with the argument of "use a struct instead"

#

but if you do know how many, then yes, you can use a struct.

#

we already do

real thunder
#

I wasn't saying, like, in general

naive pawn
#

Vector2, Vector3, Color, Quaternion, etc, could all be represented as arrays

real thunder
#

I was assuming situations where I know I would get a reasonable small amount of value types

naive pawn
#

"reasonably small" doesn't really cut it

#

you'd need to know exactly what the limits are

verbal dome
#

Regarding the RaycastNonAlloc stuff, you can (and probably should) allocate an array once in the class and reuse it if you perform the raycast a lot

real thunder
verbal dome
#

Or event a static array as long as you understand how static works

real thunder
#

but I got curious why ain't I do that for simple raycasts

real thunder
#

thing is I don't directly see/know how memory management work aside of scary alloc at profiler so

verbal dome
#

Then you should read about "heap vs. stack" / "reference type vs. value type" / "class vs. struct"

naive pawn
#

or spend some time with c/c++ lol

real thunder
#

"The size of memory required is already known before execution." oh yeah

#

missed that part

#

explains struct vs array

verbal dome
#

I keep watching/reading C++ content but haven't gotten out of my C# comfort zone yet...

#

It looks so non-standardized and messy to me

naive pawn
#

well you aren't.. super wrong

#

it inherits some quirks from C where some stuff was made before it got standardized

real thunder
#

what does standartization mean this context?

naive pawn
#

having an authority that defines how the language must behave, and what a "correct" implementation must implement

real thunder
#

people can shapeshift the language? 😮

naive pawn
#

backwards compatibility is typically one of the most important goals when developing new standards

verbal dome
naive pawn
#

so stuff is typically added, not changed

real thunder
#

that barely make sense that language with the same name have different functionalities
that's confusing

naive pawn
#

...huh?

#

not sure what you're referring to there

real thunder
#

I can get that new versions getting new features

real thunder
#

and did not merge

naive pawn
#

well, that is how proposals work

#

but they don't really get added to the language until consensus is reached that it should be added

brave compass
real thunder
#

so what differences are allowed inbetween different implementations?

naive pawn
#

well, there isn't an authority "approving" implementations

#

technically they can have any differences they want

#

but if they don't follow the standard, then it's just not a full correct implementation of that language

#

sometimes there are some things that aren't specified, those can be different

#

some implementations can also add different features beyond the standard as well

real thunder
#

I meant what are differences within the standart

#

which would make sense

real thunder
#

or also something bigger

naive pawn
#

sure, supporting different targets could be a difference between implementations?

brave compass
#

How garbage collection works can be very different between runtimes, and can affect performance. The standard doesn't tell you how you should implement garbage collection, just that there should be.

naive pawn
#

standards define what should be possible and how stuff should behave, and oftentimes they give constraints, but they usually don't specify how to achieve those requirements

real thunder
#

sigh

naive pawn
#

tbh i feel like you aren't really asking effective questions because you don't really understand what specs/standards actually do

real thunder
#

that many different programming languages were already looking too elaborate to have
and there are different version of those languages

naive pawn
#

eg in unity there's mono and il2cpp

real thunder
#

well in Unity C# is used through mono, not as a language, right?

#

or how to call it properly

#

wait what's il2cpp

#

C# to C++?

#

C# > Mono > C++?

#

that's sure alot of layers to make a silly game running

naive pawn
#

c# is compiled to il, then... i guess converted to cpp. i don't really know how il2cpp works tbh

#

pretty sure it does not go through mono though

naive pawn
real thunder
#

at this point are there even people who have a solid grasp on how all the chain and I mean all the chain technically works

naive pawn
#

probably

#

i mean, yes, it is a lot.. but it's definitely achievable

sour fulcrum
#

we honour their knowledge and nitpickyness

plucky harbor
#

hey guys, im a beginner at unity vs code and i wanted to try doing a shoot them up on it. But idk how to make my player flashing when it's get dammaged

naive pawn
#

break it down into smaller tasks - detect the hit, make it flash

#

those individual tasks should be easier to research

plucky harbor
thorn trellis
#

Hello, im a beginner doing scripts in VS Code, and I wanted to participate this channel. Hope you guys to be respectful 🙂

naive pawn
plucky harbor
naive pawn
crisp quest
real thunder
#

MovePosition is not adding force

#

AddForce adds force

naive pawn
#

MovePosition takes a position, not a delta

real thunder
#

also why would u use delta time there yeah

crisp quest
#

what does move position do btw?

naive pawn
crisp quest
crisp quest
naive pawn
#

a difference

#

MovePosition doesn't take an amount to move, it takes a position to move to, as the docs say

real thunder
#

whatever rigidbody you assigned in the inspector won't cut it

naive pawn
#

you'd probably be better off learning from a tutorial at this stage

serene pulsar
#

Everyone
Iam Making An AI
That Creates 3D Models
Is It Help Full?

naive pawn
#

not really

#

also not a code question

serene pulsar
crisp quest
naive pawn
#

that doesn't matter

real thunder
#
if (Input.GetKeyUp(KeyCode.C))
{
GameObject bullet = Instantiate(bullet, instpos.transform.position, Quaternion.identity);
bullet.GetComponent<Rigidbody>().AddForce(pushforce);
}

you meant to do something like that I think?
but I would rather do something like

bullet.GetComponent<Rigidbody>().linearVelocitt = pushforce * bullet.transform.forward

idk

naive pawn
real thunder
#

might sound dissapointing but I agree

crisp quest
naive pawn
#

!learn

radiant voidBOT
naive pawn
#

there's that and also google

gloomy heart
#

Brackeys and GMTk

crisp quest
naive pawn
#

that code isn't correct though fwiw

#

(which is why you shouldn't spoonfeed...)

crisp quest
naive pawn
#

no forcemode means it's continuous, which wouldn't work there.

naive pawn
#

if you want a solid foundation to work on, go learn instead of copying

real thunder
crisp quest
naive pawn
#

yeah, no

#

that's called guessing, not learning

#

use proper resources

real thunder
naive pawn
#

Force

real thunder
#

so it would just apply it for 1 frame?

#

proprotionally to delta time?

crisp quest
#

i thought if i do error and trials then code behaves differently then i might be able to learn practical usage of different methods !

naive pawn
#

no clue, continuous modes aren't supposed to be used in the update time step

naive pawn
#

please stop making excuses and just go learn

#

you are wasting your own time here

crisp quest
#

hmm okay

real thunder
crisp quest
naive pawn
#

trial and error does have its place. but you need fundamental skills and a degree of understanding to avoid the obviously incorrect ways

#

you don't have that experience yet

real thunder
#

my trial and error usually comes from not knowing API well ><

crisp quest
#

it is actually time wasting , so better i should watch some tutorials and learn atleast what those keywords says

#

thanks guys to guide me

real thunder
#

wait, not what I would want to ask

#

I always got a hypothesis and try out to code that

#

which qualifies in my head as knowing what I do before doing it

are there moments where it's not like that

naive pawn
#

reverse engineering sometimes, or when stuff isn't documented well, or when stuff is internal or obfuscated

#

those are just a few examples

#

you usually shouldn't need it

#

(in the context of getting code to do what you want it to, i mean. trial and error for something else like game design is fine)

real thunder
crisp quest
#

trial and error would be useful in game design but not in the context of code . i guess that is what you want to say?

real thunder
#

me? I mean that I see now how it can be useful at coding as valid approach

#

generally I mean

#

at making a game trial and error coding sounds like a bad idea

#

eh, who am I kidding, to make games it took me so much trial and error

#

through shitton of tutorials amolgamating what they talk about into my games

#

it feels like at any field at certain point you just gain enough knowledge from tutorials/other learning that it feels like you know what you are doing and new info no longer feels like new info but rather something to get integrated with already known system of how things work

#

before that point it feels like banging a head against a wall, after that point it feels like you are actually doing what you are supposed to do

#

I wonder if there is a psychology of learning or something which explains those

crisp quest
#

human loves creativity, or you can say that we love to FEEL that we are creating or solving problems (i might be wrong of course)

real thunder
#

I sure love feeling that I am creating problems

hollow lava
#

So, anyone can explain me how really works Player Animations, like an 3d Model ?

rough granite
sullen epoch
#

Hello! Question about interfaces, why use an interface to tell a script that a class "should" contain some data values such as methods or fields. instead of inheriting a class that already contains those values. sorry if thats wordered poorly.

zenith cypress
#

Interfaces are more like "traits" and classes are more like "parents". You can have many traits but only one parent(s).

#

So things like "can be attacked" IHurt (or w/e), can blow up IExplode, can be disposed IDisposable, can check pointer events IPointerClickHandler etc

sullen epoch
#

okay.... but what would IHurt contain? because if it had a method inside it for example wouldn't i be required to rewrite that method for every class that contains IHurt?

ivory bobcat
tulip gust
#

would it be efficient to store a large tile map by using a custom class for each individual tile data and throw it into a 2d array, or should I use ScriptableObject?

#

for reference, I think the world is 1000x1000 tiles large and I'm not sure if a single array is efficient

keen dew
#

Efficient for what? And how would you use a SO instead?

tulip gust
verbal dome
tulip gust
#

from a performance standpoint, I mean. If it's very minimal, I think I'll stick with 2D arrays.

verbal dome
#

Again, how would you replace the array with an SO?

tulip gust
#

or should I use both

verbal dome
#

You can have a SO that contains an array, sure

tulip gust
verbal dome
#

Are you modifying the array data at runtime?

tulip gust
zenith cypress
# sullen epoch okay.... but what would `IHurt` contain? because if it had a method inside it fo...

It would contain functions and/or properties. It's essentially a contract/promise of what this object has to be made of. So yes you would have to add what the interface says to add. Here is a quick example that isn't a good case or anything, just a showcase of what an interface can do.

// pseudo code example
interface IHurt {
  // could also have int Health { get; } but kinda icky imo
  void Hurt(int damage); // a required function
}
interface IDummy {} // just a dummy interface

// notice one class, many interface
class Enemy : Mono, IHurt, IDummy {
  int health = 100;

  // realistically I'd have a shared Entity class
  // with things like this, but just an example :)
  public void Hurt(int damage) => health -= damage; 
}
class TucanEnemy: Enemy {}

// can also virtualize it so inheritors of Enemy can change what Hurt does
public virtual void Hurt(int damage) => health -= damage;
// pseudo code example for input on a ui thing
// can have many IPointer* interfaces when needed
class ExampleUIElement : MonoBehaviour, IPointerClickHandler, IPointerDownHandler {
  public void OnPointerClick(PointerEventData pointerEventData) {
    // this ui thing was clicked
  }
  public void OnPointerDown(PointerEventData pointerEventData) {}
}
tulip gust
#

it's generated and barely touched afterwards

#

(except for the other noise generation that happens after the map is created)

keen dew
#

The forum thread you linked to is about a specific asset that just happens to use ScriptableObjects. It's not something that's inherently built in to ScriptableObjects.

tulip gust
#

oh?

#

would the best solution just be to store the array into a scriptableobject or am I seriously overestimating performance issues

#

the editor lags when generating a 750x750 world and I'd rather it not freeze if I go over the 1500 threshold

keen dew
#

You're getting hung up on the SO

tulip gust
#

2D arrays would be perfectly fine?

keen dew
#

ScriptableObject is just a basic class that has some extras to integrate it with the editor

eternal needle
tulip gust
#

I was just going to render tiles/chunks within a certain range of values rather than everything at once and thought a ScriptableObject would be more efficient

astral cedar
#

hey guys quick question about delegates:

if i subscribe to a delegate, and then recall it without unsubscribing, will it cause memory leaks?

ivory bobcat
#

I find that the tree gets nasty fast with inheritance whereas with interfaces, you simply add and implement the certain behaviors you're wanting. Both do get nasty but the first does so more quickly and is less flexible. A change of hierarchy or behavior would devastate existing code with inheritance whereas each interface would ideally be independent and valid wherever promised.

keen dew
rocky canyon
#

i think its like.. if both publisher and subscriber are alive.. ur good.. @astral cedar {fun fact, theres (4) Maik's in this server}
but if the subscriber gets destroyed but the publisher still holds a reference to it throu the delegate the GC cant collect its garbage

#

i could be totally wrong tho.. i remember someone telling me something like that

tulip gust
#

not modifying them in meaningful ways ish

rocky canyon
keen dew
tulip gust
#

thanks for the help!

sage oyster
#

!code

radiant voidBOT
astral cedar
rocky canyon
#

yes

rocky canyon
#

same way OnEnable and Start/Awake get called

#

so as long as u unsub OnDisable() your always fine..

#

no leaks.. 🥬

astral cedar
#

alright thank you spawn

tired python
frail hawk
#

any code to show?

tired python
# frail hawk any code to show?
public class EnemyCollision : MonoBehaviour
{
    [SerializeField] string DuckTag;
    private List<GameObject> EnemyList;
    public readonly List<GameObject> PublicEnemyList = new List<GameObject>();

    private void Start()
    {
        EnemyList = new List<GameObject>();
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == DuckTag) Debug.Log("Duck was detected.");
        EnemyList.Add(collision.gameObject);
        PublicEnemyList.Add(collision.gameObject);
    }
    private void OnTriggerExit2D(Collider2D collision)
    {
        EnemyList.RemoveAt(0);
        PublicEnemyList.RemoveAt(0);
    }
}```

using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;

public class ShootBullet : MonoBehaviour
{
[SerializeField] Transform prefabBullet;
[SerializeField] private Transform transformOfSpawnPoint;
[SerializeField] EnemyCollision enemyCollision;
[SerializeField] int BulletSpd;

private void Update()
{
    if (enemyCollision.PublicEnemyList.Count != 0)
    {
        Transform bullet = Instantiate(prefabBullet, transformOfSpawnPoint.position, Quaternion.identity);
        BulletMovement(bullet, enemyCollision.PublicEnemyList[0].transform);
    }
}

void BulletMovement(Transform bullet, Transform target)
{
    Vector3 direction = (target.position - bullet.position).normalized;

    bullet.position += BulletSpd * direction * Time.deltaTime;

    if (Vector3.Distance(bullet.position, target.position) <= 1f)
    {
        Destroy(bullet.gameObject);
        Destroy(target.gameObject);
    }
}

}

#

i ideally wanna try to figure it out myself, if you wanna give me advice, you can spoiler your message. chances are, i won't be doing any coding anymore today. my neck hurts like crazy

frail hawk
#

so rn you are spawning a bullet every frame and you want a small delay?

tired python
#

so like, currently, for every duck that's within range, i am spawning like 4 -5 bullets before the duck gets destroyed, so there are 3-4 bullets remaning undestroyed. i will implement a pooling mechanism later on

frail hawk
#

easiest and cleanest way would be to use a Coroutine

tired python
#

yeah prolly

#

did not think of that

frail hawk
#

do you know how htey work?

tired python
#

ya, its basically a function which goes through all the functions or smth along those lines. i forgot the specifics

#

i will be able to implement it, i am confident.

#

cus i remember using it in some part of my code earlier

frail hawk
#

nice

tired python
white matrix
#

yo so i wanted to animate my player and every time im jumping it clicking and going back to idle its like doing 0.1 sec jump then go right back to idle how do i fix it? also when i am in the air and i click again jump its working someone know why? where the code https://paste.mod.gg/inpklfhymvlx/0

polar acorn
white matrix
#

oh its on the controller

#

im gonna send

polar acorn
white matrix
#

wait what happend i closed the animator tab and i try to re open it but its not showing the stuff i had on it you know how to bring it back?
\

polar acorn
white matrix
#

oh nvm btw when i run and jump its working

thorn ginkgo
#

Good evening. I am trying to get my "Last 5 Messages" and its content to be displayed on screen. The first image shows the scene while the game is running and the 2nd image is the game itself. Can anyone give me some thoughts, tips, and tricks to figure this out? I have ensured the Canvas is operating at the highest layer

wintry quarry
thorn ginkgo
wintry quarry
thorn ginkgo
wintry quarry
#

What's going on with this Z position?

thorn ginkgo
#

whoa!

#

changing the z value (manually while game was running) fixed it

#

now I need to see what happened to the z value in the first place

wintry quarry
#

My guess is your code that instantiates them is incorrect

#

Make sure when you instantiate UI elements that you use the Instantiate(prefab, parent); form of Instantiate

#

(with the vertical layout group Transform as the parent)

#

Also make sure the prefab itself doesn't have any weird position values

thorn ginkgo
#

I think I know what happened. I made a typo somewhere when I set those UI elements. Those 5 messages are static GameObjects based off a Prefab

#

I have some dynamically-created ones elsewhere

#

Thank you! My (latest 😉 ) problem is resolved.

shrewd topaz
#

hi

wintry quarry
mild citrus
#

My Pac-Man gets stuck in a loop at the passage. Please help (I tried to screenshot but it didn't show the glitch so I took a pic with my phone)

patent vortex
#

The passages are placed at both sides right?

patent vortex
#

It is obvious that when the character teleport to the other side, trigger the passage and teleport back.
For a quick hack, make the collider smaller + the teleport position far away from the collider

ivory bobcat
# mild citrus

Maybe teleport next to the other portal relative to whichever side you're on

rich adder
radiant voidBOT
hot wadi
#

I got this reference exception
"UnassignedReferenceException: The variable _sphereCollect of CoinMagnet has not been assigned.
You probably need to assign the _sphereCollect variable of the CoinMagnet script in the inspector"
But the only _sphereCollect I have in CoinMagnet class is non-serialized and already assigned
private Collider[] _sphereCollect = new Collider[20];

teal viper
solemn dawn
#

This is far more of a rendering/shader thing than coding, but anyone know where I can ask for help regarding materials, specifically regarding workflows for characters with fur/hair?

timber tide
hot wadi
teal viper
#

It should.

hot wadi
#

Yeah, it threw UnassignedReferenceException somehow

waxen adder
#

So I made a 3rd person character controller, and I wanted to know where you guys put the camera in the player prefab's hierarchy? Right now, I have:
-Prefab Root (completely empty with only a transform)
--Player Object
--Camera

At first I thought about making the camera a child of the player object, but I decided to seperate them in the prefab.

I did this because making the camera a direct child to the player makes it so if you rotate the player, the camera changes position as a child object would. I want the player object to rotate without affecting the camera. Is there any better options? I ask because the Player Object needs access to the Camera and since this whole thing is a prefab, I have to go to the prefab root first and then use GetComponentInChildren from the root. It just seems like a lot and could be done better

patent vortex
hot wadi
waxen adder
#

Time to go toy with cinemachine

naive pawn
fallow ether
#

yo somethings up with my jump

#

it detects if im on ground and all that jazz but when it gets to the actual action of jumping it doesnt do it

keen dew
#

Does it print the log message?

fallow ether
#

yupp

#

it says it gonna jump and then just doesnt

naive pawn
#

is your rb kinematic

#

ah wait it's 3d and you're using velocity

fallow ether
#

yee its 3d

keen dew
#

Either jumpForce is zero or very small or the normal movement code overrides the y velocity

#

Show the entire movement code

#

!code

radiant voidBOT
fallow ether
#

figuring out how to use the posting code thing

#

does this show yall my code?

keen dew
#

What's the value of jumpForce in the inspector?

fallow ether
#

12, heres the full set of values in case ya need it

keen dew
#

rb.AddForce(transform.up * jumpForce, ForceMode.Impulse); this is a bit strange, if you zero out the global Y velocity then this should also use Vector3.up

fallow ether
#

oh sweet that might be the problem

keen dew
#

but that would explain it only if the player orientation is wrong

fallow ether
#

huh

fallow ether
keen dew
#

yes

fallow ether
#

dammit no change

#

at least I know my oreintation is good tho

keen dew
#

Next try to change the jump force to much bigger like 120 or 1000. You multiply all other forces by 10 as well but not this one

fallow ether
#

aight tested the jump force at 50 and 1000 and no change

naive pawn
#

how's the rigidbody set up

fallow ether
naive pawn
#

you've frozen the Y position

fallow ether
#

oh

#

daymn

#

tyyy guys

#

Nitku and Chris, yall have been awesome, love ya!!

tender mirage
#
//Does anyone know how i can apply a enum to equal to a another int? you can do 

//You can do 
int testInt = 1;

enum testEnum += testInt


//But you cant do

enum textEnum = textInt //Error! since it thinks i'm trying to turn enum into a complete int

if (Keyboard.current.rightArrowKey.isPressed)
{
    if (selectedAction < 3)
    {
        //Change action +1
        selectedAction += 1;

    }
    else
    {
        //Wrap back to 0
        selectedAction = 0;

    }

    //Error here
    currentAction = selectedAction;


    print("Right Pressed");

    yield return new WaitForSeconds(pressDelay);

}
#

Oh. Lol.

tender mirage
#

This is just annoying. It would be really nice if i could just swap between enums

sour fulcrum
#

the way enums are ints is not minimal enough for there to be a single expected behaviour from int to enum

gloomy heart
#

currentAction = (testEnum)selectedAction;

sour fulcrum
#

can you give abit of context on what you wanna do here

tender mirage
tender mirage
#

When you press the right or left arrow, and i need to wrap the actions back to eachother

midnight plover
# tender mirage

Actions is an enum, not a method 🙂 So you need to cast your int to (Actions)yourInteger

#

And be sure to give your enum values actual integers attack = 0, and so on. because if you gonna extend them and want to reorder, your integer values are still valid

tender mirage
#

oh wait i did it backwards.

#

🤦

#

Oh my god it works.

gloomy heart
#

actions goes to the inside emptyobj

tender mirage
#

it seems essential for everyday use

midnight plover
tender mirage
#

ahh yeah it's like a reversal cast

#

i get it.

#

I have not touched casting at all. and this is what happens when you're unfamiliar with it. Glad there are some experienced people here that know their stuff xD

sudden cypress
#

Hi guys

gloomy heart
#

yo

sudden cypress
#

Hows it going

#

May I ask something

hexed terrace
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

sudden cypress
#

Ohh that interesting

#

I guess ill ask sometime else when I get screenshots XD

hexed terrace
#

and make sure to use the right channel, this is a code channel

sudden cypress
#

Yes I get that

hexed terrace
#

a hell of a lot of people dom't 😬

sudden cypress
#

Meanwhile could you tell me , is it possible to make realistic water in unity using code , like simulation of physics and stuff

#

If i walk into it , the waves like dislocate

verbal dome
sudden cypress
#

Idk how to frame the question

#

Its like going inside a pool

#

And you see water displaces

hexed terrace
sudden cypress
hexed terrace
sudden cypress
#

Sorry

#

I didnt know it was shader based only

hexed terrace
#

tis np, was just an FYI

gloomy heart
hexed terrace
#

there's no render pipeline called basic - I assume you mean URP?

sudden cypress
#

Ah not that, 3d something , the first one

gloomy heart
#

oh, the built in one?

verbal dome
#

Built in render pipeline

sudden cypress
#

Yes that one

hexed terrace
#

Built-in RP, the old one that is slowly becomming redundant

sudden cypress
#

I chose that one cause i thought it would be easier

hexed terrace
#

There are shaders that do what you want for that

sudden cypress
#

Also cause i thought it would be better to run

#

Oh nice , I see

verbal dome
elder canyon
#

Vector2 lookInput = inputSystemActions.Player.Look.ReadValue<Vector2>();

I think lookInput is framerate independent? So we dont need to multiply deltaTime with this right?

keen dew
#

Mouse and controller stick input is framerate independent, yes

naive pawn
crisp quest
midnight plover
real thunder
#

I got a classic issue "weapon fov is not the same as real weapon fov" while shooting projectiles (and honestly while making bullet trails too)
Is there an equasion I should use to shift an actual shooting point (it's non multiplayer fps so I don't think there would be issues) so it looks valid from first person perspective with low fov of a weapon? Or there are better solutions?

crisp quest
naive pawn
#

@crisp quest please do not

#

we do not need bullshit spam

crisp quest
real thunder
naive pawn
#

they aren't errors anyways

#

they're just warnings

#

you could ignore them

#

it's internal too, not your own code

#

you could try a library reset if you think it might be mismatched versions

#

but i'd guess VS is just picking up warnings from places it shouldn't

real thunder
naive pawn
#

maybe you just opened an internal file and VS started analyzing

naive pawn
naive pawn
#

they're all internal, so you can't fix them anyways

crisp quest
naive pawn
#

you could, but they could be obscuring warnings related to your own code

#

what did you do when they started showing up

#

is your ide configured properly

crisp quest
naive pawn
#

do they show up again if you restart vs

crisp quest
crisp quest
#

VS just got updated and now it is fine

#

there was an update pending , i guess that was the reason

real thunder
#

what was that attribute for a method so you can call it from the editor any time?

real thunder
#

yeah first one thanks

tribal fulcrum
#

can someone help me? im trying to reference another script in a script and im getting the error "The type or namespace name 'PlayerMovement' could not be found (are you missing a using directive or an assembly reference?)"

#

i have a script named PlayerMovement so idk why its not working

gloomy heart
#

Use the exact class name and if its under any other namespace add it using <namesoace name>;

tribal fulcrum
#

oh i just found it, my class was named playerMovement

#

thank you

graceful abyss
#

Hello, I have an issue to change the game resolution in HDRP

#

I tried to write a post in unity's forums, but, I'm not sure people go in there ^^"

#

Basically, calling Screen.SetResolution might cause crashes or freezes

#

I'm using Unity 2022.3.62f2. And I managed to reproduce the issue in the HDRP sample project without changing its settings (apart from adding the scene I made).

#

--> Hence the following questions: Is it a known issue ? Is there any workaround ?

naive pawn
#

!code

radiant voidBOT
graceful abyss
slim solar
#

Hey guys I have a built in project I wanna change to URP. I have a massive built-in particle pack

#

I can't remember, is it reliable to convert all shaders to URP?

#

I remember that feature existing but not actually working for 90% of them
Edit: wrong channel my mistake

frail hawk
#

how is that related to coding?

wintry quarry
slim solar
#

Oh shit my bad lol, thought it was a diff channel

empty cairn
#

I am trying to make a teleport script but the player stops at the first wall because of the Rigidbody, how do I still get it to teleport? (I've tried setting it to kinematic before the teleport and then back but that didn't work)

slender nymph
#

show relevant code. because it doesn't sound like you are actually teleporting it

wintry quarry
#

rb.position = newPosition;

naive pawn
#

you kinda can't not use it

#

the first O in OOP is "object"

#

this covers classes and structs in c#, along with the native classes and structs in c++ land

polar acorn
#

C# is strictly object-oriented

naive pawn
#

c#'s object type and unity's own UnityEngine.Object should also give some hints

obtuse ether
#

im trying to make a basic sword thing for my game and to get it to point forward i have a child object with the texture at rotation -45, but for the animation to work, im trying to set the rotation on the Z axis back to 0, then after some time reset the Z axis rotation to -45 again, how would i go abt doing this?

#

i tried changing the transform.up and even tho it does change the rotation, it does it weird and not at the specific rotations i want it to set to

naive pawn
#

!code

radiant voidBOT
obtuse ether
wintry quarry
wintry quarry
obtuse ether
wintry quarry
#

sure, that's a direction pointing 45 degrees up/right

obtuse ether
#

Yeah the thing is it ends up looking really scuffed

#

i dont know why its doing that since its not the gameobject being rotated torwards the camera

wintry quarry
#

first off you probably want to be modifying the localRotation of this thing, not world space stuff.

#

.up is a world space thing

wintry quarry
#

you do myObject.localRotation = <some quaternion> or myObject.localEulerAngles = <some euler angle vector>

obtuse ether
ionic sorrel
#

Is there a place where I can look over certain terms and variables and stuff and see what they mean?

slender nymph
#

!api

radiant voidBOT
slender nymph
#

!docs

radiant voidBOT
slender nymph
#

i could've swore there was a separate api command. oh well.
anyway @ionic sorrel the api documentation sounds like what you are looking for ☝️

ionic sorrel
strong wren
true crown
#

im gonna guess yes, gimme a sec to do that

#

done

obsidian grove
#

is there a way to make the editor (not build) open a specific scene when you first open it? (instead of most recently open scene)?

midnight plover
humble summit
#

hello this might not be the right channel but maybe it is. i have this mixamo animation

#

where the guy runs

#

but the end of the animation always resets back into the starting position even when i loop

#

do i have to write a script in order for it not to go back to starting point?

naive pawn
soft lotus
#

Can someone please help me get Depth of Field working in my 2D game? I thought switching to orthographic camera would help, but it seel doesnt really work?

#

The frontmost sprite shouldnt look blurred at all, changing the settings in the effect itself doesnt help that

#

Here's how it looks without depth of field

soft lotus
#

I checked the manual, but it didn't have anything about 2d as far as i've read

fickle plume
#

Check the different modes and play around with distance options. 2d objects like sprites also can be positioned at different distance from camera in 3d space and probably are a subject to this post processing effect

soft lotus
#

I think it's the issue with how 2D stuff is handles specifically, i tried adding a 3d cube, and it worked fine on that one

#

the modes & settings don't change much, all the 2d sprites appear equally blurred regardless of Z distance

fickle plume
#

Alternatively you can render different distances with another camera. Because effect does work just doesn't seem to respond to distance. (to have another post-processing volume applied to it)

soft lotus
#

this feels like something that should be easily fixible, but i can't find anything. Most of questions/posts asking the same thing are either super old, or dont lead anywhere

#

and i doubt it's an uncommon problem? quite a few 2D games use depth of field

fickle plume
kindred plume
#

"elementaddermenucommandattribute" could not be found and idrk how to fix this

#

theres the full console log

#

same for this too

#

the return part

hexed terrace
#

if you're not using visual scripting, remove the package

kindred plume
gloomy heart
#

using UnityEditor;

hexed terrace
kindred plume
#

found it in

#

"in project"

#

in package manager

hexed terrace
#

yep

kindred plume
#

alright, cool thanks, works all good

#

thank you

azure tide
#

Can anyone recommend good tutorials that are like "Follow along as I break down this idea?". Most tutorials are usually predetermined about the approach and final result, but I'm looking for something where I can really get into the mindset of "Here's the problem and here's how I would approach it"

sour fulcrum
#

It's abit high level but sebastian lagues ideos might scratch that itch

azure tide
#

I'll check it out but can you think of anything more specific? I'm quite new to C# but am comfortable with python and tech art in maya. I'm just trying to translate that line of thinking/approach to unity and C#

sour fulcrum
#

Honestly not too much I know of that fills that demographic, I wish there was a lot more

keen dew
#

You're unlikely to find beginner level tutorials that are like that because any experienced Unity coder wouldn't have a problem with implementing basic stuff

#

Devlogs or VODs of devs who stream their work might be the closest

azure tide
#

I'm not necessarily looking for beginner level (I realize I posted this in the code-beginner channel 😅 ) . I'm fairly comfortable working as an artist in unity but am just finally getting into c#

fickle plume
rough granite
azure tide
fickle plume
#

He has additional notes on the process as well and there's a lot of insights into coding technique and tooling as well.

#

I would recommend his Hex Map tutorial just for learning coding even.

azure tide
#

I'll start there then, thanks again!

slow viper
#

I was tying to make on sprite the litle robot appear in midle of the dialog but i evean wont start the dialog can someone help me with it?

naive pawn
#

that's not much context to go off of

hard warren
#

are await on async same as coroutine?

slow viper
#

will send you code

naive pawn
#

they can fulfill the same needs or solve the same issues, but they aren't the same, no.

slow viper
naive pawn
hard warren
slow viper
#

the isue is that when i am trying to activate the diualog it wont activate

naive pawn
slow viper
#

i was trying to activate sprite when some line will be activated and trurn off the sprite when the achive other line

naive pawn
#

you aren't giving dialogueManager any info, so i'd guess that you're reaching that point fine, but then dialogueManager just.. doesn't have anything to work with

#

but you'll have to debug to confirm that

slow viper
#

ok i will debug it

#

ohhhh

#

it dosent shos the UI

#

this is the problem

hard warren
#

are you guys using Coroutine or Awaitable?

#

which one do you guys recommend?

naive pawn
#

im using coroutines, haven't had a reason to use others yet

gloomy heart
#

coroutines

naive pawn
#

there is also another, unitasks

#

if coroutines aren't feeling great to use, then try out the alternatives

#

decide for yourself

hard warren
#

ok thx

proper tinsel
#

Hey! Does UI toolkit world space support events? Trying to add an eventlistener like this Head.RegisterCallback<ClickEvent>(ev => HandlePlayerClick());
But it doesnt seem to register clicks.
Works in my other UIdocument which isnt world space.

proper tinsel
ionic sorrel
#

I may need some help with some of my code, would anyone here be willing to help me a bit?

naive pawn
#

!ask

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

naive pawn
#

people are, for the most part, not going to agree to help without even knowing what you need help with

ionic sorrel
#

Well if that is the case... Then I'll say it. I am trying to program platforming in my project. It works for the most part... But with the jumping mechanic I implemented, it is allowing the player to jump infinitely... Even while in the air.

#

I'm not sure how to fix this.

naive pawn
#

well first off, you haven't saved in that screenshot

#

also your ide is not configured

#

!ide

radiant voidBOT
naive pawn
#

anyways, the issue is that a || b && c is the same as a || (b && c) due to operator precedence.

#

you'll need some parens.

ionic sorrel
ionic sorrel
naive pawn
#

parentheses

ionic sorrel
naive pawn
#

"parens" is a common abbreviation, typing the whole thing out gets pretty tiring lol

ionic sorrel
naive pawn
#

you might also see "semis" for semicolons

ionic sorrel
#

Sorry about all of this... I'm very new FriskCry

tender mirage
ionic sorrel
frail hawk
#

just use ( ) to group

naive pawn
gloomy heart
#

impossible

slow viper
wintry quarry
slow viper
#

yes

wintry quarry
#

so what's wrong with it exactly?

#

looks like 42, not 39

ionic sorrel
naive pawn
#

do you know what 1 + 2 * 3 is (im expecting you do)

slow viper
# wintry quarry looks like 42, not 39

It has a robot sprite that is supposed to turn on on line 18 and turn off on line 42 but when I put it there it doesn't deactivate when I put a shutdown number below 40 it turns off fine but otherwise the dialogue has 45 lines

frail hawk
gloomy heart
naive pawn
#

how do you even get 6 there

#

the wrong answer is 9

gloomy heart
#

3*3 =6

slow viper
naive pawn
rough granite
#

3 + 3 is 6

wintry quarry
#

it starts on line 13 and ends on line 52. 52 - 13 is 39

naive pawn
wintry quarry
#

so when you put a number higher than the actual number of dialogue elements, yeah it never reaches that number so it will never shut off

polar acorn
wintry quarry
slow viper
#

sorry for waisting time

wintry quarry
naive pawn
#

your ide can also tell you how many lines there are if you select them all

wintry quarry
#

use npcDialogue.Length where needed

#

instead of a magic number

polar acorn
slow viper
polar acorn
# gloomy heart oh

There's not different ways to do order of operations. Math is math. Whatever you call it the order of operations is absolute

#

No, there is no "it depends". There's the order of operations, then there's incorrect math

ionic sorrel
frail hawk
#

the 2 inputs

#

you still haven´t solved it yet? i thought you were kidding

ionic sorrel
frail hawk
#

if ((input1 || input2) && isgrounded)

ionic sorrel
naive pawn
#

* is multiplication here

#

god i don't have the patience for this

#

it's 7, and it's not 9 because you do the * before the +

#

that's what operator precedence is

#

you do && before ||

#

but you can change that with parens

gloomy heart
#

|| is for either of statement is true and && is for both to be true

mild furnace
#

Anyone found a way to disable this extra 'Unity Serialized Field' text that appeared after latest vscode extension updates?
Theres a lot of unnecessary text on my screen now above every variable and method.
I do like to keep the number of references though

gloomy heart
#

there is no direct setting for that ithink

mild furnace
#

🤮 at least they fixed some of the performance issues.
I had to literally close vscode any time I wanted to compile or enter play mode, otherwise 30+ second wait

#

now its fine, but this text is really hard to ignore

naive pawn