#šŸ’»ā”ƒcode-beginner

1 messages Ā· Page 604 of 1

thin stream
split ginkgo
#

but i think i will get @rich adder 's Suggestion

rich adder
#

show the inspector

thin stream
#

ooh wait

rich adder
#

so its empty

#

no wonder it returns null

cosmic dagger
thin stream
#

do i need to add it add every scene?

#

i mean the code?

rich adder
#

unless you put it on a DDOL

split ginkgo
#

and thats theonly thing i need

thin stream
cosmic dagger
rich adder
thin stream
#

Alright but i gonna do oldskool way just put it on every scene way easier for me

rich adder
#

ok

thin stream
rich adder
#

what do you expect here

thin stream
#

they double spawn

rich adder
#

I see that

thin stream
#

but wanted to only get one

rich adder
#

so make it get one?

thin stream
#

how?

#

i added the prefabs and then this happend

rich adder
#

do you have two of them now?

#

PlayerManager

thin stream
#

nowp only 1

rich adder
#

so then look careful whats happening

#

You see whats already in the scene vs whats being spawned by line 22?

thin stream
#

yea this line : GameObject player = Instantiate(playerPrefabs[CharachterIndex], lastCheckPointPos, Quaternion.identity);

#

its normal the mean intention to spawn 1 so thats good enough

rich adder
#

yes that would be the spawning line

#

exactly its doing what you coded it to do

#

now it doesnt error so its working

thin stream
#

yep but how come their are 2?

rich adder
#

you didn't notice whats inside the scene before you hit play?

thin stream
#

:oo waitt

#

ty for remind to check that i was focussing on the console

#

but how do i add the function DDOL

#

where to?

#

to charachter Selection? or?

rich adder
thin stream
#

cause the selection menu is not working yet

#

yea but thing is if i add manager each scene they spawn also and that is not the intention

#

look wait

#

i gonna show what i mean

rich adder
#

game manager being DDOL make no difference in your current issue

thin stream
#

is that possible?

rich adder
#

whats possible?

thin stream
rich adder
thin stream
#

but the thing is on that menu their no players only the charachters

thin stream
rich adder
honest vault
#

Where do I ask if I want to join someone on a project or smthn

rich adder
#

as long as the index matches selection to the one saved in PlayerPrefab

thin stream
#

Okayy

rich adder
# thin stream Okayy

the Player Manager just needs to have the same list order / amount. The only difference now is Player is Spawned in, so anything in the scene doesnt have direct reference to the player that was in the scene when it started.
You'd need to inject or FindByTag or Component or singleton

rich adder
eternal falconBOT
#

:loudspeaker: Collaborating and Job Posting

We do not accept job or collab posts on Discord.
Please, use Discussions to promote yourself as job-seeking, advertise commercial job offers, or look for non-commercial projects to participate in:
• Collaboration & Jobs

rich adder
#

also you should provide that info without me having to ask.. its kinda of. waste of time having to extract info eevery time

thin stream
#

The errors are just screen overlays i dont have rn, but the charachter selection dont work like you see

edgy sand
#

I have returned! After changing my grid over to a set of images I'm trying to get the specific image hit to put my card object into. This is the snippit of code that I'm using for PointerUp

