#💻┃code-beginner

1 messages · Page 722 of 1

rocky canyon
#

after u get input (which i imagine in ur update) and normalize it and then u use that method -> then send it over to ur movement fuctions

tacit prism
#

im a dumbass mb, forgot this shitter existed already

rocky canyon
#

so after all that..

#

and after u normalize it but before u use it to multiply w/ ur speed modifier

grand snow
#

If you make a poly shape in editor and see how that works I hope it will make more sense to you

rocky canyon
tacit prism
rocky canyon
#

if this script is on the player object its working fine..
b/c in the video ur rotating the camera around the player
the players direction never changes..

if u select the character (movement script object) and watch its transform it'll show u its orientation.. thats the transform.forward and transform.right that ur multiplying the input by...

#

if u wanted it to move the direction ur camera is facing instead.. u'd multiply ur inputs w/ the cams direction/axis cameras.transform.forward and .right

tacit prism
rocky canyon
#

ive been working on CC's for bout 4 years now 😄

#

i have quite a few already in different stages.. just ready to help

tacit prism
#

well thats nice, thanks, ill try to get this working better, even if itll take the next 3 horus

#

i will say i was pressing w for all examples though

#

:(

#

this is what i get for trying to learn through tutorials after spending only 1 week on microsofts c# thing

rocky canyon
#

CCs have alot to do with math.. (basic stuff like geometry)
knowing the Vectors.. the Directions (the relation between Local/World) magnitudes / normalization.. why we do that.. then its multiplication and addition usually

#

the camera / rotation work is usually a bit more complicated (still pretty easy tho)

tacit prism
rocky canyon
#

oh yea, thats much better example..
def messed up.. (how are you rotating?) im having a hard time figuring out how the movement and rotation is supposed to be working.. also share ur !code in case someone does know

eternal falconBOT
tacit prism
rocky canyon
#

brute force the computer to do what i want 😈

tacit prism
#

i wish it worked like that...

hallow acorn
rocky canyon
#

ya, soo..is ur rotation script also trying to rotate the same object the freelook camera is controlling? to me it looks like theres some code fighting back and forth.. (the jittering)

tacit prism
#

very much so :(

#

i was following a video for the rotation script and its like almost 4 years old

#

so i really didnt know what was going on

#

i dont want to have to watch videos, but theres so much on the documentation, and probably a decent chunk of it ill never use, so i want to find out what i am going to use

#

and how to

tacit prism
#

god this field is so hard

tacit prism
#

screw it im remaking my entire movement script again, this time around the cinemachine camera...somehow

sour fulcrum
#

What isn’t working

forest mirage
# sour fulcrum What isn’t working

nah i fix it i get some coffee
its because i tell print the number not i tell him to print number 0 (c# is counting from 0 to ...) soo i fix it

#

everyone you need coffee

frosty wren
#

When you get this error in inspector, is there any way to know what script it was looking for? I tried looking through git differences, but everything is in IDs and not names

teal viper
tacit prism
vestal anvil
#

what is the difference between NavMeshAgent.NextPosition and NavMeshAgent.Destination? i see that they both output the same thing,they both set the next point where the agent goes so what is the difference?

#

there is also NavMeshAgent.path that can still be used to set a path

naive pawn
#

docs seem to suggest that destination is where it's trying to go and nextPosition is where it's trying to move to (to get to the destination)

rotund root
#

why is this button not working? 🐒

using System.Collections;
using System.Collections.Generic;
using System.Data;
using UnityEngine;
using UnityEngine.UI;

public class Help_Off_Button : MonoBehaviour
{
    public GameObject HelpPanel;
    private void Click()
    {
      HelpPanel.SetActive(false);
    }
}
#

it's responding to my click (i can see it blink when i click it) but it's not doing anything

grand snow
#

hmm perhaps because you didnt actually pick the function it should call

#

@rotund root ^

rotund root
#

ohhh

grand snow
#

you can subscribe to the event in code or do it via the UI like this (but you need to pick the function from the dropdown list)

silk night
#

no code needed then 😄

glossy vigil
#

hey guys im new to unity

#

would anyone mind hopping in a call with me

#

i have some questions

grand snow
#

!ask

eternal falconBOT
grand snow
#

ask questions in a channel in text instead of expecting someone to be your tutor

hallow acorn
#

@grand snow @rocky canyon yesterday at 3 am i came up with a solution for my mesh problem if you remember. Forgot to tell you guys about it though as i was craving either sleep or immense amounts of coffee. What if i create a triangle fin by making a triangle with vert indexes i, i+1 and the coordinates 0,0,0? Like a triangle fin as used in circles. Obviously wont work well with to complicated shapes but after making 2 triangles before i almost passed out of tiredness It looked like it could work. I tried making a normal 3x3 grid first by making 4 imaginary points in the middle but i was afraid of it glitching when squished to much as these points werent moving with the others, rather they stay around the geometric middle with an offset. So i thought id merge those 4 center points into a single one in the center. Topology wise probably nof optimal but simple and hopefully enough to get it colored.

#

Im not sure if i was dreaming or if this really happened but ill look into it later today

grand snow
hallow acorn
grand snow
#

No rush

hallow acorn
#

@grand snow I hope this makes it a bit more clear. The imaginary point is stored on the last slot of the array i think that could cause a bit of confusion

#

So in a for loop a triangle is essentially i, i+1, imaginary point

grand snow
grand snow
#

If it starts as a square then you can easily figure out the uv coordinates. Bottom left is 0,0 and top right is 1,1

hallow acorn
#

Oh thats really easy actually thank you. Ill look into it in the evening

grand snow
silver lance
#

yo chat

#

iam new to unity

balmy vortex
#

hey so like how do you actually make UI bars for ints like player health, mana etc?

hexed terrace
balmy vortex
#

what

hexed terrace
#

I see now you deleted your other msg, so haven't crossposted... but you've been given the info you need to be able to do it.

#

It's also an extremely common thing, so you'll find lots of tutorials online

silver lance
#

help me bro

frosty hound
eternal falconBOT
silver lance
#

okayy

silver lance
hexed terrace
#

!learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

silver lance
#

like iam abiginner

fiery stone
#

alright now im really confused
https://www.codedump.xyz/csharp/aLGb_Plli_PGg5hK

it worked amazingly, but after adding the cooldown (not the timer), even after the isDashing is false, it still slowed me down until the cooldown was finished. Like the cooldown itself, which is really weird because it shouldnt affect speed at all, let me record an example of it happening

#

and yes, this happens even if i set the CurrentCooldown manually without dashing

#

if you want more specific numbers averrage speed goes from 5-6 to 2-3. If i set it so the cooldown is 0 (so ti sets the cooldown to 0 when dashing) it doesnt happen, so its somehow tied to CurrentCooldown being above 0

fiery stone
#

its in the codedump

#

everything named cooldown

#

nothing else

silver fern
#

it would be easier if you kept your code formatting consistent

#

its kind of a mess

silver fern
acoustic belfry
#

hey, is this aproach for stay on the plataform too much? It works like a charm, but im not sure if is too overly complex or smt, or just straight up a bad idea

{
    // Check if there's a platform below using OverlapCircle :P
    Collider2D collider = Physics2D.OverlapCircle(transform.position, groundcolliderradius, groundlayer);

    if (collider != null && collider.TryGetComponent<movablePlataformBase>(out var platformBase))
    {
        Transform platform = platformBase.transform;

        // If she stepped on a new platform
        if (currentPlatform != platform)
        {
            currentPlatform = platform;
            platformOffset = rb2D.position - (Vector2)platform.position;
            lastPlatformPos = platform.position;
        }

        // Move the player within the platform
        rb2D.position += (Vector2)(platform.position - lastPlatformPos);
        lastPlatformPos = platform.position;
    }
    else
    {
        currentPlatform = null;
    }```
silver fern
#

it might be more precise to use a raycast instead of overlap

patent wedge
#

I know that you can do int = somebool ? True : false. But is there an equivalent with somebool ? Function() : do nothing?

keen dew
#

if(somebool) Function();

burnt vapor
#

Or return null, and I'm fairly sure you can do delegateVar?.Invoke()

#

But tbh this is so obscure that I don't even remember

fiery stone
fiery stone
fiery stone
marble pendant
#

Hello, i am very new to using unity, can someone please suggest a video,website,tutorial for understanding unity's new input system(i find the old input system very easy but want to learn the new one)

eternal falconBOT
#

:teacher: Unity Learn ↗

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

marble pendant
#

Thank you!

silver fern
fiery stone
silver fern
fiery stone
#

like i said in the original message

silver fern
fiery stone
silver fern
#

does it still happen if you remove that part?

fiery stone
silver fern
#

the part that I just posted

fiery stone
silver fern
#

no only the part that applies slowdown

fiery stone
silver fern
#

but what about 1 - movementdrag * deltatime

#

since thats the part of the code thats executed if isDashing is false

fiery stone
silver fern
#

which is the issue

fiery stone
#

so you dont, yk, fly off the screen the second you press w

fiery stone
#

but the cooldown doesnt affect movement except not being able to dash

#

thats the weird part

silver fern
#

I'm noticing that you're multiplying your movement verctor with deltatime twice, is that on purpose?

silver fern
fiery stone
silver fern
#

what did you remove exactly

fiery stone
silver fern
#

what's the value of the movement vector right before you change position?

fiery stone
# silver fern what's the value of the movement vector right before you change position?
(Infinity, 0.00)
UnityEngine.Debug:Log (object)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:111)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

transform.position assign attempt for 'Player' is not valid. Input position is { Infinity, 0.000000, 0.000000 }.
UnityEngine.Transform:set_position (UnityEngine.Vector3)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:112)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

(-Infinity, 0.00)
UnityEngine.Debug:Log (object)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:111)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

transform.position assign attempt for 'Player' is not valid. Input position is { -Infinity, 0.000000, 0.000000 }.
UnityEngine.Transform:set_position (UnityEngine.Vector3)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:112)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

(Infinity, 0.00)
UnityEngine.Debug:Log (object)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:111)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

transform.position assign attempt for 'Player' is not valid. Input position is { Infinity, 0.000000, 0.000000 }.
UnityEngine.Transform:set_position (UnityEngine.Vector3)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:112)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

silver fern
#

then go back and check the involved variables to see where the infinity is coming from

#

that shouldnt happen

#

I do see that you're mixing floats and ints a lot, maybe its a rounding error because of that somewhere

#

nvm

fiery stone
#

yeah thats the keyboard inputs

fiery stone
# silver fern nvm

heres some logs:

Xinput: 1 | Yinput: 0
UnityEngine.Debug:Log (object)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:105)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

Xvel Before Drag: -Infinity | Yvel before drag: 0
UnityEngine.Debug:Log (object)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:106)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

(Infinity, 0.00)
UnityEngine.Debug:Log (object)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:113)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)

transform.position assign attempt for 'Player' is not valid. Input position is { Infinity, 0.000000, 0.000000 }.
UnityEngine.Transform:set_position (UnityEngine.Vector3)
PlayerController:HandleMovement () (at Assets/Scripts/Player/PlayerController.cs:114)
PlayerController:Update () (at Assets/Scripts/Player/PlayerController.cs:42)
#

so acceleration must be infinity?

silver fern
#

xvel before drag is

fiery stone
#

or negative infinity

polar acorn
#

Unexpected Infinities usually means division by zero or at least division by something close enough to zero to count

silver fern
fiery stone
#

0? but multplication by 0 is 0, not infinity?

silver fern
#

where is xvel before drag exactly

fiery stone
#

then i log that

silver fern
fiery stone
#

as shown in the logs

silver fern
#

1f

polar acorn
# fiery stone no division :O

I wonder if it's compounding multiplication by something less than 1? If that thing gets smaller and smaller every time eventually you'll run out of floats and unity will decide it's infinity. What are the values of MovementAcceleration and MovementDrag at the time you're getting Infinities?

fiery stone
silver fern
#

we are seeing xVelocity += 1f * 0.15 = infinity

polar acorn
fiery stone
silver fern
fiery stone
#

its weird this only started happening when we stopped multiplying by deltatime 🤔

silver fern
#

its got to be some sort of rounding error

silver fern
fiery stone
silver fern
#

1f

polar acorn
#

Some number is compounding when it's not supposed to be. I might just need to step through this in a debugger to find out what

fiery stone
#

ight

fiery stone
polar acorn
silver fern
#

I think for this we want to be as precise and explicit as possible

#

just in case

polar acorn
# fiery stone you can do that if it would help

It might take me a bit, I'm about to head to work where I will probably be able to investigate in more detail. If this isn't solved in like an hour I'll look into it, because I don't really see anything obviously wrong at a glance

#

One thing to consider - try making a test scene that contains only this script and as little as possible to actually test it. Make sure it's not some other script futzing with those public values

fiery stone
silver fern
#

oh yeah, is any other script affecting any of these variables?

fiery stone
polar acorn
fiery stone
fiery stone
#

thats multiplyiing itself by itself * -4

silver fern
#

that seems about right

#

the factor is about -4

polar acorn
silver fern
#

ah yep thats it

polar acorn
#

It's like, a drag percentage. The closer to 1 the faster it damps

silver fern
#

thats the issue right there

#

both the original issue and this one

fiery stone
#

but the original problem is still there

#

the CurrentDashCooldown is still messing with the speed

fiery stone
polar acorn
fiery stone
#

it applies even when i articially set the CurrentDashCooldown to something greater than 0

#

without dashing at all

#

lemme show

silver fern
#

the only part with slowdown of the code thats reached when isDashing is false is the part involving the drag

fiery stone
polar acorn
#

I'm not sure what I'm supposed to be noticing different here actually

fiery stone
silver fern
#

the character moves slower while dash cooldown is more than 0

fiery stone
#

bad one

#

better

#

comparison side by side

silver fern
#

just to make sure, does it still happen if you set default for isDashing to false

fiery stone
silver fern
#

set a default value and try just in case theres a bug in the inspector or something

fiery stone
silver fern
#

aha

#

and drag is < 1 now?

fiery stone
silver fern
#

and the velocities are as they should be when it happens?

stuck current
#

What’s the most effective way to smoothly make object with body slide down walls that has a lot of force agianst a wall?

silver fern
#

lerp?

stuck current
#

Wdym?

fiery stone
flat sphinx
# fiery stone .. so division by zero would be multiplication by what?

cant translate
the relatoin between the two is defined as a/b=c implying a=b*c (example: 10/2=5, 2*5=10)
if you try that with b=0 everything breaks (10/0=x, but no number exists that multiplied with 0 gives you 10, alternatively 0/0=x, then x can be any number you want (property not shown with any other number, even 1))

silver fern
#

can you check its not doing this?

fiery stone
flat sphinx
#

do remember, division by zero isnt "it gives you infinity", its "its undefined"

silver fern
flat sphinx
#

even something like limits if converging on 0 give you different results based on where you're approaching from

#

if you're approaching from a positive number, it gives you infinity
if from the NEGATIVES, it gives you NEGATIVE infinity

acoustic belfry
#

what must be done for make the raycast to slowly follow the player instead of straight up hit it?

protected void laser(Transform laserPos, LayerMask victim, float laserDamage)
    {
        {
            Vector3 targetPosition = objetivo.position; // objetivo is the player
            targetPosition.z = 0;
            Vector3 shootDirection = (targetPosition - laserPos.position).normalized;

            RaycastHit2D hit = Physics2D.Raycast(laserPos.position, shootDirection, Mathf.Infinity, victim);

            if (hit)
            {
                Debug.Log("Enemy hit: " + hit.collider.name);
                ValeriaController player = hit.transform.GetComponent<ValeriaController>();
                if (player != null)
                {
                    // Apply damage
                    player.TakeDamage(30);  // Adjust damage as needed
                }

                // Optional: visualize the attack
                lineRenderer.SetPosition(0, laserPos.position);
                lineRenderer.SetPosition(1, hit.point);
            }
            else
            {
                // Missed, draw a line in that direction anyway
                lineRenderer.SetPosition(0, laserPos.position);
                lineRenderer.SetPosition(1, laserPos.position + shootDirection * 100);
            }
        }
    }```
fiery stone
silver fern
#

well i'm stumped, my usual approach in these cases is to print variables at every step to make sure everything is as it should be, and to remove parts one by one until I find the one thats causing the problem

shell sorrel
#

they are always instant

acoustic belfry
#

i mean following it

#

mm, i mean, like a laser

#

if is instant, it will look and feel bad an be an instakill

shell sorrel
#

think you need to break the problem down more

#

like figure out would be a case of having something turn to aim at the player over time

silver fern
flat sphinx
silver fern
#

lol

shell sorrel
#

if its that then i would just use a projectile

flat sphinx
#

thanks deno you're very useful and necessary

#

dyno
wahtevre

fiery stone
acoustic belfry
#

Holup

fiery stone
#

i can send you the entire project if you want

acoustic belfry
#

Thats a great idea

#

Wait

#

Theres an issue

I mean

#

If i did a proyectile and a line following it, it wouldnt have inf distance or it will?

silver fern
#

why would it

acoustic belfry
silver fern
fiery stone
silver fern
acoustic belfry
silver fern
#

yes

acoustic belfry
#

But wait

Using proyectiles wouldnt make that anything in the line to get hit, just what the proyectile hitted

Or you mean
Not just the line but the raycast be on the proyectiles position aswell?

#

It may work

#

I will test it

fiery stone
shell sorrel
#

or is the tracking of the laser taking time, so its always behind a moving target

#

2 very different things

polar acorn
acoustic belfry
#

In theory it should.

acoustic belfry
#

I just want a laser attack, and an instantaneus laser wouldnt do it

shell sorrel
#

ok but you are not answering much about how that should play out

polar acorn
shell sorrel
#

since there are a few approaches and people cant help without knowing which one

cosmic dagger
#

You want it to travel like Star Wars? Pew, pew . . .

acoustic belfry
#

Wut

shell sorrel
#

like a star wars one is just a projectile

acoustic belfry
#

Like James Bond

#

Is s raycast

#

That moves slow

polar acorn
#

That seems like a star wars laser to me

acoustic belfry
#

Like it should hit where the player were

#

Not was

silver fern
#

he wants a laser that gets longer slowly

#

I think

acoustic belfry
#

No

I think im messing thing up

#

I want a raycast that shots where the player were

#

I mean

cosmic dagger
#

You just described a Star Wars laser . . .

acoustic belfry
#

I want the distance instantaneus

polar acorn
acoustic belfry
slow blaze
#

How do I get the mouse position local to a specific parent

hexed terrace
#

'tisn't lasers in SW, it's "bolts of super-heated plasma or energised gas" 🤓

polar acorn
acoustic belfry
#

No

#

I want the distance to be instaneus

#

I want the angle

#

To be slow

cosmic dagger
#

Angle? 🤔

acoustic belfry
#

Like if you pointed with a laser not to a potato, but you rotated your hand slowly to the potato

silver fern
#

movement of the ray

polar acorn
#

Okay, so multiple raycasts

acoustic belfry
#

Wat

polar acorn
#

With a delay between each

shell sorrel
polar acorn
#

So you'd do a raycast and then after a frame do another raycast at a different angle

acoustic belfry
#

Its on update btw

#

This raycast thing

#

So yeah

polar acorn
#

A raycast is instantaneous, you can't "move" a raycast, you just make a new one

silver fern
#

I think applying rotation to the raycast is probably better

shell sorrel
#

You raycast each frame in a new direction

acoustic belfry
#

I want the raycast to hit where the player was then

shell sorrel
#

They direction is moving overtime to the direction of the target

acoustic belfry
#

Yes i know that, it updates

#

Is just that i explained myself wrong

#

But now i think i know how to fix it

#

Tho i dobt know how to write it

#

I mean

#

I need a raycast that hits whenever the player was

#

So it would follow it

#

If we make a lot constantly

elder hearth
#

Guys, how do you make it so your camera doesnt move up/down/left/right with your mouse with the slightest tap? Would you just make it so only after a certain value it starts moving or is there a different way of doing it?

shell sorrel
#

Lerp it's raycast direction between the last one and the player location so it turns over time

acoustic belfry
#

Oh! Thanks

elder hearth
hexed terrace
#

that just sounds like your sens is too low

scarlet skiff
#

how can u get a list of all the children of a gameobject? i only see get child or get child by index

rocky canyon
#

for loop thru them all

polar acorn
rocky canyon
cosmic dagger
#

Looop over the transform of the GameObject . . .

slow blaze
#

How can I get the position of the MouseCursor relative to a parent
like it's always (x = 3 , y = 1, z = 5) relative to the parent even though it's moving to the world

#

well no z ig

polar acorn
calm ice
#

hi! im learning C# and unity, can someone tell me what's the best place to start ?(also sorry if my english is bad, its not my first language)

hexed terrace
#

See the pinned msgs and also 👇 !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

polar acorn
# fiery stone

I have dropped your code into a fresh project and come to the conclusion that this is either psychosomatic or framerate-related and there is no difference.

I made three objects at different starting points. One of them had the script you provided as-is. One of them has the script you provided, but with its current dash cooldown set to 999999. One of them had a modified copy of that script with everything related to dashing and cooldowns removed.

All three moved completely identically. They were in perfect sync at all times until I dashed, at which point, the two that had dashes still did their dash and remained synced with each other.

silver fern
#

I did actually find one issue

#

possible issue anyway

fiery stone
silver fern
fiery stone
#

i think

silver fern
#

add a check like that to keep your values from going into unnecessary ranges

polar acorn
silver fern
#

but yeah I made the velocities public and the values were the same with or without cooldown

fiery stone
polar acorn
#

I ran it with and without dashes and everything remained synced

fiery stone
#

thats wierd

silver fern
fiery stone
#

oh well

#

if its just something on my end its probably just me seeing things

fiery stone
#

huh

#

also

#

moving on

polar acorn
#

Top is unmodified.
Middle is given a dash cooldown as shown in the video.
Bottom is custom script with no dashing whatsoever

fiery stone
#

how do you do smooth turning towards another object

#

like a player seeking projectile

silver fern
#

smooth how

fiery stone
silver fern
#

lerp

fiery stone
fiery stone
#

like in this?

#

where its just Time.time?

polar acorn
fiery stone
silver fern
#

deltatime

fiery stone
#

alright

#

wait

polar acorn
#

You'd probably want it to slowly increase from 0 to 1 over time

silver fern
#

you can multiply time with speed to change the how fast it turns

slow blaze
#

I can't call the function properly I think I'm missing something

polar acorn
silver fern
#

I think you mean th4n0id

slow blaze
fiery stone
polar acorn
polar acorn
#

So if it were 10 units directly above this object, it'd return 0, 10, 0

#

Even if that virtualKeyPosition is actually at something like 120, 44, 318

silver fern
fiery stone
silver fern
#

maybe quaternion lerp is useful

#

depending on what exactly youre doing

fiery stone
silver fern
#

then recalculate the angle when it changes and lerp to that

tiny crag
polar acorn
languid pagoda
#

How do racing games handle their ai? Like are they just simulating input to get the cars to move toward waypoints and using raycasts to avoid ramming other vehicles?

tiny crag
#

right?

silver fern
languid pagoda
silver fern
polar acorn
tiny crag
tiny crag
#

but not when its supposed to write in the console from the method

#

the movement method

polar acorn
#

What calls movement?

tiny crag
tiny crag
#

and the two messages are different

#

in the console

polar acorn
#

How is it referencing the one in the scene?

silver fern
# languid pagoda Such as?

for example, you could properly simulate the whole race for every car, or you can use a simplified representation in memory, or you can just not do anything when the ai cars are offscreen and periodically put them behind the player

#

there are many ways

tiny crag
#

i forgot to comment that the method is being called on row 88

polar acorn
silver fern
#

components are parts of objects

tiny crag
#

also what does "set to" mean? isnt the method supposed to run when its called

#

isnt it that simple?

polar acorn
polar acorn
tiny crag
#

i think ive misunderstood what scriptable objects are

tiny crag
polar acorn
polar acorn
tiny crag
#

in which movement() is supposed to run

polar acorn
tiny crag
#

im sorry but i really dont understand could you give a brief example

polar acorn
#

I mean

#

what is the value

#

that you set the variable enemyScript to

#

I cannot make this easier

#

Variables are containers that hold value

#

what is the value this container holds

tiny crag
#

i did this: [SerializeField] EnemyScript enemyScript;

#

and then i dragged in the enemy prefab code

polar acorn
polar acorn
#

So you're calling movement on the prefab

#

The prefab that never exists in the scene

#

and never has Awake run on it

tiny crag
polar acorn
#

but they never get movement called on them

tiny crag
#

as in that they were not assigned a value

#

but the movement method is being run

polar acorn
#

You are spawning copies of the prefab.
These copies do exist in the scene, so they do run Awake.
But nothing ever calls movement on them.

tiny crag
polar acorn
tiny crag
#

how do i then make it so that only clones exist and that they each run awake and movement?

polar acorn
slow blaze
#
_virtualKeyPositionLocalToPlayer = player.trasnform.InverseTransformPoint(Input.MousePosition);
                if (Input.GetMouseButton(0))
                {
                    points.Add(new Point(_virtualKeyPositionLocalToPlayer.x, -_virtualKeyPositionLocalToPlayer.y,strokeId));
                    currentGestureLineRenderer.positionCount = ++vertexCount;
                    currentGestureLineRenderer.useWorldSpace = false;
                    Vector3 drawPoint = 
Camera.main.ScreenToViewportPoint( new Vector3(_virtualKeyPositionLocalToPlayer.x,_virtualKeyPositionLocalToPlayer.y, 10));
                    currentGestureLineRenderer.SetPosition(vertexCount - 1, drawPoint);```
I don't get what's wrong with this trying to draw using a lineRenderer based on Mouse's position relative to the player, the drawing of the lineRenderer is supposed to move with the player and not be disturbed by movement up and down or anything.
#

and I dunno why discord ruined the code like that lol

tiny crag
#

Or wait

#

would it work if i didnt do serializefield

#

and if i tried to define enemyScript via code?

#

then the movement method should connect to all gameobjects that have the class EnemyScript in them right?

polar acorn
#

Not the prefab

tiny crag
#

is it an idea worth of pursuit?

polar acorn
#

I don't know what solution you're proposing

silver fern
#

do what digiholic said

tiny crag
#

look i understand that the movement method is only being run on the prefab, thats what digiholic has told me so far

#

what im after is a solution

polar acorn
#

Call it on the objects that you spawn. The ones that actually exist.

tiny crag
#

yes im trying to figure out how i can do that

polar acorn
#

Instantiate returns a reference to the object it spawns

silver fern
#

objecttype variablename = prefab.Instantiate()

tiny crag
#

My idea for a solution is to define enemyScript like this

EnemyScript enemyScript;

void Awake()
{
enemyScript = GameObject.Find("Enemy").GetComponent<EnemyScript>();
}

would this not reach every object that spawns with that code file in it?

silver fern
#

then you can variablename.movement()

slow blaze
polar acorn
#

You can just check what these functions do by the way, you can look them up

tiny crag
#

so it would not find every object named Enemy

silver fern
#

yes

slow blaze
#

Just one

silver fern
#

abandon this idea

polar acorn
#

you have the references

#

Instantiate returns the references to the objects it makes

#

Use them.

tiny crag
#

ill look into this idea

#

all ive learned about instantiate so far is that it spawns things, not that i can send signals to these spawned objects

#

but thx everyone

shell sorrel
#

it gives you the reference to the thing it spawns

#

with that reference you can get anything on the object and do what ever you want with it

#

most people would create a list to hold references to all enemies you spawned then you have access to all of them

slow blaze
#

does
LineRenderer.SetPosition(index, position);
can it work on Local Positions?

#

LineRenderer.SetPosition(vertex-1, new Vector3(0,1,0));
Can this be (0,1,0) be a position relative to a parent or does it have to be world position?

frail hawk
#

try it out

slow blaze
#

well I did

#

and it's world position as far as I can gather

shell sorrel
#

there is a toggle on it

#

to use worldSpace or local space

#

just turn off use world space in the inspector

slow blaze
#

oh

#

so now position will take the localSpace of the parent of the gameObject or do i have to pass something in?

shell sorrel
#

works with the same values

#

the toggle effects both poitns added in code and ones added in the inspector

slow blaze
#

I mean like,
if the LineRenderer's gameObject is not a child, it will also use world space?

shell sorrel
#

not sure what you mean by that

#

but the points in a line renderer work in world space or local space to the line renderer object

#

via that toggle

#

if you need anything more specific then that like putting something in local space of a other object that is not the one the renderer is on then i would just use world space and get familar with the TransformPoint and InverseTransformPoint methods on transform

slow blaze
#

yeah I got you I just misunderstood something

slow blaze
# shell sorrel if you need anything more specific then that like putting something in local spa...
_virtualKeyPositionLocalToPlayer = player.transform.InverseTransformPoint(Input.mousePosition);
Transform tmpGesture = Instantiate(gestureOnScreenPrefab, player.transform, worldPositionStays:false) as Transform;
points.Add(new Point(_virtualKeyPositionLocalToPlayer.x, -_virtualKeyPositionLocalToPlayer.y, strokeId));
currentGestureLineRenderer.positionCount = ++vertexCount;
currentGestureLineRenderer.SetPosition(vertexCount - 1, _virtualKeyPositionLocalToPlayer);```
So this is the script I'm trying to use to draw a gesture with my mouse that moves with the player on screen but doesn't get jagged or disrupted from the player's movement
#

has a problem where it draws yes, follows the player, but the scale is horribly off and it doesn't draw on the mouse position

shell sorrel
#

ok so first things first

#

your camera

#

perspective or ortho?

slow blaze
#

Ortho

#

the camera follows the player everywhere with a little offset

shell sorrel
#

so jsut converting mouse position with the players transform does not make a whole lot of sense

slow blaze
#

I thought that would return the mouse's position relative to the player's transform?

shell sorrel
#

no because mouse position is in screen space

silver fern
#

you need Camera.main.ScreenToWorldPoint(mousePosition)

slow blaze
#

Oh yeah lemme try that rq

shell sorrel
#

that method also only works for ortho cameras since it gets a point on the camers near plane

silver fern
#

you may want to set your mouse position z coordinate to Camera.main.nearClipPlane

shell sorrel
#

yeah can just make it a tiny number

#

or make it a control so you can decide how projected out from the camera the point should be

slow blaze
#

yeah it works thanks guys

patent wedge
#

i know it's network related but i don't want to make an entire thread just to ask how to convert networkvariable<bool> to a proper bool?

shell sorrel
#

networkVar.Value

slender nymph
junior ivy
#

I have a 2D tile based game. Every tile has collision, material and some properties.
If my game has 200x200 visible tiles, am I supposed to create 40000 game objects?

hallow acorn
#

have you heard of tilemaps before?

junior ivy
#

yes but I instantly ignored them after I realized they are not scalable

#

what if I want to have 200x200 visible tiles but 20000x20000 tile map

hallow acorn
#

i want to see you make a tilemap this big this would take forever

junior ivy
#

doesn't matter, maybe I want much more, like 100k x 100k

hallow acorn
#

i think i still dont get what you mean. tilemaps are basicly infinite only depends on how much you "draw" onto it

junior ivy
#

every tutorial I watched said something different, built-in tile maps are not infinite

hallow acorn
#

whatever then do it with 40000 gameobjects

#

tilemaps are the solution that everyone uses because it works for anyone

junior ivy
#

it's not whatever, if you say they are scalable, maybe I watched crap tutorials

#

generally 95% of unity videos are soooo useless

hallow acorn
rocky canyon
#

good luck w/ a 100k² tilemap

#

ud def want some type of chunking / procedural streaming

#

Fun fact: games like Stardew Valley, Terraria, or Factorio have millions of tiles but only a fraction are ever instantiated as actual objects in the scene at once.

junior ivy
#

I absolutely don't care what others do. I just want ot know if I can scale built-in tile maps

hallow acorn
#

may i ask what you need a tilemap this big for?

rocky canyon
#

then you do care.. else why ask and just do ur own thing

#

a tilemap like that is gonna tank performance.

junior ivy
#

you are not "others", I do care what you think

rocky canyon
#

ahh soo "others" as in non-game-devs

#

can you explain a bit by what u mean by "scale" when ur refering to tilemaps?

rocky canyon
#

lol.. at that point they'd be 2-3 pixels across 😄

flat sphinx
#

if no, dont instantiate them all at once, if yes, you're probably doing something wrong

#

game dev 101 is not instantiating the entire map all at once

rocky canyon
#

lets see how long it takes to generate

flat sphinx
#

you'd need to ask someone smarter than me in how to do that tho
the only solutuions i know are rawdogs

hallow acorn
junior ivy
#

you miss the whole point of what I want
instead of asking something important you ask about amount of rendered tiles or map size
that's why I said 200x200 or 100k x 100k to show you that numbers doesn't matter

if I said that I have 10x10 visible tiles and 100x100 map, you would start to intruducing some f*cking crap solutions I've seen 100 times already on youtube

flat sphinx
#

you didnt exactly clarify on what you want

junior ivy
#

I will do doc research about these built-in tile maps, maybe they aren't that bad as I thought

flat sphinx
#

and the solution does depend on your scale

rocky canyon
hallow acorn
#

what are your specs tho?

rocky canyon
flat sphinx
#

if its a small map (64x64 or whatever) just instantiate everything at once
if its larger, store the type of tile in some list array whatever and init when entering your viewport
if its infinte then generate on the fly

hallow acorn
glass ivy
#

Claude ❤️

rocky canyon
flat sphinx
# glass ivy Claude ❤️

why do you want them sorted by distance anyways
just store their refs and compare distance when you actually need them

rocky canyon
hallow acorn
# rocky canyon

those specs arent even that crazy im running a 2070 super and ryzen 5 5600x

rocky canyon
hallow acorn
rocky canyon
#

the 12 gig of Vram is a decent flex imo

#

the rest is meh

hallow acorn
#

yeah thats pretty good actually. my flex are 32gb ram

midnight pumice
#

i need help with the unity microphone class (idk if this is the right channel, i cant find a programming help channel)

rocky canyon
#

yes this is a programming channel u can ask questions in.

#

yes the microphone class would be included..
!ask

whats the question?

eternal falconBOT
midnight pumice
#

because the mic doesn't follow these parameters the receiving clients aren't reading the data fast enough or reading it correctly

glass ivy
#

frequency of update > when nearby player

flat sphinx
#

if its less than uhh half a thousand? just sort on the fly

#

(number pulled out of my ass)

midnight pumice
flat sphinx
#

distance isnt really something you can easily re-sort

hallow acorn
#

hey i have a softbody made up of points connected with spring joints, but if i change the rotation for example, its like the springs loose all their tension. is there something i can do about this?

midnight pumice
hallow acorn
glass ivy
flat sphinx
#

fair

glass ivy
#

context is unity pathfinder, that underspecced blackbox is a nightmare

flat sphinx
#

i once got deepseek to say something summarizing to "this is absolutely insane but if you do this you'll be forever revered by [community]. godspeed."

#

lemme dig it up hol on

balmy vortex
#

why does the value of the additional gravity here not matter past a certain point? and also how do I stop the upwards momentum the player has after jumping when trying to fast fall?

errant valley
#

I want to implement a system where the player hits a tree with a rock, the tree loses HP and is destroyed at 0, how can I handle this with boxcollider?

void Update()
{
    if (Input.GetMouseButtonDown(0))
    {
        animator.SetTrigger("Hit");
        boxCollider.enabled = true;
    }
    else
    {
        boxCollider.enabled = false;
    }
}
eternal falconBOT
eternal needle
#

you also shouldnt use a box collider there if its just supposed to be a 1 frame check, just use one of the physics methods like OverlapBox

balmy vortex
eternal needle
# balmy vortex https://paste.mod.gg/hfdtbgbxlbul/0

using addForce and setting the linearVelocity directly elsewhere probably isn't helping here, i would change this to just use add fastFallGravity to the linearVelocity instead.
also you dont need to GetComponent, you're already storing and using the rb in other parts of your code

#

as for stopping the upward momentum, you could just directly set the linear velocity so the player starts falling immediately like you do with the jump already. It might look very sudden to the user though

balmy vortex
#

ty king

lethal meadow
#

its better than most AIs but thats not saying much

hallow acorn
#

hey i got a softbody system i made and it also has background color made by creating a mesh of the individual points of the softbody. when the object is rotated even before hitting play, the mesh doesnt really want to cooperate and it looks like as if it rotates with the object, but twice the amount. what can i do about this? heres what it looks like and the code i use for making the mesh (which also isnt perfect) https://hastebin.skyra.pw/jiketohula.csharp

silver fern
#

how do you rotate it

hallow acorn
#

transform in inspector

grand snow
#

how is the mesh updated?

glass ivy
hallow acorn
# grand snow how is the mesh updated?

what do you mean exactly?

private void Update()
{
    CreateShape();
    mesh.Clear();
    mesh.vertices = verts;

    if(tris != previousTris)
    {
        mesh.triangles = tris;
        previousTris = tris;
    }
    mesh.RecalculateBounds();
    mesh.uv = uv;
}```thats the update function if it helps
grand snow
#

you cant compare arrays like that btw thats just a reference comparison

hallow acorn
grand snow
#

as long as the mesh origin matches the other objects origin and vert positions are local it should update correctly

#

but to compare array contents you can loop and compare both

hallow acorn
lethal meadow
#

why do you need to check each frame it worked?

grand snow
hallow acorn
grand snow
#

erm no

#
int[] a = {1,2,3};
int[] b = {4,5,6};

bool areSame = true;
for(int i = 0; i < a.Length; i++)
{
    if(a[i] != b[i])
    {
        areSame = false;
        break;
    }
}

if(areSame)
{
    //Do shit
}
hallow acorn
#
for(int i = 0; i < tris.Length; i++)
{
    if (tris[i] != previousTris[i])
    {
        trisUpdated = true;
        break;
    }
}
if(trisUpdated)
{
    mesh.triangles = tris;
    previousTris = tris;
}```like this?
#

forgot including trisUpdated is a local variable being false by default

ivory bobcat
#

Did you perhaps want to use i+1 for lines 32 and 33 as well or ...

hallow acorn
#

line 32 is more of a relic forgot to delete that. the vector2 vert is used for nothing

hallow acorn
ivory bobcat
#

If you're wanting to add 0.5f every time, you'll need either value 1 or 2 to be 1f or 2f.

#

If you're wanting to divide after adding one, you'll need to use parenthesis (verts[i].x + 1f) / 2f.

stuck current
#

Please help me, I’m using a invisible player object to handle movement but I want another hovering over it to serve as the display and be posilhed. This mesh can be pushed to the floor but I have no idea where to start

#

I’m in 2d btw

silver fern
#

what

grand snow
#

wat

ivory bobcat
#

This is the beginner coding channel, if the issue is directly related to code you'll need to post more context (!code)
Else try one of the other channels id:browse

eternal falconBOT
grand snow
hallow acorn
#

while i did improve a lot of things about my code i still dont have the solution to my original problem though

silver fern
#

did you check the first thing rob told you

#

about object origins and positions

hallow acorn
#

didnt get it but i fixed it right now

silver fern
#

what was it

hallow acorn
# silver fern what was it

just had to change line 34 from verts[i+1] = points[i].position - transform.position;
to verts[i+1] = points[i].localPosition;

rich adder
wintry quarry
hallow acorn
stuck current
echo ravine
#

idk if this is begginer, but I am
I am using Mathf.PerlinNoise and I noticed that it rarely reaches the edges(mind it is 2d side viwe, so I only need a 1D perlin noise, using 2d for seeding purposes)

int layerYPerlinDelta = 2;
for (int x = 0; x < 70; x++)
{
    int perlinSample = Mathf.RoundToInt((2 * layerYPerlinDelta + 1) * (Mathf.PerlinNoise(perlinScale * x, perlinSeed) - 0.5f));
    //below is +layerYPerlinDelta and not +layerYPerlinDelta+1, since it's a float function
    perlinSample = Mathf.Clamp(perlinSample, -layerYPerlinDelta, +layerYPerlinDelta);
    Debug.Log(perlinSample);
    //(i'm not actually debug logging, but it works)
}

If the distribution was uniform, this would give me a pretty decent world terrain
But it rarely hits 2 or -2(i never saw it hit -2)
ChatGPT suggested i raise it to some exponent, which is a pretty god idea, but is the problem with perlin noise or my code(i think my code is fine)

frigid iron
#
public class SpawnSteak : MonoBehaviour
{
    public GameObject steak;
    public GameObject cookedSteak;
    private GameObject spawnedInstance;
    public AudioSource soundPlayer;
    public AudioSource soundPlayer2;
    public float timeBegin = 5f;
    void DestroyObject(){
        Destroy(spawnedInstance);
        soundPlayer.Stop();
        Instantiate(cookedSteak);
        soundPlayer2.Play();
    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    public void OnMouseDown(){
        spawnedInstance = Instantiate(steak);
        soundPlayer.Play();
    }

    // Update is called once per frame
    void Update()
    {
        if (spawnedInstance != null){
            Invoke("DestroyObject", 5f);
            //CancelInvoke("DestroyObject");

        }
    }
}

#

This code is meant to instantiate an object, destroy it after 5 seconds, and instantiate a new one. But after five seconds, it keeps instantiating multiple clones of the new object, how do I make the invoke method only perform the action once?

rocky canyon
frigid iron
rocky canyon
#

option 2 use a coroutine

silver fern
#

cant you just check for a state

frigid iron
rocky canyon
silver fern
#

or use a different kind of noise

rocky canyon
#

so it just spammed the Invoke over and over until it was eventually gone.. by calling it at the end of the OnMouse method ur ensuring its only gonna run once.. just as its instantiated once

frigid iron
rocky canyon
#

srry bout the rogue ping.. meant to ping enegaga

#

explains perlin pretty well

silver fern
rocky canyon
#

oh dang..

#

ya im just realizing theres soooo many different types of noise

compact sundial
#

why is my potion not being set active? I am creating it during runtime so instantiating it

public void SpawnSmallManaPotionPrefabForPlayer()
    {
        if (hasSmallManaPotion == false)
        {
            Quaternion rotation = Quaternion.Euler(0, 0, 0);
            smallManaPotionClone = Instantiate(smallManaPotionPrefab, rightHandOffsetObjectTransform);
            smallManaPotionClone.transform.rotation = rotation;
            smallManaPotionClone.transform.position = rightHandOffsetObjectTransform.transform.position;
            hasSmallManaPotion = true;
            hasDrinkable = true;
            smallManaPotionClone.SetActive(false);
        }
        

    }
    public void RecoverManaFromSmallPotion()
    {
        if (hasSmallManaPotion == true && hasDrinkable == true)
        {
            smallManaPotionClone.SetActive(true);
            hasSmallManaPotion = false;
            extendedCharacterController.currentMana = Mathf.Min(extendedCharacterController.currentMana + 30, extendedCharacterController.currentMaximumMana);
            

        }
    }
eager elm
rigid pike
#

i will be making a game where money can reach above googol (10¹⁰⁰). I searched how to store that and found "BigInteger". Is that a good way to do the money calculations or should i do it different way?

rocky canyon
#

logs are the solution in this case ^ log each method, each if statement, and jst see

rocky canyon
silver fern
#

if you dont actually need exact precision you can also fake it

rocky canyon
#

^ this.. could use a big multiplier..

echo ravine
compact sundial
#

lol I found the problem, I have it set to if I have a below the maximum amount of mana, the function will be run but if it is full then it wont run so basically it was a human error

silver fern
#

classic pebkac

rocky canyon
#

its human error almost 99.9% of the time 😅

compact sundial
#

u know what I mean tho

#

it wasnt a code error

rocky canyon
#

logic error

#

always helps to debug everything
odds are you'll be like "wait, where is.. x,y,z?"

compact sundial
#

sort of, I just had full mana when I tried to activate the Recover function

#

cuz I forgot to use up some mana before trying it

summer wren
#

If I set InputFields line type to multi line and give it a ContentSizeFitter with vertical preferred size, the text jumps up a little when I click enter for new line
It is set to top left anchor

subtle bronze
#

is there any way to use python with unity without spending money for an asset? it's what im used to using because im just a hobbiest and cs is atrocious

subtle bronze
#

fml

sour fulcrum
eternal needle
shell sorrel
# subtle bronze fml

if you already got a grasp on python, learning a other langauge will be no big deal

tiny crag
#

how do i access the code of an instantiated object

#

i have methods that i want to access in instantiated prefabs

keen dew
#

Didn't people spend almost an hour yesterday to go through this

#
SomeComponent clone = Instantiate(prefab).GetComponent<SomeComponent>();
clone.SomeMethod();
tiny crag
frail hawk
#

all you need to do is to cache the GameObject or any of its components, as Nitku showed, you are caching the Component here, if you would the whole GameObject so you can acces all of it you could simply do
GameObject instantiatedGo = Instantiate(.....);

#

then acces its components by doing instantiatedGo.GetComponent<SomeComponent>();

naive pawn
#

well, it's fine, but it could be better

#

for something like that you should have prefab be typed as the component directly

#

makes it foolproof @tiny crag ^

(cc @frail hawk)

tiny crag
#

there are a lot of things i dont understand in your replies, what would be the best way to learn more?

#

because i think this project is beyond me at this point

frail hawk
#

then you will have to start small and learn the c# basics

tiny crag
#

i watched two tutorial series on c# in unity, but i didnt finnish them because at that point i didnt understand what they were talking about

#

so i decided to try and make a simple game to reinforce what i had learned so far

#

what i wanted to make was a game where the player was a cube avoiding other cubes coming from the edges of the screen

#

it worked but the spawning and movement between all the objects were not synced, an idea i tried to realize by making a new project and changing the code

#

i think im gonna do the tank game tutorial made by unity for now and maybe come back to this project in the future but thanks a lot for trying to help me!!!

frail hawk
#

if you are not experienced in programming i would recommend you learn some basic c# instead of unity c#

grand snow
#

Yea c# and programming in general should be learnt and understood on its own if a total beginner

tiny crag
#

i have made projects in python, whereof the most advanced one was a poker bot that typed out probabilities and made decisions for poker

#

i also made a simple game in pygame

grand snow
#

Then it should hopefully make sense how we spawn new objects and can get components of those instances

tiny crag
#

the idea of accessing components is entirely new to me

#

so is coding with classes

grand snow
#

Its nothing crazy. You know what a gameobject is and components are right? You can add your own "scripts" to gameobjects but these scripts are also components.

#

Well when we spawn in a copy of a prefab we want to get those NEW components and do stuff with them, thats what GetComponent() is for.

tiny crag
#

maybe then its not the concepts but the code that i dont understand

grand snow
#
GameObject myCoolPrefab = Resources.Load("MyCoolPrefab");
GameObject spawnedObject = Instantiate(myCoolPrefab);
Light light = spawnedObject.GetComponent<Light>();
#
  1. Load prefab from resources folder
  2. Spawn copy of prefab in our scene
  3. Get reference to Light component from our new copy
tiny crag
#

thank you, this made it very simple!

grand snow
#

we can use a serialized reference of a prefab instead which is often preferred

[SerializeField]
GameObject myCoolPrefab;
tiny crag
#

yes but i did run into an issue when i used this on a prefab
apparently the prefab already existed but not the gameObject with the code that i was trying to apply to the prefab though a serialized reference

#

but thanks a lot rob5300

grand snow
#

well yea if you try to modify the prefab asset instead then you will be confused

#

so make sure to not do that and name things well so its obvious whats the "prefab asset" and whats the created instances in scene

tiny crag
#

yes i will

rigid swallow
#

what is the point of creating a private variable to then create a public variable referencing the private one?

grand snow
rigid swallow
#

oh like a getter and setter?

distant aurora
rigid swallow
#

alr thank you

primal tree
#

I'm currently getting the following error -

Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak
I've set Unity to output JobTempMemoryLeakValidation, but I'm a bit lost as to where the error is. Can anybody help me out here?

primal tree
#

Thank you! I'll repost there.

versed fjord
#

when I hit a breakpoint in Unity with vscode, the entire vscode is not visible for my mouse in Linux and Windows

#

what kind of crap is this man

#

I am not able to continue execution or do literally anything. I have to kill Unityand restart again until I hit another breakpoint.

#

same with Unity window, also not visible for mouse

junior ivy
#

how to dump a class to the console in unity?

there is a God tier function in php called dd which prints everything

example:

class A
{
    public string $str = "aaaa";
    private int $i = 123;

    public function __construct(public B $b = new B()) {}
}

class B
{
    public string $bField = "bbbb";
}

dd(new A());

result:

#

Now I need something like this in unity. Debug.Log is nothing near dd

keen dew
#

C# is a compiled language so it's not quite as simple. Use the IDE's debugger to inspect objects

rocky canyon
# junior ivy how to dump a class to the console in unity? there is a God tier function in ph...

not sure about the formatting that u want
but couldnt u do something like

        [SerializeField] private string scriptFileName = "ScriptDumper.cs";


        [ContextMenu("Dump Script")]
        private void DumpScript()
        {
            string path = Path.Combine(Application.dataPath, scriptFileName);
            if (!File.Exists(path))
            {
                Debug.LogError("Script file not found: " + path);
                return;
            }

            string[] lines = File.ReadAllLines(path);
            for (int i = 0; i < lines.Length; i++)
            {
                Debug.Log($"{i + 1:000}: {lines[i]}");
            }
        }
    }```
keen dew
#

I'm pretty sure they want to see the current values of object fields and properties, not the class source code

balmy vortex
#

setting the vector 3 to smth rly low like -1 doesn't help either

rocky canyon
rocky canyon
#

could try making the ground collider a bit bigger (use a cube as the collider rather the plane)

#

also use ur ground-check as an advantage...

#

if not grounded -> do the gravity fast fall or w/e
if is grounded -> keep the gravity a concrete value.. like -9

        // Vertical movement (Y)
        float vertical = currentVelocity.y;

        if (controller.isGrounded && vertical < 0f)
            vertical = groundedGravity; // Stick to ground
        else
            vertical += gravity * Time.deltaTime; // Apply gravity``` like so
red igloo
#

I have this issue where when I am not grounded the player speed is very fast. to fix this should I reduce input, and boost the down force a bit? or Apply a different force when in the air? I see so many people talking about different methods but don't know which one to choose.

Script: https://paste.ofcode.org/Vh8qzd39PF3xvBUeVS3w2Q

rocky canyon
#

people usually change out the drag/ dampening values

red igloo
rocky canyon
#

depending on air or ground

ground = smaller value (because of friction helping out)
air = bigger value (to simulate air drag)

rocky canyon
#

so the lateral movements are nerfed but u adjust the gravity to work w/ those new values

red igloo
rocky canyon
#

i actually do it that way for my controller..

air has its own values

#

ground has differ values

rocky canyon
keen dew
#

If you've already found different solutions then try them out and pick the one that works for you. That's why there are so many of them because it depends on the game which one works the best

rocky canyon
#

^ theres no real one solution fits all type of deal

#

unity's gravity is kinda floaty imo anyways

#

i use strong gravity forces

balmy vortex
rocky canyon
#

groundedGravity is the concrete value

#

it stays the same... like -9 , -9, -9 all the time

#

the Simulated gravity is when im airborne.. its compounded

hallow acorn
#

hey i was wondering if there is a way to make a gameobject through code that exists after leaving playmode would be really usefull, thanks in advance

red igloo
rocky canyon
#

-9 -9 = -18 -9 = -27 so on

rocky canyon
#

its just a trial and error game..

you have ur logic.. (either u stick to that logic or adapt it)
but w/e you do ur values will need to be fine-tuned to that logic

#

if u change the logic.. u then need again to change and tune the values of the rigidbody/friction/code values etc to make it work

#

mine wont be the same as urs.. urs wont be the same as someone elses..

rich adder
hallow acorn
rocky canyon
#

heres ur options

  • seperate ground / air movement and values
  • adjust drag/ dampening (by state)
  • custom gravity (forces stronger when airborne)
  • hybrid approach (air input reduced, air drag a bit higher, gravity slightly boosted
    (makes jumps snappy, reduces mid-air "Ice-skating"
#

it most likely will be a hybrid of those... (depending on whats good enough for ur controller)

rich adder
rocky canyon
#

helps to start with some normal feeling values.. and then tune them very slowly.. (just minor increments)

hallow acorn
rocky canyon
#

you absolutely can..

hallow acorn
#

HOW???

rocky canyon
#

in this example ^ im using the ContextMenu

hallow acorn
#

this is so fucking cool i didnt know you could do that

rich adder
rocky canyon
#

editor scripting is a rabbithole tho..

#

dont fall in 🤣

rocky canyon
#

u can make the code create this object under a parent container.. and just delete that container and try again insteed

rocky canyon
hallow acorn
#

ill definitely try this thats so cool

rocky canyon
#

i'd def try to introduce it into ur work-flow somehow

hallow acorn
#

hey if i want to makee an array of coordinates (in 2D) for individual points, how can i do that through code for example if i want to make a square with 16 points, how can i distribute the 16 points evenly and place those points on the square? idk if its clear what im trying to say but i hope so

rocky canyon
#

bunch of math 😅

#

division mainly

hallow acorn
# rocky canyon division mainly

probably dividing the perimeter of the shape by the number of points to distribute them evenly but i have no idea how to go on with the rest of it

rocky canyon
#

yup something like that..
you'd probably want to figure out how many rows / columns u'd need
get the corner somehow.. and then space out that number of items

#

im bad at those kind of setups. soo thats bout all i got to give 😅

teal viper
#

x * y = totalPoints

#

Then it's just simple math.

neon forum
#

!code

eternal falconBOT
rocky canyon
#

1. Pick how many points you want total (example: 16).

2. Pick how big the square is (example: width = 10, height = 10).

3. Figure out how many points should go on each side of the square.
   (take totalPoints ÷ 4).

4. Write down the four corners of the square.

5. For each side of the square:
     - Start at one corner, end at the next corner.
     - Evenly space the points between those two corners.
       (search term: "linear interpolation between two points")

6. Collect all the points into a list or array.
``` @hallow acorn **edit**- *wait!, this is just for a perimeter
```fix
1. Pick how many points you want total (example: 16).

2. Decide if you want them arranged as a grid 
   (example: 4 × 4 points).

3. Pick how big the square is (width/height).

4. Figure out the spacing between each row and column.
   (square size ÷ (gridCount - 1)).

5. For each row (y-axis):
     For each column (x-axis):
         Place a point at (x, y) position.

6. Collect all these points into a list or array.
``` ^ this would include the fill
hallow acorn
rocky canyon
#

it'd basically be the same as making a 2D grid (since its a square Exactly the same) w/ nested loops

rocky canyon
hallow acorn
rocky canyon
#

then u'd have ur list or array to pull the points from (w/ the index)

neon forum
#

I have a slight UI issue, when I click the card in the right most panel(available cards), it adds a new instance of a card prefab to the middle.
The deck list is saved and stored and is accurate when it comes to how many times I clicked the test card.
The issue is the UI does not reflect this accurately, ex I clicked 14 cards the decklist has 14 instances but the UI only displays 11. Another issue is that when the refresh is ran, the cards sometimes appear in the wrong order(There should be enough space for 3 across, but it skips the third slot and jumps to slot 4 for some reason. It also just flat out removes a card when the logic should be add card.
Code: https://paste.mod.gg/ytojakcfidjt/0
first screenshot is 3 cards in current deck, second is when the fifth card is added.

rocky canyon
empty pulsar
#

What’s the best way to learn csharp

#

I’m getting a book about it

naive pawn
#

there are resources pinned

empty pulsar
#

Oh ok thx

neon forum
#

should I post this in UI-ux instead? i feel like it's a coding issue and the ui can't keep up

halcyon lion
#

if I am completely new to coding and the Unity software should I install 6.2 or is there a better version to get started with?

cosmic quail
#

and check out !learn

eternal falconBOT
#

:teacher: Unity Learn ↗

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

keen dew
#

Use the same version that the course or tutorial you're following uses

halcyon lion
#

I'm on the learn tab but it said to choose a version so I was unsure thanks for clearing that up

halcyon lion
#

now that I have done the unity hub and editor tutorials what should I do next? should I look up c# tutorials or more unity ones?

cosmic quail
halcyon lion
#

at what point should I start learning the code?

cosmic quail
rich adder
#

It doesn't teach c# fundamentals

halcyon lion
#

wait do the learn tutorials go from foundation to beginner?

cosmic quail
#

okay then i'd check out the pins and learn the basics of c# right now

rich adder
#
neon forum
languid pagoda
#

the ui can definitely keep up

#

I have an advanced vehicle telementary running in a physics substep system and am updating the ui 100 times every fixed update

neon forum
#

okay, then why is it specifically always erroring out on the 5th object?

languid pagoda
#

oh wait you did show us code

neon forum
#

I did

#

lol

languid pagoda
#

let me go look my bad

#

so its skipping the 3rd slot and filling in slot 4, how is the 3rd slot being filled in the second screenshot? is it just adding the next card there instead next time you draw?

neon forum
#

so basically clicks one and two work perfectly fine

#

on click 3, the slot that SHOULD be where the card goes is skipped

#

if

#

[]

#

is to represent the card

#

its like [1]. [2]. [skipped]
[3]

#

but then when I click it the 5th time it ends up like this:
[1] [2] [5]
[3] [4]

languid pagoda
# neon forum yes

show me the specific code where you are assigning what slot it goes to

neon forum
#

I don't assign slots specifically, I just add it to a list and then the code instantiates a card prefab:

 public void addCard(Card obj)
    {
        
        var found =  availableCards.Find(card => card.cardName == obj.cardName);
        Debug.Log($"[DeckEditorUI Found card: {found.cardName}");
        selectedDeck.Add(found);
        GameObject btn = Instantiate(cardButtonPrefab, selectedDeckPanel);
        btn.GetComponent<CardUI>().SetupForDeckList(found);
        btn.GetComponent<CardUI>().OnClick += removeCard;
        btn.GetComponent<CardUI>().OnPointerHover += displayCard;
        Debug.Log($"Current Deck Size: {selectedDeck.Count}");
        refreshdecklistDisplay();

    }
remote tundra
#

hey guys..i am a beginnr (REALLY BEGINNER) in C# and i have been struggling with basic player movement in unity 6.2 (the player is not moving no matter what i do) if someone is willing to help for free..DM me or just let me know

languid pagoda
neon forum
#

the heirarchy?

eternal falconBOT
neon forum
#

like the parent/childs?

languid pagoda
naive pawn
#

no-one's gonna be willing to help without knowing what you actually need lol

neon forum
#

I thought the content size filter/grid layout would solve it, but I'll scvreen shot

languid pagoda
#

but honestly I wouldn't suggest doing it that way

remote tundra
#

!ask hey guys..i am a beginnr (REALLY BEGINNER) in C# and i have been struggling with basic player movement in unity 6.2 (the player is not moving no matter what i do) if someone is willing to help for free..DM me or just let me know

neon forum
#

this is before

eternal falconBOT
neon forum
#

here is after

remote tundra
#

that was embarrassing

rich adder
#

no DMs

remote tundra
remote tundra
rich adder
#

You cannot Destroy a Transform component... they are essentials to gameobjects working properly, you delete the gameobject

languid pagoda
# neon forum this is before

From what im seeing your code should work and you dont have anything funky going on with the heigharchy id look at your canvas/grid settings next

naive pawn
languid pagoda
#

post your code

#

tell us the problem you're having

remote tundra
#

lemme just

naive pawn
hallow acorn
neon forum
remote tundra
naive pawn
eternal falconBOT
naive pawn
#
  1. describe what isn't working
    if it was working you wouldn't be here 😉 you gotta be more specific than that
neon forum
#

could the content size filter + grid layout group be clashing?

#

I have a feeling that could be it

naive pawn
#

are you getting errors or warnings?
is something not responding?
is something responding, but not in the way you want it to?

rich adder
hallow acorn
remote tundra
naive pawn
hallow acorn
#

i did not put the .parent there

languid pagoda
naive pawn
hallow acorn
#

Bro intellisense hates me😭

#

i did NOT put that there i swear😭🙏

neon forum
#

hmmm well I'm glad it wasn't a code issue

#

however I'm a scrub when it comes to UI

rich adder
hallow acorn
naive pawn
naive pawn
neon forum
#

yeah, I'll move there now, thank you all for the help!

hallow acorn
languid pagoda
naive pawn
#

ides exist for a reason

languid pagoda
#

its right a lot but its wrong often

hallow acorn
#

also, why is this not deleting all children? cs [ContextMenu("Reset")] private void DeleteChilds() { for(int i = 0; i < gameObject.transform.childCount; i++) DestroyImmediate(gameObject.transform.GetChild(0).gameObject); }

naive pawn
rich adder
#

did you even write this

hallow acorn
#

yes

#

i dont know if im proud about that or not tho

naive pawn
rich adder
#

ya also you need to do this in reverse

hallow acorn
#

why?

naive pawn
#

or just change the condition

rich adder
naive pawn
# hallow acorn why?

imagine you have 4 children
first iteration, i = 0, 0 < 4, delete one, now childcount 3
second iteration, i = 1, 1 < 3, delete one, now childcount 2
third iteration, i = 2, 2 ≥ 2, so loop exits

you end up deleting 2 children

hallow acorn
rich adder
#

the next item will have the current index

naive pawn
#

you don't need a for loop for this at all

#

you can just use a while (transform.childCount > 0) if you're just removing the first element

#

(also yeah, gameObject.transform is unnecessary, you can just use transform)

naive pawn