public void OnPointerUp(PointerEventData eventData)
{
    if (currentState == 2)
    {
        GameObject hit = eventData.pointerCurrentRaycast.gameObject;
        GridCell cell = hit.GetComponent<GridCell>();

        if (cell != null)
        {
            Vector2 targetPos = cell.gridIndex;
            if (gridManager.AddObjectToGrid(gameObject, targetPos))
            {
                if (handManager != null)
                {
                    handManager.cardsInHand.Remove(gameObject);
                    handManager.UpdateHandVisuals();
                }
                else
                {
                    Debug.LogWarning("HandManager not found!");
                }

                Destroy(gameObject);
            }
        }
        else
        {
            Debug.LogWarning("GridCell not found on the hit object or its parents!");
        }

        // Transition to state 0
        TransitionToState0();
    }
}
```and it's throwing this error (image 1) however the grid cell script is attached to my box prefab (image 2)
rich adder
thin stream
#

I just added the player Manager to everyscene. but yea like you see no works

rich adder
#

why did you add it to character selection scene?

#

obviously you spawning a player on awake in the character selection sceene makes no sense

#

so there is absolutely no reason to even have player manager there

thin stream
#

maybe it would work but it doesnt & now i know why bcs it doesnt have to be there, but yea the button need to select the charachter but the thing is it doesnt

thin stream
rich adder
thin stream
#

agree

rich adder
#

you can't just guess your way through things, you have to be deliberate in what you do..

rich adder
thin stream
rich adder
#

have no idea why you keep sending the same script over and over

thin stream
#

huh

rich adder
#

why do you keep sending PlayerManager

#

I already know what it does.

thin stream
#

the thing is it is because it was on the samelink

rich adder
#

I get it they're in different tabs

thin stream
#

indeed

rich adder
#

no idea how those relate to what the issue is

#

do you even know what half your code is doing?

thin stream
#

yep

rich adder
#

well if you did how come you don't know where the problem is ?

thin stream
#

thats just the problem, everything is alright in my codes but when i press play it doesnt work

rich adder
#

"it doesnt work"

#

what does that even mean

#

if you think everything is alright in the code, why do you keep insiting its the code and sending me code?

thin stream
#

the game etc does work only the character selection menu doesnt oh maybe here i have to look

rich adder
thin stream
#

nvm i will look it out of my own, player manager is not anymore in it

rich adder
#

very simple :

  1. either player manager can exist in all scenes but not spawn player in AWAKE but use an explicit method, possibly listening for scene changes / reading specific scene name
  2. Playermanager only exists in play scenes and nothing more.
thin stream
#

ok

edgy sand
#

ok so for my thing, hit.name returns "Image"

rich adder
edgy sand
#

by name alone, nothing

#

however what I'm trying to hit is an image, it doesn't have the name image though

#

ope

#

wait

rich adder
#

Do you have an image as a cursor ? it could be hitting itself

edgy sand
#

found it, and the problem does make sense

#

let me try something real quick

#

ok figured it out, now to find the solution. I'm trying to drag and drop an image onto another image (probably stupid I know) and it's hitting the upper image, the card

#

is the best solution just turn off raycast target on all of my card images?

rich adder
#

i find easier to also just use Canvas group for that as well

edgy sand
#

I actually am using multiple canvases

rich adder
#

but also helps easily disable raycast target on it and its children

edgy sand
#

hmm so do I put that in a script on the canvas?

#

and then just call it when I pick up the card?

#

because I do have on hovers

rich adder
#

nah just put that on the item you want to disable

#

so any draggable item

edgy sand
#

for reference this is the heirarchy of a card

#

(centerimage was previously just Image)

rich adder
#

each card have their own canvas?

edgy sand
#

yup

rich adder
#

whys that

edgy sand
#

at the time it seemed like the simplest way to handle everything, and also what a tutorial recommended

rich adder
#

so if you spawn 50 cards you have 50 canvases , thats a lot of canvases

edgy sand
#

I'm quite new so I don't know everything possible

edgy sand
rich adder
#

I would keep a Card canvas but not have one nested in each prefab

edgy sand
#

actually I guess 21 canvases would be the max possible, forgot about player 2

rich adder
#

each canvas per card might complicate what you're doing even further

#

UI is very picky

edgy sand
#

I figured that out lol, my last post here was to figure out how to interact with non-ui elements and had to recode a bunch of stuff

thin stream
edgy sand
rich adder
thin stream
#

SelectedCharachter & CharcterSelected

#

in player & charachter selection script

edgy sand
#

btw dylan you're misspelling character

rich adder
edgy sand
#

it's hurting my soul lol

thin stream
rich adder
#

it would not throw a null reference

#

video you showed, you still had error on line 22 because the one on char selection screen didnt have its fields populated like the other scene

thin stream
#

but also in charachter script was it this : PlayerPrefs.SetInt("SelectedCharacter", selectedCharachter); instead of PlayerPrefs.SetInt("SelectedCharacter", selectedCharachter); so yeah idk something small i guess but found it thats important

rich adder
#

also another reason not to use string like this and use a const / static key

thin stream
#

indeed

#

now i can go further with the progress šŸ™‚

edgy sand
#

small update before I inevitably come back later: got the canvasgroup to work to disable the raycast blocking, now the cards at least attempt to go to the right spot (numbers are wrong, gotta fix those) and all I have to do is turn the raycast blocking back on after I drop it down and it doesn't go in the right spot

earnest wind
#

how can i make so that if parent has different scale than (1,1,1) the children with rigidbody act normal?

#

because when they fall and rotate they kinda become bigger/smaller?

void thicket
#

By not having parent with non uniform scale

earnest wind
#

im making a text system and i want to be able to scale the parent and it scales the whole text

#

im gonna have to recalculate letter positions and all?? 😵

void thicket
#

Why would your text system involve rigidbody

earnest wind
void thicket
#

What

rich ice
earnest wind
#

what

#

its my own 3d text system

void thicket
#

That doesn’t explain anything

earnest wind
void thicket
#

And they are going to interact with physics?

earnest wind
#

they already do, and it works well

void thicket
earnest wind
#

but once u scale the parent, it all breaks down

earnest wind
rich ice
#

im incredibly confused by what you're doing. but, try one of these

void thicket
#

And scale

earnest wind
# void thicket And scale

maybe it would be possible to first instantiate in the parent, and then unparent it, so that it already keeps all the scale, rotations?

earnest wind
void thicket
earnest wind
#

okay i will try and see if i could scale up each individual letter instead of the parent, and calculate it so its all together centered

hot harbor
#

why does the var on the left hand side not get garbage collected if monobehaviour is destroyed? I thought gc takes care of this

#

Or is this a renderTexture only kind of thing

brave compass
hot harbor
#

Maybe I'm confusing the meaning

void thicket
#

Afaik it should be called if enumerator is properly disposed

timber tide
#

I dont understand this. What if you stop the coroutine, will the object not be garbage colelcted?

timber tide
#

Does unity not check for unused dependencies when these objects are destroyed

hot harbor
#

Before async was introduced in Unity 2017, asynchronous routines were implemented using coroutines and/or callbacks. This video covers the benefits of async over coroutines. You'll see how one example problem – building an asynchronous prompt popup – can be solved using async vs coroutines.

Speaker:
Johannes Ahvenniemi - Seriously Digital Enter...

ā–¶ Play video
void thicket
brave compass
# hot harbor Are unityEngine.Object classes not considered C# classes?

Classes that inherit UnityEngine.Object have two representations, managed and native. Both reference each other. The native object can be destroyed without the managed class being garbage collected, like when you keep a reference to a game object even though it's destroyed. Similarly, the managed class instance can be garbage collected, but the native object still exists in memory.

timber tide
#

Is that intended? It's not like the texture exists on the scene, so how else would you actually reference it?

hot harbor
#

Also where can I learn more about this type of quirks, or do I have to trip and fall before encountering them

brave compass
void thicket
brave compass
# hot harbor So when I have a nullreference exception due to destroyed gameObject, it actuall...

Yes, Unity is faking a NullReferenceException in that scenario. You're still referencing a valid C# object, because it's not possible to "destroy" a C# object that is still referenced. That's just not something the runtime is capable of. So Unity does the next best thing and throws a NullReferenceException if you attempt to access anything on a GameObject class reference which has been destroyed.

hot harbor
brave compass
#

Unity is also overriding the obj == null check to return true for destroyed instances, because again, C# objects that are still referenced somewhere cannot be destroyed.

swift crag
#

I was really baffled by that for a while

timber tide
#

I guess this is more of a special case too because of having to release the texture so ok it does make sense. I wouldn't be creating them inside of the coroutine anyway

brave compass
#

The screenshot you shared isn't really talking about this, btw. It's referring to the fact that a finally block in a coroutine will not be called if the coroutine is stopped early. So even though the coroutine attempts to do the right thing and release the texture, it will be unable to.

void thicket
timber tide
#

Yeah, the async operation is actually way different in that it still runs which is a behaviour you usually don't want from gameobject routines

hot harbor
swift crag
#

you just stop calling MoveNext() on the enumerator object

hot harbor
#

I was reading some of the unity forums about when to use Coroutines, and one of the answers I found was that "if you have to stop a coroutine you don't need one", and now I'm slightly more confused about when to even use async

void thicket
#

Disposing IEnumerator should call whatever in finally I believe, but Unity might just not doing that UnityChanThink

timber tide
#

I mean, I always stop coroutine/tweens when I want to stop it mid-way from lerping to its location

void thicket
swift crag
wintry dew
#

Hello, I would like to ask if there is a better way to find a collision between a CharacterController and a Sphere Collider, because this won't work when I test it out!

hot harbor
#

Also had an animator component specific question: I wanted to check for animation completion after playing an animation in a coroutine, but I think that the animator only starts playing on the next frame(from what I've tested so far), so I can't sequentially do

_animator.Play(animation);
// My working solution is to yield return null to wait a frame before checking but that seems hacky
if (_animator is playing) {
  check animCompletion // I have to check specifically what animation is being played or else this does not work
}
timber tide
#

I usually just rely on the statemachine I make and not what the animator is currently doing

wintry dew
#

hmm so do i need a rigidbody for the sphere?

#

only if i want to push it ig

void thicket
#

You put rigidbody for whatever dynamic physics body

wintry dew
#

is there way to make trigger happen without an active Move() being called?

void thicket
wintry dew
#

alright

#

oh mb

void thicket
#

But in what case you can’t call Move

wintry dew
#

i just mean if the character is falling onto it

#

wait ig theres auto gravity move being called so

#

yeah ig it works i just dont want it to be buggy

#

Would the script have to be on the characterController or on the sphere if i were to detect a hit?

void thicket
drowsy helm
#

Is it more common to use git or the build in unity vc?

barren plume
#

Im trying to create my own game through unity itd be like a 2d platformer basically a cheaper version of undertale with a different theme Ive never used unity how cooked am I

timber tide
#

have you made flabby birb yet

teal viper
atomic hatch
#

I need to swap parent of my weapons between a few different bones on my characters rig.

Is it true that the only way to find these bones is a runtime search?
I read that i cannot serialize Transforms

toxic frigate
#

hello everyone, i have some code here:

float scroll = Input.GetAxis("Mouse ScrollWheel");
if (scroll != 0)
            {
                Debug.Log("scrolled");
                Vector3 scrollPos = transform.position;
                scrollPos.y -= scroll * scrollSpeed * 100f * Time.deltaTime;
                scrollPos.y = Mathf.Clamp(scrollPos.y, minY, maxY);
                transform.position = scrollPos;
            }

which should move the camera up and down when scrolled, however there is zero change, the debug log is printed and the scrollSpeed is set to 300 but it still doesnt work, anyone know why?

summer thorn
#

Are structs just PODs?

teal viper
void thicket
teal viper
steep hollow
#

how do make a bool in a code and say if its true do a thing in another code?

#

do i*

teal viper
teal viper
steep hollow
summer thorn
ivory bobcat
steep hollow
#

how do i reference it?

#

is it like how i reference commponents?

ivory bobcat
#

Go over the basics from !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

Over 750 hours of free live and on-demand learning content for all levels of experience!

steep hollow
#

ok

teal viper
#

Structs can have methods and properties if that's what you're asking.

void thicket
#

How can POD mean Dictionary

teal viper
#

I guess what they meant is "plain old data" or something

summer thorn
#

What can a struct do that a dictionary can't or vice versa?

slender nymph
#

struct is how you define a value type object. dictionaries are collections of key value pairs, they really aren't the same at all

void thicket
teal viper
void thicket
#

Let me guess, Python

summer thorn
summer thorn
#

I don't see any difference, what can a struct do that a dictionary can't?

summer thorn
teal viper
slender nymph
tawdry quest
#

what am i reading

teal viper
void thicket
#

And much more

summer thorn
slender nymph
#

lua is a silly language where everything is a table for no reason. c# is not the same at all

void thicket
#

okay it was Lua, not Python

summer thorn
void thicket
#

int is value type for starter

teal viper
# summer thorn Actually everything is in lua But are you saying a struct is just a dictionary t...

No. I'm saying that they are completely different data types.
There's an actual physical difference in how they are laid out in memory. Structs are defined at compile time. You can't add new members to the struct at runtime, because it's a contiguous block of memory. Dictionaries are not a contiguous block of memory. I don't know how exactly they work under the hood, but it's probably 2 arrays with keys and values. So they are potentially placed randomly in memory. You can add elements to the dictionary at runtime.

summer thorn
slender nymph
#

strings are reference types but they are immutable

summer thorn
void thicket
summer thorn
teal viper
void thicket
atomic hatch
teal viper
teal viper
#

You can assign a transform of a prefab root to a scriptable object. It's not gonna help in your case though.

wanton epoch
#

Would any one have a tutorial on any chance about how to do enemy pathfinding and player detection for a 2d platformer? Most gudies im watching arent that good or are top down.

drifting cosmos
wanton epoch
# drifting cosmos a platfomer would be pretty easy i think

Im pretty new to unity and C# so im learning things as im going. Im trying to do my first enemy and the last things Im missing are:

  1. Pathfinding where I can draw a custom path for them to follow left and right.

  2. Player detection where if the player gets in range they will attack.

  3. The attack of my enemy is long range so I have to figure out how to do the projectile and put the animation on the projectile n stuff.

drifting cosmos
wanton epoch
#

never heard of that. Im currently trying to use something called A* pathfinder

drifting cosmos
#

can your enemies go up or jump or anything

wanton epoch
#

I have it set in my code that if an enemy comes across a wall (and its jump force allows it), they will jump and continue walking.

#

I just havent figured out so how to draw my left and right custom paths for each enemy that I want

drifting cosmos
wanton epoch
#

yea i thought about keeping them stationnary until they see the player but i kinda want them to have "patrol paths" where they just go back n forth in

drifting cosmos
#

well if they chase your character to a different area would those paths work

#

or would they go back

wanton epoch
#

I would it set so that as soon as they see an enemy, they leave theri path and 100% focus the enemy and chase him

#

like it will override their paths

drifting cosmos
#

yeah will they chase forever or when you get out of range will they stop? or go back?

wanton epoch
#

forever

barren plume
drifting cosmos
wanton epoch
#

nope Ai pathfinding

#

but I can write a custom ai script

drifting cosmos
# wanton epoch nope Ai pathfinding

idk i guess set 2 points maybe with in a range and then have it set to go to point a and when it reaches go to point b and so forth when not in chase

wanton epoch
#

yea I guess that could work

#

ill try that out

barren plume
#

And also what languages are valid in unity

barren plume
late burrow
#

can i make static indexer property

teal viper
late burrow
#

or perhaps i show off issue i want to deal with

#

this is what i tend to use for most classes i use now if i do array stuff in them thing is serializing it duplicates names, both for dictionary and thing it holds inside, that why i wanted make my sub class accessible by indexer so i wont have need for dictionary

    {
        public static Dictionary<string, class2> easyaccesstoclass2;
        public class class2
        {
            public string name;
        }
        void add(string name)
        {
            easyaccesstoclass2.Add(name, new class2 { name = name });
        }
    }```
rich ice
#

remember to put cs after the ``` when posting !code

eternal falconBOT
teal viper
late burrow
#

i want access sub class by string without dictionary

#

back to simplified messages

teal viper
void thicket
stray thorn
rich adder
stray thorn
#

still dosent work

#

i did this same script on another script and it worked well but this time i rotated my gun 180 degrees to it faces away from the cam and had to rotate the gun tip so it dosent shoot bullets at me u think that might be the problem?

#

another project*

rich adder
#

check gunTip rotation is probably wrong

stray thorn
#

its 180 but when i change it it starts shooting bullets straight back at me instead of away

rich adder
#

whats it look like in the scene gizmo though in local space mode?

void thicket
stray thorn
wanton epoch
#

I would love some people's suggestion on the issues I am encountering for my enemy script.

  1. I cant for the life of me figure out how to make it so that my enemy goes back and forth for his path. He goes in the direction of the point but when he reaches it, he just continues walking in that direction and not go back to the original path.

  2. My sprite isnt flipping for the direction my enemy is walking along is path.

  3. I want to make it so that, if the enemy is going along his path, it will play their walking animation, the problem is that it spams the walking animation non-stop.

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

drifting cosmos
wanton epoch
wanton epoch
#

which Ig is an upgrade from jsut consistenly looking left

drifting cosmos
#

well in patrol or whatever wouldnt you only flip when it swaps objective

#

and in chase subtract player position from enemy position and if its negative or whatever go a certain way

#

idk how the map on unity works tho

wanton epoch
#

hmm maybe that is true. But the problem is that, in the picture you can see, the first point is the left one and the second one is the final one. Its moving to the second one while looking to the left. Also, the issue is that it doesnt go back to the first one, it just keeps going right.

#

I have these 2 problems to fix and its killing me

drifting cosmos
wanton epoch
#

sure let me try

drifting cosmos
#

if its facing the wrong way

wanton epoch
#

WAIT IM DUMB AF

#

I KNOW WHY ITS INVERSED

#

i set the isFacingRight = true as the base value

#

when my sprite is originally facing left.

#

god im dumb

#

welp that only leaves my not going back n forth issue

drifting cosmos
#

ok

#

so does your game have levels

wanton epoch
#

yes 3

#
  1. for the first leve
#
  1. for the transition level
#
  1. for the final level with the boss
drifting cosmos
#

is it possible the walk code still runs if theres no objective

wanton epoch
#

let me tryu

#

my path is just a dot

#

yep he does

drifting cosmos
#

well if hes not chasing the player or patrolling why would he

wanton epoch
#

that is very true ig i didnt test that.

drifting cosmos
#

what if

#

you place the objective to the left

#

you sure he wont just go right

wanton epoch
#

huh?

drifting cosmos
#

well has it been following the path at all

wanton epoch
#

it seems not, it just seems to walk to the right infinetly

drifting cosmos
#

or just going right on start

wanton epoch
#

let me try with no path

#

with no point, he just stands still

#

as soon as I assign a point, he just starts walking right

#

no matter what

drifting cosmos
#

well you need to compare the enemys position to the objective point

#

i think you just start run and it keeps running

wanton epoch
#

Yea ill have to try that. ill do that now.

ruby python
#

Mornin' all,

Having something of an issue which is confusing the p*ss out of me.

I'm trying to grab something from an object pool, but for some reason it just won't grab the object and I can't see why (this exact same script works absolutely fine in another project I was playing with just yesterday). So I'm at a bit of a loss as to what I'm missing.

using UnityEngine;

public class TunnelManager : MonoBehaviour
{
    float tunnelOffset;
    [SerializeField] ObjectPoolManager tunnelObjectPoolManager;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        tunnelOffset = 20;
        GameObject newTunnelSection = tunnelObjectPoolManager.GetPooledObject();
        newTunnelSection.transform.position = new Vector3(0, 0, tunnelOffset);
    }
}

This is what's calling the object.

And this is the object pool script.

https://hastebin.com/share/laracojibi.csharp

And here is everything populated as it should be.

So I'm very confused. (Probably missing something really obvious, but could someone take a look and point me in the right direction please?

drifting cosmos
#

why do you need to get the object

ruby python
#

Okay, now I'm really confused, the debug here is saying the count for PooledObjectList is 0, but in the inspector is fully populated. Absolutely baffled. lol.

drifting cosmos
#

isnt it set to 0

ruby python
drifting cosmos
#

like you create a set number and then disable them all and enable and disable when you need to

ruby python
# drifting cosmos i thought you enabled and disabled them in an object pool

Yes you do, that's the idea, but for some reason it's not finding anything in the list in the object pool object.

The 0 that you can see in the console is a Debug for "pooledObjectList.count" but it's returning 0 (saying there are no entries in the list. But on the right in the inspector, the list has 15 entires as it should.

drifting cosmos
#

or is it idk

ruby python
#

It all gets setup on start. It's really confusing because like I said I was using the exact script/system yesterday. I literally copied/pasted the script into this project. lol.

drifting cosmos
ruby python
drifting cosmos
#

can you get an instance of a disabled object?

#

thats all ive got i dont know if you can like compare this project and your other one

ruby python
#

That's why they get put in the list. Reference the list, tell it to turn on that object. I know it works, I was using it for bullets yesterday.

void thicket
#

How are you ensuring which Start is called first

ruby python
#

I'm using Awake on the script that calls the GetPooledObject() method.

#

Also tried OnEnable

void thicket
#

You’d want pool manager’s initialization to be called first not the other way

ruby python
#

Pool manager uses Start(), the 'spawning' script uses Awake

void thicket
#

Swap that

#

Are you aware that Awake is called first

ruby python
#

Honestly I thought Start was called first. lol.

But I have tried with OnEnable too (for the spawning script) and still failed.

void thicket
ruby python
#

Okay, well yeah, that fixed it. silly spud.

ruby python
#

Yeah, for some reason I'd got it in my head that Start() was first, even though I do (or did) actually know otherwise. lol.

ruby python
#

Sooooo, another teeny issue that's bugging me.

    private void Update()
    {
        curveChangeCountDown -= Time.deltaTime;

        if (curveChangeCountDown <= 0)
        {
            currentXBend = tunnelCurveMaterial.GetFloat("_xStrength");
            currentYBend = tunnelCurveMaterial.GetFloat("_yStrength");

            currentXBend = Mathf.MoveTowards(currentXBend, xBend, lerpSpeed * Time.deltaTime);
            tunnelCurveMaterial.SetFloat("_xStrength", currentXBend);

            currentYBend = Mathf.MoveTowards(currentYBend, yBend, lerpSpeed * Time.deltaTime);
            tunnelCurveMaterial.SetFloat("_yStrength", currentYBend);

            xBend = UnityEngine.Random.Range(-3f, 3f);
            yBend = UnityEngine.Random.Range(-3f, 3f);

            Debug.Log(xBend);
            Debug.Log(yBend);

            timeToChangeCurve = UnityEngine.Random.Range(3f, 5f);
            curveChangeCountDown = timeToChangeCurve;
        }
    }

Would someone be able to give me a clue as to why my MoveTowards operations aren't moving smoothly and just 'snapping' to their new positions please? šŸ˜•

novel nymph
#

I am confused on how to fix this, also, I am pretty sure I got the multiplication part wrong

cosmic dagger
novel nymph
cosmic dagger
#

Are you doing this inside of another method?

novel nymph
#

I want to make it so the EnemyAi's sightRange, a circle around the Enemy, becomes half of its original size when you press Left Ctrl.

cosmic dagger
#

You need to:

  • Check for input
  • If correct input, call a method that halves the size . . .
#

Typically, input is checked in Update. I'd start from there . . .

novel nymph
cosmic dagger
echo ruin
#

You make a reference to the EnemyAI first, use the reference.method (if it returns a float) if you want to make a float

cosmic dagger
#

Also, I would increase/decrease its size by half instead of subtracting 0.5. What if some have a range of 2, 3, or 4?

novel nymph
#

I believe I got it to connect to the original variable from my seperate script but I cant figure out how to multiply it

strong wren
cosmic dagger
strong wren
cosmic dagger
echo ruin
#

As in, does the EnemyAI class contain a sightRange float?

echo ruin
# novel nymph yes

Then you'd access it like this for example

    public EnemyAI enemyAI;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftControl))
        {
            enemyAI.sightRange = .5f;
        }
    }```
static cedar
#

Just curious, is there any way to get the normal force that occured during collisions between two colliders?

novel nymph
cosmic dagger
static cedar
cosmic dagger
#

One is the total impulse. The other is the (size) velocity of the collision. You can normalize either to get the direction (you may need to invert it to get the outgoing normal . . .

#

I haven't tested either myself . . .

static cedar
#

Interesting that Collsion2D doesn't have that. It still has relativeVelocity though. I was focusing on 2D, and looking through Collider2D if there's another way other than the message.

cosmic dagger
#

Oh, 2D always has different stuff than 3D . . .

static cedar
#

Why can't they be the same.

cosmic dagger
#

Facts . . .

timber tide
#

Box2D vs Nividia physx

teal viper
bright zodiac
#

-> is a valid syntax in c# for raw pointers

#

but I see what you mean šŸ‘

pure sapphire
#

any1 know how to make it so when the player starts moving the walk animation starts and the moment he stops the idle one, i keep having the issue of the player still being in the walk animation for 0.2s after i stop moving and more or less the same for the idle animation when walking

slender nymph
pure sapphire
slender nymph
#

then show relevant code

#

but 10 times out of 10 that description points to an issue with your animator controller setup

pure sapphire
#

hmmmm, ima double check and see if i can do some fixes there then rq

#

oh yeah i forgot to reduce transition times lol thx for the help

fleet venture
#

why does it jiggle like this when i click, i dont see anything in my code that could be causing it.

public class RotationTransform : MonoBehaviour, IPointerDownHandler
{
    private bool _dragging;
    private Vector3 _original;
    private Quaternion _originalRotation;
    private Camera _mainCamera;
    private Transform _effectedObject;

    private void Start()
    {
        _effectedObject = transform.parent.parent;
    }

    private void Update()
    {
        if (Input.GetMouseButtonUp(0) && _dragging) _dragging = false;
        if (!_dragging) return;
        var mousePosition = _mainCamera.ScreenToWorldPoint(Input.mousePosition);
        _effectedObject.rotation = Quaternion.Euler(0, 0, _originalRotation.eulerAngles.z + Vector2.Angle(_original - transform.parent.position, mousePosition - transform.parent.position));
        transform.parent.rotation = Quaternion.Euler(0, 0, -_effectedObject.rotation.z);
    }

    private void Awake()
    {
        _mainCamera = Camera.main;
    }

    public void OnPointerDown(PointerEventData eventData)
    {
        _dragging = true;
        _original = _mainCamera.ScreenToWorldPoint(Input.mousePosition);
        _originalRotation = _effectedObject.rotation;
    }
}```
#

oh wait

#

its getting replaced

#

completely

#

thats weird

#

maybe thats the issue

fleet venture
#

i have indeed fixed it now

fleet venture
#

NVM its not fixed T-T

#

i just thought it was

#

thats painful

#

the jiggle issue its fixed but now it just doesnt work while rotating

#

ok i fixed it and i dont know how

sterile radish
#

hi, in my game, i have a list of all of the upgrades the player has bought. im currently trying to make a save sytem that saves this list and also the levels for each of the upgrades. i have tried but have failed because i don't think json can save monobehaviours (boughtupgrades list is a list of monobehaviour classes) how would i go on about saving the boughtupgrades list?
https://hastebin.skyra.pw/pixolibese.pgsql

teal viper
#

You don't want to save all the data of a monobehaviour(if that was even possible). You'll waste a lot of storage on stuff that doesn't matter(doesn't need to be saved) at all.

sterile radish
rich adder
fleet granite
rich adder
fleet granite
#

i've done that

#

😭

rich adder
fleet granite
rich adder
fleet granite
rich adder
# fleet granite

yeah something is missing.. it Should at least say Projects: .. Show you have all the appropriate stuff installed

#

see how mine says Projects: Assembly-CSharp

brave helm
#

Lets say im trying to make a game, what is the best way to learn? ive tried following the unity tutorials but stopped halfway through cause i wasnt learning the features i want. Let say i want to make a door open and close with an interaction, where and how would i learn that?

rich adder
#

most features share the same base knowledge

#

if you know how to break down interactions, it doesn't matter if its a door or picking up an object

#

making a door, if you think about the smaller parts needed.. First thing would come to mind for me is, tracking the state of the door itself first with isOpen bool or similar.

#

build up your objects from their very basic functionalities

brave helm
#

That makes sense

rich adder
#

yeah most problems are just compounded smaller problems

brave helm
#

is there a good way i can learn the diffrent bools and functions?

rich adder
#

well most of that isn't even related to Unity, I would suggest you learn that way

#

like plain c# (check out pins in this channel its a good start)

fleet granite
# rich adder

sorry, was dealing with a roommate
by appropriate stuff installed, do you mean extensions?

rich adder
rocky canyon
brave helm
#

alright thanks

rocky canyon
#

that just comes with tme and experience..

#

best to look up stuff from google and finde the link leading to the documetatiopn

brave helm
#

i found the .net documentation, maybe ill follow a tutorial off of youtube then break down every function

sterile radish
#

hi, im trying to save a dictionary in my game using json. i made a list of a class that holds a string key and a value pair. when saving, i stitch these values to the dictionary and when im loading i overwrite the dictionary with the saved values. however it's not getting written to the json file. why is this?
https://hastebin.skyra.pw/hibolalayi.csharp

rich adder
#

screenshot the output

fleet granite
#

9.0.200

#

just 9.0.200

rich adder
#

also unity cant serialize dictionaries

sterile radish
rich adder
# fleet granite

hmm go back to VSC again and select c# devkit under the Output tab

slender nymph
fleet granite
rich adder
#

then go back to unity, only check the top two checkboxes in External Tools

#

Regen project files again and open script from unity

fleet granite
#

still nothing unfortunately, same output for the devkit

rich adder
rocky canyon
#

is it possible permissions/firewall issues?

rich adder
#

im confused why its trying to use dotnet 8.0.13 but they showed they have .net sdk 9.0

rocky canyon
#

can u go in and manually uninstall the 8?

fleet granite
#

8 isn't installed afaik, i haven't done so myself
fresh windows install from around two days ago

rocky canyon
rocky canyon
rich adder
#

You can do
dotnet --info in command line
it will show everything installed related to .net

fleet granite
rocky canyon
#

also i cnat remember if beign signed in matters at all

fleet granite
#

creating a new project atm, will test once it's open

rich adder
#

you got a lot of earlier version of .net I wonder if its causing conflicts

rocky canyon
#

oh im behind

fleet granite
rich adder
rocky canyon
#

if its a reset probably

#

not

rich adder
fleet granite
#

same happened in a new project btw

rich adder
#

yeah Ima guess/suspect something borked going on with your runtimes causing conflicts

fleet granite
#

all else fails i'll work with visual studio for now but i'm gonna have to hold in the vomit

#

thanks for trying to help though man

rich adder
#

that works too

#

np. If you feel up to it, do a clean wipe of all .NET then just install 9

fleet granite
#

i have time so i'll probably do that

#

ty

brave helm
#

Hello for some reason unknow to me i cannot apply this image to my background panel.

slender nymph
#

Sprite Mode Multiple
also not a code question

brave helm
#

oops

polar loom
#

Wrong thing

magic panther
#

https://hastebin.com/share/nopotakoqu.csharp
In the following code, in the Update function, I'm using a Vector2.Lerp to smoothly move the position marker object into the targetPosition. The problem is it always goes a little bit further than it should. I tested that by setting it's position to the targetPosition, and it worked perfectly. Does someone know how a lerp can overshoot? How do I prevent

rich adder
#

idk about overshoot tho...if anything it should never reach full val.
either way lerp is still done wrong

ruby python
#

Evenin' all,

I was just wondering if anyone knew if the following was possible (and where to look to help figure out how to do it if it is)

Player is controlling a turret and doing pew pew things. I'm using image 'planes' for my environment with textures applied (see pic for context).

in the image there are some buildings and at the moment, my bullet impacts are pretty much all the same size etc. I was just wondering if it would be possible to sort of sample a depth map (I have one for the image) and adjust the size of the bullet impacts accordingly (ie, brighter the sampled pixel is, the larger the bullet impact?

Also for further context, short video

https://streamable.com/yduf2m

Watch "2025-02-16 19-45-07" on Streamable.

ā–¶ Play video
wintry quarry
#

but yeah - absokutely not a problem - you can read the pixels of the texture and do whatever you'd like with it

rich adder
ruby python
#

It's a single image, mapped to 3 'plane' objects and sorry @rich adder the plane is a model. It's just the environment that's an image.

ruby python
wintry quarry
ruby python
# wintry quarry What part are you struggling with?

I actually think I have some code that reads the pixels in an image from an old level generation script and throws them into a Vector2 array, so that shouldn';t be in issue.

At the moment, I'm not sure how to read the pixel value and then apply that to the scale of the impact object. (Mainly how to 'normalise' the value because it would read as an rgba?)

wintry quarry
#

to essentially map the depth from the texture into the hole size you want

ruby python
wintry quarry
#

the depth would be stored in one of the color channels

ruby python
#

Oh wait, as it's greyscale I'd only need to read one of the rgb values and normalise that.

wintry quarry
#

and the color channels are just numbers

#

yes

ruby python
#

Thank you. Sorry. lol. saying/typing it out loud helps so much. lol.

primal cliff
#

I'm getting this error when I need to call GameStateManager, I check the hierarchy and for some reason upon loading my project the GameState object (containing the GameStateManager) is being destroyed despite nothing in the code doing that, what could be happening?

primal cliff
#

all of it? it doesn't specify from where it's coming from

rich adder
#

anything that is trying to access GameStateManager

#

does GameStateManager have any scripts on it?

primal cliff
#

this is in my title screen's code which is where I get the error, this is all I do to interact with it

rich adder
#

you might be able to just put a log inside the OnDestroy and it should show who called it through stack

primal cliff
#

my object is called GameState and the script is GameStateManager

primal cliff
#

how would I check who called it?

rich adder
#

most likely though if you have Level switching, its probably being destroyed for scene change and something else is still trying to access it still

primal cliff
#

I do have level switching, but it gets destroyed even without me trying it

#

it's destroyed as soon as I click play

rich adder
#

thats how scene switching works

rich adder
primal cliff
#

I'll be honest I have no idea what that is

#

the other thing I noticed is that it disappears from my DontDestroyOnLoad in the hierarchy now, when previously it didn't

#

but src (for sound source) still is there

rich adder
primal cliff
#

I have this script attached to both GameState and src

rich adder
#

you literally coded the second object to destroy itself if it has the same script

primal cliff
#

so src sees that there is another object in DontDestroyOnLoad (which would be gamestate) and deletes it?

#

I think I get it, I had this script before where src was the only object which had this script

rich adder
#

since its the same script and not different class singleton/instance

primal cliff
#

how should I go about coding it then? my guess is to check for a gameobject of the same name as the one the script is attached to, and only destroy that

old karma
#

got a question that i was looking for some context to.

so i see a simple coroutine but it's using while(true) and i have no idea what is "true" in this context
here's the example code

[SerializeField] private float delay;

private void Start()
{
    StartCoroutine(Routine);
}

private IEnumerator Routine()
{
    while(true)
    {
        yield return new WaitForSeconds(delay);

        DoSomething();
    }
}

can anyone tell me what is "true" in this case? is it the coroutine running or is it the game object being enabled or? im usually specific about these kind of things, but this is the first time i noticed this one, so it's bothering me that i dont know šŸ˜…

wintry quarry
#

it's the literal value true

runic lance
wintry quarry
#

like:

bool x = true;
bool y = false;```
#

bool can be true or false

old karma
#

yeah but... what is true in this case?

wintry quarry
#

nothing is true

#

you're asking like if I typed 1 and you said "but what is 1?"

#

1 is a value

#

true is a value

primal cliff
old karma
#

AAH! ok i see. yeah, i just wanted to know what was determining the condition. so i this case, the corutine is running so that's the "true" here.

primal cliff
#

so that it only destroys duplicates of the game object it's attached to

rich adder
#

DontDestroy desnt do anything but not destroy an object and its children through scene changes

#

it has nothing to do with actually destroying objects

#

that is your singleton pattern Instance check doing that

rich adder
primal cliff
#

I'm finally understanding why I shouldn't copy code that I don't understand what it does

primal cliff
#

fixed it now, thanks for the sage advice

old karma
rich adder
#

if you used a variable, then you could control how long the loop runs, if it runs at all (condition being false and loop is skipped)

old karma
#

yeah, im just going to put a bool to it. i was hoping i can get by without doing much and giving it a stop function. but i'll just add a bool and a coroutine variable because i need a way to start and stop it

rich adder
#

unless you have more code before/after, and want the while loop to be skipped/done according to a condition

old karma
#

actually, i was just instantiating some sparkles at a frequency and just letting them destroy themself after a duration.
but... now that i think about it... can't i just use the special effects thing(forgot the name of it) to spawn the sprite?

rich adder
old karma
#

particle system

rich adder
#

yeah it pretty much what its for

old karma
#

yeah... i'll use this time to play with it

rich adder
#

you can do a lot with it

#

not the most performant compared to the new VFX graph, but the upside is its simple to use in comparison and can also interact with unity physics colliders

old karma
#

hmm.. well i would like to go after whatever is more performant

#

so i'll look at the VFX graph and see what that's about

#

but coroutines are pretty easy to understand though

rich adder
old karma
#

ah, i dont think i'll have a case where i go near 200

wintry quarry
#

VFX graph is a really good thing to learn regardless

old karma
#

yeah, im going to look and see what it's about

fleet venture
#

is there a way to like, breakpoint a y position

#

i have a ui thing thats like moving down very fast and i dont know why

#

i have no idea whats moving it

rich adder
fleet venture
#

oh ok

#

BRUH WHY DOES IT HAVE A RIGIDBODY

rich adder
#

lul

fleet venture
#

i dont even remember ever adding that

rich adder
#

UI should never have colliders or rigidbodies

fleet venture
#

probably did that on accident

#

ye i know

#

that makes no sense

#

lmao

#

it had gravity hahaha

rich adder
#

nicee

fleet venture
#

whats this btw

#

i sometimes get it

#

no idea what it means

#

i get it whenever i start the game

rich adder
fleet venture
#

idk how to see that in unity

rich adder
#

select the error it should show you at the bottom

fleet venture
#

oh

#

there is nothing more

#

only the line that shows in the error itself

#

there isnt like an actual stack trace

rich adder
#

could be a bug in some asset or unity itself

fleet venture
#

i could try restarting unity i guess

rich adder
#

thats the first step yes

#

if it doesnt work you can try deleting library folder and do a full refresh

#

I think artifact might have something to do with it

polar loom
#

Does anyone here make fps games and I’m not asking to make one I’m just asking for help

slender nymph
#

!ask

eternal falconBOT
polar loom
#

It’s a script

#

Can I send a photo

slender nymph
#

!code

eternal falconBOT
polar loom
#

Can’t send the code rn

#

I’ll send a photo

#

And the error

slender nymph
#

a photo of what?

polar loom
#

The script

#

And the error

slender nymph
#

jesus

polar loom
#

I know how

slender nymph
polar loom
#

I’m just letting you know

#

But can you help

slender nymph
#

i refuse to even attempt to read your shitty photos of your screen

polar loom
#

This isn’t helping so not tryna be a toxic Karen but I will speak to mod for not helping or even trying

slender nymph
#

oh of course. in that case here's how you can fix it

polar loom
#

That’s now how I sent it

#

You can actually see the words in mine

polar loom
#

I’m not using discord on my computer rn

#

I KNOW HOW TO SS

slender nymph
#

we've already been over not making "you" problems other people's problems

polar loom
#

IM JUST NOT RN CAUSE DISCORD TAKE TO LONG O. THE COMP

slender nymph
#

don't make it difficult to help you or else nobody will want to help you. i've given you information on how to correctly share your code to follow the guidelines of this server so you should maybe consider following those guidelines if you want help in this server

polar loom
#

Bro you can see the words stop lying it’s only some pixels and plus your mot even trying to help you can see the words your just choosing not to help

#

And your being a dick about it

slender nymph
#

you're absolutely correct that i'm choosing not to help, and that is purely because you refuse to share your code or errors in any form that makes it easy to read. i'm not going to read your shitty phone photos

polar loom
#

I showed the error

#

And the code

slender nymph
#

great, then if you don't intend to share them correctly you can wait for someone who has the patience to deal with reading your shitty photographs

polar loom
#

Bro stop being a dick about it I just want help

#

I’m sorry I don’t have a iPhone 16

#

And my comp is slow

slender nymph
#

or you could share the information following the guidelines of this server which have been provided to you and maybe you'll have better luck getting help

polar loom
#

I can’t fix that in two secs

#

Wtv

#

Your a dick

#

Anyone please help I can’t send an Ss on computer rn so please understand my circumstances

#

Click on the photos to see full image

rich ice
#

if you cant send a screen shot, why dont you just send the !code ?

eternal falconBOT
polar loom
#

Computer gone take forever

#

I’ll try it’s wtv

#

Ion even wanna work on it anymore

slender nymph
#

wait till you learn that before you can even get help here you have to configure your !IDE lmao

eternal falconBOT
ruby current
#

If you can't even send a code from your computer. How are you manage to make a game on it.

polar loom
#

I can’t take an Ss rn

#

That’s what I’m saying

#

I’m getting it worked on soon

slender nymph
#

so you didn't even bother reading the information about posting code correclty then if you think screenshots of code are how to share it

rich adder
eternal falconBOT
#

mad No

Be mindful, if someone requests your code as text, don't send a screenshot!

grand snow
#

"plz help me with my code you can hardly read in this shit photo"

polar loom
#

Yeah fuck this server

#

I just want help

grand snow
#

Provide us with the info in a decent format so we can help you properly

polar loom
#

I’m new

rich adder
#

ta ta šŸ‘‹

polar loom
#

I don’t have a good computer

grand snow
#

if you send the code AS TEXT i can read it pleasently and even test it out!

polar loom
#

I just started

rich adder
#

no shit

#

does that means you don't use common manners?

polar loom
#

Ion even wanna work on the game anymore

#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Gun : MonoBehaviour {

[Header("References")]
[SerializeField] GunData gunData;

    float timeSinceLastShot;[]


private void Start()
{
    PlayerShoot.shootInput += Shoot;
}
private bool CanShoot() => !gunData.reloading && timeSinceLastShot > 1f / (gunData.fireRate / 60f);

private void Shoot()
{
    if (gunData.currentAmmo > 0) {
    {
        if (CanShoot())
        {
            if (Physics.Raycast(transform,position, transform.forward, out RaycastHit hitInfo, gunData.maxDistance))
            {
                Debug.Log(hitInfo.transform.name);
            }

            gunData.currentAmmo--;
            timeSinceLastShot = 0;
            OnGunShot();


            }
        }
    }

    private void Update(){
        timeSinceLastShot += Time.deltaTime

;

        throw new NotImplementedException();

}

}
}

#

Happy

rich ice
#

no

#

!code

eternal falconBOT
ruby current
polar loom
#

JUST COPY THE DAMN TEXT

rich adder
#

at this point this has to be a troll..

#

either way. blocked , Im moving on

#

goodluck guys

slender nymph
# polar loom JUST COPY THE DAMN TEXT

how about instead of throwing a fit like a toddler, you take a step back. calm down. then come back and read the information presented to you so that you can share your code correctly.

polar loom
#

I did what yall told me and I was wrong

slender nymph
#

no you didn't

polar loom
#

I don’t know what to do

#

How do I code block

slender nymph
#

man if only you had been pointed out how to share code correctly like 5 different times

polar loom
#

It just gives a https

grand snow
#

` <- dis guy

polar loom
#

Give me a damn minute

rich ice
polar loom
rich adder
slender nymph
#

i sure can't wait for them to post code just to not receive help because they don't have a configured IDE

rich ice
polar acorn
polar loom
#

Ok

#

Just making sure

#

That’s the code

#

For my coding app

slender nymph
#

great, now go configure your !IDE like you've already been told since that is a prerequisite for getting hlep

eternal falconBOT
rich ice
polar loom
#

I use VS Code

rich adder
#

float timeSinceLastShot;[]
notlikethis

polar acorn
polar loom
#

huh

slender nymph
#

that's not even the error they are trying to fix at the moment lol

polar acorn
#

Yeah the more I look at it the worse it is

polar loom
polar acorn
#

This needs a configured !ide to fix all of the problems

eternal falconBOT
polar acorn
#

If this isn't lit up in red underlines like a christmas tree you need to set up your IDE

verbal dome
polar loom
#

I use VS Code

lethal smelt
#

I use notepad

slender nymph
polar acorn
grand snow
polar acorn
#

configure it using the linked instructions

#

then look at what's underlined in red and fix it

polar loom
#

I’m sorry I’m new and I’m trying my best with tuts

#

But there is no new tuts

#

Anymore

rich adder
#

the link they sent is literally the tutorial

grand snow
#

thats okay but please do as we say and correct your vs code so it can help you out more

polar loom
#

Idk

slender nymph
#

configure your IDE before receiving help. it is a requirement

rich ice
lethal smelt
#

I'm starting to think he doing this on purpose yall

polar loom
#

It is configured

polar loom
polar acorn
rich adder
polar loom
#

Idk

lethal smelt
polar acorn
rich ice
polar loom
#

There ain’t nothing spelled wrong? Or is it just code wrong?

polar acorn
#

start there

polar loom
#

Ion see nthng

rich ice
grand snow
#

šŸ‘

polar acorn
#

And it would be best to stop pretending you have

#

follow the instructions

#

get the syntax highlighting

polar loom
#

I’m not pretending

polar acorn
#

Then, and only then, can you solve your problems

grand snow
#

look they dont know any better so we had to tell them (but they didnt trust us)

polar loom
#

So will it underline wrong code?

grand snow
#

YES

polar loom
#

Ok

grand snow
#

red squiggle like in word or g docs

lethal smelt
#

big bonus

polar loom
#

Nice I used chat gpt but for this code I did it myself

#

In the past

#

Before I tried learning

lethal smelt
#

tip

#

try not to use ai too much

polar loom
#

Yeah I didn’t for this one

lethal smelt
#

especially if ur new to this

#

only way to learn is by making mistakes

polar loom
#

Ok

#

I swear I’m not trolling I’m just extremely slow

#

When it comes to coding

grand snow
#

we all saw the errors in your code cus we have been doing this for years but you will learn that too

#

we also all rely on our IDE to help us out which is why its good to get it working

polar loom
#

Ok

#

I’m doing the external tools

#

Rn

#

Turning it on

#

Is that it?

rich adder
#

its not done until it underlines red, otherwise no need to keep spamming plz

polar loom
#

Ok question

grand snow
# polar loom Is that it?

close vs code then re open it by double clicking a script file in the unity editor. Hopefully this time it opens correctly

polar loom
#

In the package manager if it says ā€œUnlockā€ ā€œRemoveā€ and on the image it just shows remove do I click ā€œUnlockā€

#

I did it

lethal smelt
#

šŸ’„

polar loom
#

Let’s see! Ima restart the editor

#

Uhhh I restarted the editor and nothing happened

rich adder
polar loom
#

Thanks

polar loom
#

Guys it’s talking about there not being a net sdk do I install it

rich adder
#

you did not read the link sent did ya

#

oh well

cosmic dagger
#

If it's not there, but it's talking about it; you prolly need it . . .

polar loom
#

Ok

scarlet hull
#

why is this lamp not here

#

its here in game mode not in scene

#

collider and everything works

#

i can touch it

wintry quarry
scarlet hull
#

but sprite is not rendering

wintry quarry
#

Or it's behind other stuff

scarlet hull
#

i have it on a higher layer

wintry quarry
#

Show what you have

#

Also

#

Wrong channel

#

Not a code question

void thicket
#

Check Z

scarlet hull
#

how big of a mistake from me to accidentally ask unity ??? question in the unity CODING channel

#

i hope the big unity gods out there save my soul

#

truly i am sorry

#

my sins shall be never forgotten

#

i shall bear them and stand strong

#

thank you mr.PraetorBlue for pointing my sin out

west radish
#

You aren't in trouble or anything

#

Keeping channels focused on their own topic is for everyones benefit

faint agate
#

Hello, I have this script that auto scrolls since im using keyboard to scroll. I dont want the auto scroll to happen on the last button going onto the next off screen but the button before the last one, so it starts auto scrolls on the one before last . Ive been trying for awhile
https://pastecode.io/s/rtt44h96

gray pawn
#

I been following a tutorial and i noticed the words on my side weren't highlighted in color is that ok or no?

slender nymph
#

!ide

eternal falconBOT
thorn holly
west radish
#

The problem sounds like you just need to ignore the first and last iteration in a for loop

#

for(int i = 1; i < foo.count - 1; i++) something like this

fierce plume
#

heyyy guysss i need some simple help so If I wanted to change the position of a game object but didn't know how to get the name in order to change the game objects position what would you tell me

slender nymph
#

learn how to correctly get a reference to the object instead of relying on its name

fierce plume
#

oh how do I do that

slender nymph
#

did you know that blue text indicates a link

fierce plume
#

oh nope

#

thanks

west radish
#

For something called a hyperlink, it sure doesn't move around a whole lot

gray pawn
slender nymph
gray pawn
#

quite handy

lavish magnet
#

Yes are yiu still here? Like the split model visibly looks split but together like small cracks are visible

night raptor
worthy veldt
#

I want to make a bool toggle in editor that will show other variable, ex: "IsCutAble" bool will show things to be filled, like energy needed, cut wood prefab, yield amount etc.

#

I made one, but essentially unused because i only have 1 processing activity. now that i look into it, search result shows codes using editor or gui but there's none in my script.

rich ice
#

you mean something like this?

GitHub

MyBox is a set of attributes, tools and extensions for Unity - Deadcows/MyBox

worthy veldt
#

i do remember making it myself with simple lines, perhaps i do use 3rd party tool but not editor extension

#

but yes i found what i want in the github, ill use it for now. ill stumble upon my own code eventually, it should be here somewhere

frigid sequoia
#

If I use GetComponent and there are a bunch of the component I am looking for, it does always return the same one or one random?

frosty hound
#

It's not a guaranteed thing I don't think?

rich ice
#

isn't it the top one first?

#

oh nvm.
according to a random guy on stack overflow its the top one first
although according to the docs

Note: GetComponent returns only the first matching component found on the GameObject on which it is called, and the order that the components are checked is not defined. Therefore, if there are more than one of the specified type that could match, and you need to find a specific one, you should use Component.GetComponents and check the list of components returned to identify the one you want.

faint agate
frigid sequoia
# rich ice isn't it the top one first?

I want to do a thing where characters get a typical absorb shield that takes X amount of damage before breaking, but they also can stack. Like... shield 1 for 100 for 5 secs and then shield 2 for 150 for 3 secs for example. These are managed by a status effect script that attaches to the object for each shield and basically says "while this is on the char it has +X shield, when expires, remove -X from shield if possible and remove this script". So I have to have a reference to who casted the shield (to attribute to them the damage mitigation) and when the shield takes damage I have to know which one did (which I think should be either the top one or the one with less time remaining, not sure) so I don't remove shield value comming from another shield

wintry quarry
#

Or List or whatever

frigid sequoia
#

I could have a List of all current shield type scripts on the target on the health manager, yeah

#

And whenever the shield takes damage attribute that damage to whichever shield on the list has the less time reamaining, I think it makes sense

#

Maybe even better use a Dictionary

frigid sequoia
#

Is this gonna do the thing that I expect it to do or did I mess it up?

#

I am not quite sure I understood the example and it's kinda messy to check for myself

cosmic dagger
# frigid sequoia I am not quite sure I understood the example and it's kinda messy to check for m...

You can a small script to check if it works . . .

  • create a MonoBehaviour script
  • create a c# class with a Duration field (on the same script)
  • add a list of the c# class to the MonoBehaviour script
  • add a CompareTo method to the c# class (this will compare the duration)
  • implement IComparable<InsertClassName> on c# class
  • from the inspector (of the MonoBehaviour script), add 3-4 items (instances) to the list
  • set random duration for each instance: 1, 2, 3, 4 (out of order)
  • call List.Sort in Start of MonoBehaviour script
  • check the list from the inspector to see if the order correctly changed
frigid sequoia
#

I am not sure I undertands that

#

I have not really used a IComparable before

brazen narwhal
#

anyone here familiar with gm2 and unity? I need to transform a gms2 script to c#

cosmic dagger
#

Which part are yuo stuck on?

frigid sequoia
#

Why even add the IComparable? Isn't that basically creating 4 objects with a test script and see if they get ordered right with that?

lapis yew
#

Well, you still need to order the list right

#

Or use Where() to pick the right one

cosmic dagger
#

It's easier to have your compare (Sort) method in the class in case it changes and to have more control over it . . .

lapis yew
#

It looks to me like Daleo wants to pick 1 item that has the less of x. Seems like you don't need to sort the list, instead use Where() to locate the correct one

#

Unless there's a meaning to actually sorting the list

cosmic dagger
#

They want to order the list from least to greatest . . .

cosmic dagger
frigid sequoia
#

Give me a sec, I am setting some other thing

last owl
#

I need a way to add an objects vector3 position to a list/array when it is created, then after it moves somewhere else and is destroyed, that specific vector3 value is removed from the list/array. Basically I don't want a new object being spawned in the same spot as another object has until that first object is destroyed.

cosmic dagger
last owl
#

so I have a general "enemy" script attached to every enemy object that is instantiated, how do I keep track of which specific spawn position is tied to which specific instantiated enemy object since the enemies current position when destroyed will be different

edgy tangle
#

Otherwise you could use a dictionary to have a key/value pair (enemy, spawn position), or create a custom struct or class to wrap the two together.

#

Or use tuples

#

In any case, you either make the spawn position a member variable or you couple it together in some sort of other wrapper.

#

Member variable would probably be easiest, because then you can have the enemy register itself (and its spawn position) either to a static dictionary or to some other mediator class, and then also unregister itself.

shell orchid
last owl
ancient halo
#

i'm having a small problem with entity spawning
i have an entity prefab and i Instantiate it in this way
but i get an expected behavior which the new entity appears at the location specified in the prefab before it transports to the new location i set down there
i expected this but have no idea how to fix it now

` Entity newUnit = state.EntityManager.Instantiate(currentItem.UnitPrefab);

        RefRW<GameEntity> gameEntity = SystemAPI.GetComponentRW<GameEntity>(newUnit);
        gameEntity.ValueRW.Team = factoryGameEntity.ValueRO.Team;
        gameEntity.ValueRW.Owner = factoryGameEntity.ValueRO.Owner;
        
        var position = factoryData.ValueRO.UnitSpawnPositionTransform;
        
        state.EntityManager.SetComponentData(
            newUnit, 
            LocalTransform.FromPosition(
                localTransform.ValueRO.TransformPoint(position)));`

i tried changing the prefab's LocalTransform to the new location before Instantiating it using SystemAPI and state.EntityManager
i also tried using a command buffer and using playback but it still the same problem

SystemAPI.GetComponentRW<LocalTransform>(currentItem.UnitPrefab).ValueRW = LocalTransform.FromPosition( localTransform.ValueRO.TransformPoint(factoryData.ValueRO.UnitSpawnPositionTransform));

novel nymph
#

is it possible to move your camera (not the POV in the game) to a object?

cosmic dagger
novel nymph
#

I mean the camera that is used to edit the game, like this one

astral falcon
novel nymph
vapid plinth
#

Im having an issue with my movement system, I created a public float for the speed, but in the void update parameter it says its doesn't exist

rich ice
#

!code !screenshots typo

eternal falconBOT
rich ice
#

guh, never get this command right

vapid plinth
#

Thanks

#

Thanks so much, didn't realise there was a typo and spent 20 minutes trying to fix it

rich ice
#

its a very common error lol

#

if you get that error, make sure to double check your spelling

vapid plinth
#

Will do thanks again