#💻┃code-beginner

1 messages · Page 577 of 1

swift crag
#

so battle.GetComponent<BattleStateManager>() is pointless

#

(unless you have two BattleStateManager components on one object, I guess, but that's very cursed)

brave compass
#

It's undocumented and not intended to be used by users, but it's used by Unity's own packages, such as Timeline. Like other internal APIs, it might be removed or change without notice, but since it's being used by multiple packages spread out over multiple teams within Unity, I think it's unlikely that it will be removed.

robust harness
swift crag
#

all of those lines are redundant

#

just write battle.playerPrefab

#

yeah

#

You should also change the type of the player prefab from GameObject to whatever component type you'll be using

#

maybe Player

robust harness
#

thanks

hot laurel
brave compass
hot laurel
#

nice, thanks, may be usefull in future

Thought it exist for serialization system purpose, but the purpose is more like tooling for lightweight execution before user scripts.

oak dagger
#

Can someone help? I am trying to make a car game but i think something is going on and my car is going really slow.

eternal falconBOT
cosmic dagger
edgy tangle
#

what is s?

#

strength?

#

currentStrength?

burnt vapor
#

Please don't comment on code style unless it actually hinders the application

#

Best is to just help with the issue, then comment on style later to avoid confusion

edgy tangle
#

Well if you want someone else's help, clear naming is pretty crucial.

burnt vapor
#

You can see s is assigned by strengthCoefficient there. It would help more if the code was properly pasted here using a paste site

edgy tangle
#

I admit it's just a pet peeve of mine. Sorry. I'll try to help solve the actual problem.

hot laurel
edgy tangle
edgy tangle
#

Although I guess I see what you mean

#

You can just inherently scale your values down

hot laurel
#

may be it get rid of it and check, the calculations including time delta time are usless but still modify the outcome (fixed delta time its equal to 0.02 by default)

swift crag
eager elm
swift crag
#

especially given that you can change the physics update rate

edgy tangle
#

Beat me to it

quick pollen
#

how could I turn a float into an angle for a vector3?

#

that vector3 being a direction

swift crag
hot laurel
swift crag
quick pollen
swift crag
# swift crag This is wrong.

Whether you're in Update or in FixedUpdate, this is bogus:

transform.position += velocity;

You must convert that velocity to a displacement by multiplying by a duration.

swift crag
quick pollen
timber tide
#

If it's 3d you probably shoukd be using Quaternion

swift crag
#

If you want a vector that points in a direction based on an angle, you can do

Quaternion.AngleAxis(angle, Vector3.forward) * Vector3.right;

for example

polar acorn
swift crag
#

This spins a world +X vector by angle degrees

#

around the world +Z axis

swift crag
#
for (int i = 0; i < 10; ++i) {
  float t = Mathf.InverseLerp(0, 10, i);
  float angle = Mathf.Lerp(0, 360, t);
  Quaternion rot = Quaternion.AngleAxis(angle, Vector3.forward);
  Vector3 dir = rot * transform.up;
}
edgy tangle
swift crag
#

indeed

polar acorn
#

Right

swift crag
#

It's true that your game will behave consistently if you leave out the length of the physics timestep

#

but it will still be wrong

quick pollen
#

Debug.DrawRay(transform.position, Quaternion.AngleAxis(degs[i], Vector3.right).eulerAngles * visionLength, debugColor, _timeBetweenScans);

swift crag
eager elm
quick pollen
swift crag
#

well, yes, but that's a completely bogus vector

#

you're interpreting euler angles as a displacement...

#

You can multiply a Quaternion by a Vector3 to get a rotated vector

polar acorn
quick pollen
#

just vector3.one?

swift crag
#

a direction you want to rotate

quick pollen
#

I already have all the rotations

polar acorn
#

What direction do you want the ray to point in?

swift crag
#

Take some starting direction and multiply it with a rotation

#
Quaternion rot = Quaternion.AngleAxis(90, transform.up);
Vector3 dir = transform.forward;
Vector3 result = rot * dir;

a 3D example

cosmic dagger
swift crag
#

This spins your forward direction around your up axis by 90 degrees

#

I can never remember if that's clockwise or counterclockwise

quick pollen
#

I want to use those

polar acorn
quick pollen
#

I keep fucking up the multiplication

#

Quaternion.AngleAxis(degs[i], Vector3.right) * Vector3.forward

#

i dont know which one needs to be which

swift crag
#

Oh, this is a 3D game, right

#

You need to rotate around the up axis

#
Quaternion.AngleAxis(degs[i], Vector3.up) * Vector3.forward
#

This would be appropriate for a 2D game, where the +Z axis is pointing into the screen:

Quaternion.AngleAxis(degs[i], Vector3.forward) * Vector3.up
quick pollen
#

i thought I tried this

#

ty!

swift crag
#

Rotating around Vector3.right means that you're spinning around the world X axis

quick pollen
swift crag
#

which will spin out of the XZ plane

quick pollen
#

something does seem to be wrong though with my Job

#
    public struct PFor : IJobParallelFor{
        public float nom;
        public NativeArray<float> results;
        public void Execute(int i){
            results[i] = nom * i;
        }
    }```
#

this is literally all I do

#

and its still not good

swift crag
#

presumably nom isn't large enough

#

if you aren't getting a complete circle

#

(what on earth is nom)

quick pollen
swift crag
#

integer division!

#

💥

quick pollen
#

sighPrecision is the amount of lasers I shoot out

quick pollen
#

ur right

#

forgot to add the f

#

i swear if it fixes

#

it does

#

im so stupid

#

ty

hot laurel
# polar acorn deltaTime in Fixed Update isn't used to make things framerate independent, but i...

yes its true but that wasnt the case of the question, simply said it scale down input value by factor to fixed update rate.
He didnt want to scale down his moving value, he wanted to move his object faster, and in this case the fixed update was the culprit since it scales down his input value. I dont like unecessary noise, better to focus on the question instead try to push own agenda like others did here

quick pollen
#

okay well I'm not getting more frames

#

this is sad

hot laurel
#

noise again

swift crag
#

you provided an objectively wrong answer and everyone else explained why you were objectively wrong

polar acorn
burnt vapor
#

If you don't want noise then stop responding ❓

quick pollen
#

yeah wow its literally not making a single bit of difference, using jobs over normal

swift crag
burnt vapor
swift crag
#

RaycastCommand might help if you can run all of the raycasts in one huge blob

quick pollen
swift crag
#

But it's not a massive upgrade, from my experience

#

It's faster, but not mind-blowingly faster

#

I use it for a visibility system in my game. I need to shoot lots of rays between entities, as well as work out the light level at each position (so, more rays fired at lights)

quick pollen
#

no, I mean theres literally 0 difference

rich ice
# quick pollen

literally just clicked on chat. sorry if i miss something. but, you could probably optimise this by doing an overlapSphere first and then raycasting if there's something nearby. you'd probably only need 1 direct raycast (or you can add a few more, that are spread out, for a little more accuracy)

swift crag
#

Drawing all of the rays is going to be nasty

quick pollen
swift crag
#

all those rays you're drawing

quick pollen
swift crag
#

Making this allocation-free was fun

quick pollen
#

idk why im bothering so much tho

#

this is just a school project

swift crag
#

My bitrate lmao

quick pollen
#

lmao yea

#

bonkers

swift crag
#

that is absolutely brutal on the encoder

quick pollen
#

how fast is Quaternion.Angleaxis actually?

swift crag
#

It's all very fast math

#

I guess you could make it even faster, though

cosmic dagger
#

pretty quick . . .

swift crag
#

You could punt all of that into Burst and use the Mathematics structs

quick pollen
#

what I did for the "unoptimized" one is just rotate a gameobject and get it's forward vector

swift crag
#

Okay that's going to be way way worse

quick pollen
#

no difference

swift crag
#

I guess it's not too bad if it has no children

quick pollen
#

for some reason

swift crag
#

I would insert some profiler markers to measure how long each step takes

quick pollen
#

imma send all my code if yall wanna look through it for optimizations

#

unoptimized one

rich ice
#

honestly, im more interested in the profiler than the code

#

i gotta know what's going to cause more lag first lmao

quick pollen
#

optimized one

rich ice
#

!code

eternal falconBOT
swift crag
#

Oh wait a second

rich ice
#

update: nvm

quick pollen
rich ice
#

missed it at the bottom

swift crag
#

ah, yes

#

logging is going to slow you down dramatically

quick pollen
#

didnt know logging strings would be this bad

rich ice
quick pollen
#

xD

swift crag
#

(Also, this "CheckForPlayerJob" method isn't going to get burst-compiled, I'm pretty sure)

#

especially because it needs to access managed objects, haha

#

You'll want to use a profiler marker to measure how long the raycasts take vs. how long the raycast command batch takes

hot laurel
swift crag
quick pollen
#

interesting, you can see the yellow/orange part increase whenever I turn off jobs

swift crag
#

rather than randomly ripping out another part of the calculation

rich ice
quick pollen
#

without jobs

#

something is taking 10 ms inside update both ways

swift crag
#

which you can figure out by using profiler markers, yes...

quick pollen
#

how exactly?

swift crag
#

use Profiler.BeginSample("Foo") and Profiler.EndSample(); to measure a region of code

quick pollen
#

ohh ok

swift crag
#

To be maximally efficient, you can create a marker once and then use it many times

#
        private static ProfilerMarker _perceptionMarker = new("Perceptions");
#

e.g.

#

I use this to profile my perception system

#

I wrap the relevant code with _perceptionMarker.Begin(); and _perceptionMarker.End();

quick pollen
#

oh wait I have an idea

#

could be my Wander script

#

no

#

i cant find anything

#

this makes no sense

#

wheres the extra 8 ms coming from?

#

youd think its the timeToLoseSight one

#

but thats not it

swift crag
# quick pollen

Anything that isn't being attributed to something else (e.g. to "Foo") is counted in the "Self" time of Update

#

notice that "Self ms" is 7.78 there

#

a profiler marker includes any time spend between its start and end that isn't part of another profiler marker

swift crag
# quick pollen

also, you've got a mismatched begin/end sample on that "Faa" marker

#

this is going to confuse the profiler

quick pollen
#

as physics go down, scripts go up

swift crag
#

RaycastCommand isn't causing Raycast calls, and those are what count as Physics time

#

Instead, you're just waiting on a job handle to complete

#

hence, script time

#

Insert more profiler markers to make this more clear.

quick pollen
swift crag
#

Uh Oh!

quick pollen
#

huh.

#

somethings wrong there

#

this is like 4 lines of code

#

shouldnt be 20%

swift crag
#

You can get even more granular with it

#

I have no idea how expensive CompareTag is

quick pollen
#

whats causing it tho?

quick pollen
swift crag
quick pollen
#

it uses hashes over string comparations

swift crag
#

so it's hashing the string 6000 times per frame

rich ice
swift crag
#

sounds mildly suspicious

#

Wrap both if statements in separate markers

#

This will add some non-trivial cost, but it should at least indicate what's going on

#

When you do something ten thousand times per frame, even the cheapest of operations can start getting a bit taxing

quick pollen
swift crag
#

Hits is being measured 60 times per frame, so I presume you have 60 tanks here

#

shooting 100 rays each

quick pollen
#

btw I am intentionally making the game perform worse, I can change the amount of times I scan for the player

spare mountain
#

i-intentionally?

swift crag
#

they are benchmarking

#

I've done similar things in my game, like spawning 100 entities that do literally nothing but look at each other

quick pollen
#

huh, tagcompare really is bad

swift crag
#

no brain. no body. no movement.

quick pollen
#

holy

#

` ` jumpscare

daring heath
#

bad formatted code will fix

quick pollen
cosmic dagger
#

check their component. see which one is worse . . .

quick pollen
#

tagcompare seems to be really angry

quick pollen
swift crag
daring heath
#

i'm trying to get the first script here to take information from the second script, but the asterisked "AddCollectible" is throwing up a no argument given error. The suggested fix adds the lower lines to the second script. Why isn't it finding the first AddCollectible class in that script?

    {

        for(int i = 0; i < collectibleSlot.Length; i++)
        {
            if(collectibleSlot[i].isFull == false)
            {
                collectibleSlot[i].*AddCollectible*(collectibleName, collectibleSprite);
                return;
            }
        }
    }```
---
```    public void AddCollectible(string collectibleName, string description, Sprite collectibleSprite)
    {
        this.collectibleName = collectibleName;
        this.collectibleSprite = collectibleSprite;
        isFull = true;

        collectibleImage.enabled = true;
        collectibleImage.sprite = collectibleSprite;
    }

    internal void AddCollectible(string collectibleName, Sprite collectibleSprite)
    {
        throw new NotImplementedException();
    }```
swift crag
#
TryGetComponent(out Player player)
#

You could also filter by layer

#

If the player is on layer X and the obstacles are on layer Y, that's a very cheap test

cosmic dagger
#

do you use a filter on your raycast??

swift crag
#

the raycast needs to hit both obstacles and the player

quick pollen
cosmic dagger
#

too slow . . .

swift crag
#

so there's not much room there

quick pollen
#

yeah

#

i dont want the tanks to see through walls

#

but yes, it would be way more efficient

swift crag
#

The layer check would be especially cheap

cosmic dagger
#

i have an idea, but check the player component first . . .

#

damn you Fen. that was it . . .

formal hill
#

Can anyone explain to me what a Quaternion is/does?

cosmic dagger
#

just check the layer of the hit object. that's just a bit check . . .

quick pollen
swift crag
#

It should have been called Rotation

#

Alas.

cosmic dagger
#

NonGimbalRotation?

swift crag
#

I don't know how quaternion math really works -- and I don't have to!

#

I do know most of the vector math I do, but I still don't have to think about it

edgy prism
#

Hello I was wondering about the best way to get real time for time gated events should I be using an API?

quick pollen
#

just as bad, if not worse

#

its called TagCompare but I used TryGetComponent

quick pollen
edgy prism
cosmic dagger
edgy prism
#

I dont want people to be able to change it xD

swift crag
#

This will deter basic cheating

edgy prism
quick pollen
swift crag
quick pollen
#

I cant find the layer

swift crag
quick pollen
#

o nvm got it

swift crag
#

er

quick pollen
swift crag
#

of the game object of the collider you hit

cosmic dagger
quick pollen
#

its hit.transform.gameObject.layer

swift crag
#

I can never remember which things are on GameObject and which things aren't

#

You can call TryGetComponent on a component, but not AddComponent

oak dagger
quick pollen
#

do I compare number or string?

#

does it matter?

edgy prism
swift crag
quick pollen
#

if I do == 4 or == "Player"?

cosmic dagger
swift crag
#

You should compute LayerMask.NameToLayer("Player") once and then reuse that number

swift crag
swift crag
cosmic dagger
#

alternatively, you can compare the bitmask . . .

slender nymph
#

CompareTag on a component just internally calls gameObject.CompareTag, Component.AddComponent could easily do the same thing. In fact you could just make an extension method for it right now

quick pollen
#

its like 4% better @cosmic dagger

cosmic dagger
quick pollen
#

what I find extremely weird is: what I free up in physics processing, I lose in script processing when switching to jobs

slender nymph
quick pollen
cosmic dagger
slender nymph
rich ice
#

is this still beginner coding...?

swift crag
swift crag
#

Your script is waiting on a job to complete

#

you're calling JobHandle.Complete()

#

this means "wait until the job is done"

#

so your script is just parked there, doing nothing.

#

It does not matter exactly which category the profiler puts this into!

slender nymph
# rich ice *is this still beginner coding...?*

probably, extension methods are probably on the beginner side of "intermediate" knowledge about c#. it's some handy stuff to know about tbh
unless you're referring to all the raycast command stuff lol

quick pollen
#

I could get rid of a jobhandle by doing simple maths

#

instead of all this bs

#

just i * nominator

swift crag
#

If you can't wait for a bit before using the results of the command, then it's not going to be that much better than just running the raycasts directly

swift crag
#

the player should not be able to say "It's time for my reward!" and just get the reward

cosmic dagger
quick pollen
#

so I fiddled around with my optimizational features a bit, turned down precision, increased the time between checks....

#

those spikes are the comparetags....

swift crag
#

Consider smearing out the queries over time

#

Chop the tanks into ten groups and run one group per frame

#

That is how I handle vision in my game. I break entities into five groups and round-robin them

quick pollen
#

....wdym?

#

I am checking if the object im hitting is a player

slender nymph
swift crag
#

I'm saying to not check all 60 tanks every single frame.

oak dagger
# swift crag How are you figuring that?

Because i have a different code that makes it able for me to see the speed i am going (it is a really simple speedometer) and the results i get are not the ones that they were supposed to be

rich ice
swift crag
quick pollen
swift crag
#

Hence the enormous spikes

quick pollen
#

i dont know how to smear them

swift crag
#

a very simple way:

quick pollen
#

like the problem is that they're synced

#

they all check for the player at the same time

swift crag
#
int val = GetInstanceID() % 10;

if (Time.frameCount % 10 == val)
  Whatever();
quick pollen
#

I need to somehow stop that from happening

quick pollen
#

I mean I get what it does

#

but whu

swift crag
#

this makes Whatever() execute once every ten frames

#

and the exact choice of frame depends on your instance ID

cosmic dagger
quick pollen
#

a bit more efficient maybe

cosmic dagger
swift crag
edgy prism
swift crag
#

i.e. maybe they're all divisble by 2

#

i forgor

rich ice
# quick pollen

im still pretty sure that the issue is the absurd amount of raycasts

quick pollen
#

this looks abyssmal

rich ice
#

surely you can just optimize that to a single raycast

swift crag
#

In practice, yes, you would just fire a few rays directly at the player

rich adder
quick pollen
#

and not 20 tanks, but like 5 or 10

#

not to mention I wouldnt be checking for the player every frame, rather once every second or so

languid spire
quick pollen
#

LMAO I was wondering why my frames skyrocketed, turns out I nuked my raycasts xd

rich adder
quick pollen
#

doesnt really work

        int val = GetInstanceID() % 10;
        if (timeBetweenScans > 0f)
            timeBetweenScans -= Time.deltaTime;
        else if (job)
            if(Time.frameCount % 10 == val)
                CheckForPlayerJob();
        else CheckForPlayer();```
rich adder
#

oh lol

swift crag
swift crag
#

(please just give us the modulus. nobody ever wants a remainder)

cosmic dagger
swift crag
#
x -= 1;
x += n;
x %= n;
quick pollen
oak dagger
# swift crag I'm asking you why you think you should be going at 200 km/h

Because i have did some testing with the unity standard assets car and the result was for a car that was 2500 kg that was going at 200 kmh, so because my car is 1000 kg and will have around half the power, i suppose it will reach 200 kmh. There is possibility that the wheel colliders are the issue but I am not sure about that

polar acorn
swift crag
#

No, it's a value y such that x = kn + y

polar acorn
#

In computing, the modulo operation returns the remainder or signed remainder of a division, after one number is divided by another, called the modulus of the operation.
Given two positive numbers a and n, a modulo n (often abbreviated as a mod n) is the remainder of the Euclidean division of a by n, where a is the dividend and n is the divisor.
...

swift crag
#

where k is an arbitrary integer

#

In mathematics, the result of the modulo operation is an equivalence class, and any member of the class may be chosen as representative; however, the usual representative is the least positive residue

this is what I always want

quick pollen
edgy prism
quick pollen
#

@swift crag i would love to post the result but i think itd get blocked for causing epileptic seizures

#

sike

#

also this boosted my fps quite well, tho im not sure if its because of the smearing or because im not running the raycasts every frame

swift crag
#

well, yes, the smearing is why you aren't running so many raycasts every frame :p

quick pollen
#

well ok yes

#

technically

#

it matters less when I decrease the check times

#

it goes from one large spike to multiple smaller ones

cosmic dagger
swift crag
#

You can do better than that -- you could spread the raycasts out over all frames

quick pollen
swift crag
#

right now, you're only doing tests about half of the time

quick pollen
#

x times per frame sound insane

quick pollen
cosmic dagger
quick pollen
#

there we goo

#

much better

#

o wait

#

no

#

i changed it to % 20

#

maybe its better

#

int val = Mathf.Abs(GetInstanceID()) % (int)(1.0f / Time.deltaTime);

#

ill try something like this

#

actually this might be a stupid idea

#

i wanted it to be based on framerate

vestal sandal
#

hi guys

swift crag
#

for example, you can limit it to 5ms of work per frame

quick pollen
#

i... dont understand

#

70 fps if i turn off gizmos

#

that was actually a pretty good recommendation tho @swift crag so ty!

#

it feels like I have vsync on

#

it just wont go over 60 fps no matter what

#

even tho I have the targetframerate as -1

true owl
#

are these conditions for the transition an "and" or an "or"

#

like && or ||

true owl
#

thx

quick pollen
#

you want 2 transitions for it to be an or

true owl
#

ah

#

gotcha

oak dagger
swift crag
#

Yeah, if the wheels are slipping, then you won't be getting any torque

#

A slipping wheel does almost nothing

true owl
#

so this means it's an or

#

just confirming

quick pollen
#

yeah

swift crag
#

You have two transitions between "Ground States" and "Air States"

true owl
#

sweet

swift crag
#

If either transition succeeds, you'll switch states

true owl
#

cool cool

#

thx

swift crag
#

so yeah -- many transitions for "or", one transition for "and"

quick pollen
#

ngl

#

i wish they just added an or

oak dagger
quick pollen
#

instead of having to copy over all the fucking settings

swift crag
#

not sure how many of those translate into Unity physics...

swift crag
#

I've done some awful stuff in VRChat

quick pollen
#

xD

rich adder
#

VRChat is made in unity

swift crag
#

VRChat is a Unity game.

quick pollen
#

I know, I was making a stupid joke

swift crag
#

Almost everything you do with avatars is Animator-based

#

it's great

quick pollen
#

btw I think im done optimizing for today, its all i did all day

#

but ngl it was fun

oak dagger
quick pollen
#

more fun than working on my main game for now

#

but at least I know how I'll be adding pathfinding to my bosses

#

although the way the movement works for navagents kinda sucks, I hope I can just somehow use the pathing or smth without the movement, maybe make an invisible agent that the boss follows

rich adder
#

good way to have chars move freely on a floor without dealing with walls

swift crag
#

You can make queries directly, yes

quick pollen
#

also, yeah, why is it that the game has the same fps with 20 tanks as with 200

quick pollen
swift crag
#

You can also make the agent not control the position of its object

#

(you can't stop it from rotating the object, though..)

quick pollen
#

for this school project it works fine

swift crag
#

in the past, I've parented an empty to my character with an Agent on it

quick pollen
#

but for my game, ill want something better

quick pollen
swift crag
edgy tangle
#

It’s analogous to wheels spinning in mud — no traction, no velocity

edgy tangle
#

Personally I would not pursue that level of realism and instead would figure out a way to fake it… that level of detail and realism is beyond my understanding of how to use the physics system

#

A detailed look at how we made our custom raycast-based car physics in Unity for our game Very Very Valet - available for Nintendo Switch, PS5, and Steam.
BUY NOW!! https://toyful.games/vvv-buy

~ More from Toyful Games ~

▶ Play video
velvet schooner
#

!code

eternal falconBOT
faint osprey
#

so ive got a bunch of animations for walking for my character which ive made and it now looks like its walking only thing is now ive got a gun sprite to include in the walking so how would i add that to the walking animations do i have to get the artists to make seperate animations for walking with each gun or am i missing something

quick pollen
upper forge
#

So im trying to get my player to climb a walk and i am using a raycast and i have the raycast position as a empty gameobject on the player so when the player is facing right and then left the empy gamobject follows, the climb works for the right but when player is on the left they dont climb up?

Im confused

quick pollen
cosmic dagger
upper forge
#
RaycastHit2D hitRight = Physics2D.Raycast(rayCastPos.transform.position, rightRayDirection, 2f, SuctionCupLayer);

RaycastHit2D hitLeft = Physics2D.Raycast(rayCastPos.transform.position, leftRayDirection, 2f, SuctionCupLayer);

anim.SetBool("isClimbing", hitRight);

anim.SetBool("isClimbing", hitLeft);
public GameObject rayCastPos;
public Vector2 rightRayDirection = new Vector2(1, 0);
public LayerMask SuctionCupLayer;
public Vector2 leftRayDirection = new Vector2(-1, 0);
quick pollen
#

ah

#

so you set isClimbing to hitRight, then you set it to hitLeft

faint osprey
quick pollen
#

that means that no matter what value hitRight has, isClimbing will always get overwritten by hitLeft due to syntax

quick pollen
cosmic dagger
upper forge
astral falcon
#

Is your raycastPos flipping with your character when looking left?

upper forge
cosmic dagger
quick pollen
#

same thing happens vice versa, and inverted. doesnt matter what value hitRight has because hitLeft is the last value that you set it to

cosmic dagger
#

you should check which direction you're facing and place the raycast code for that direction in the if statement, and the opposite direction in the else . . .

astral falcon
#

or just setboolean to hitLeft || hitRight

upper forge
true owl
#

is there a way to make it so that if my player is holding W and D for example, he doesn't get the speed of that and still continues his speed as if he was holding D only?

slender nymph
#

normalize the input before mulitplying by the movement speed

#

or clamp the magnitude if you want to support analog input less than a length of 1

astral falcon
true owl
#
void OnMove(InputValue value)
    {
        moveInput = value.Get<Vector2>().normalized;
    }
slender nymph
#

show how you are actually using this, because digital input should already be normalized if you're using the input system and didn't explicitly select the non-normalized Vector2 composite

true owl
#
    // Handles player movement velocity
    void Move()
    {
        if (!isDashing)
        {
            rb.linearVelocity = new Vector2(moveInput.x * playerSpeed, rb.linearVelocity.y);
        }
        animator.SetBool("isRunning", true);
    }
#

oh wait

#

this code is confusing

#

actually nvm

#

i think its fine

slender nymph
#

ah, so in that case you don't want to normalize the input if you're only using a single axis

true owl
#

wym by a single axis, just the X in this case?

#

here's my full code maybe something is wrong

pseudo ermine
#

Hey - are there many tutorials / documents that would be helpful for changing/accommodating to unity 6?

true owl
#

if u wanna look

#

if you don't no pressure

slender nymph
#

yes, you're only using the X axis. this is not a code thing, you need to adjust the input action asset

true owl
#

the input manager? What if I want to keep it later on for usage for my dash (which i want to go diagonally)

rich ice
#

there probably are. but, the changes aren't that big

#

well they are, but not for the average user

rich ice
# rich ice no :D

basically, just check the change logs if you want to see all the differences. explore and find out while using unity 6, if you're unsure of whats new

#

also not a code question

pseudo ermine
slender nymph
true owl
#

well its like

#

i want them to be able to dash diagonally

#

but when you're on the ground i dont want holding diagonally to affect it

#

the run that is

astral falcon
oak dagger
swift crag
#

By default, one world-unit is one meter, so yeah

oak dagger
#

The good thing is now i know that my code is working as it should and i can finally start working on stabilizing the car at high speeds and make the tire meshes follow the suspension

true owl
#

idk if this is a good soln but

gloomy cosmos
#

Hello, when emitting particles through script is there any easy way to set startindex to use on spritesheet? I need to set which sprite to use on any particle.

true owl
#
    // Handles player movement velocity
    void Move()
    {
        if (!isDashing)
        {

            float adjustedMoveInput = isGrounded || isOnRail ? (moveInput.x == 0 ? 0 : (moveInput.x > 0 ? 1 : -1)) : moveInput.x;
            // if player is on ground or rail, have holding diagonally affect the same as just horizontally 
            rb.linearVelocity = new Vector2(adjustedMoveInput * playerSpeed, rb.linearVelocity.y);
        }

        animator.SetBool("isRunning", true);
    }
#

lol excuse the code haha

slender nymph
#

if you want to still use the Vector2 input from the input action asset, just get the Mathf.Sign of the x axis instead of nesting ternary operations

true owl
#

oooh

#

that's way better

#

thx

upper forge
astral falcon
upper forge
astral falcon
upper forge
#

yes i believe so

astral falcon
#

So you could just raycast into Vector3.left and .right

upper forge
# astral falcon So you could just raycast into Vector3.left and .right
 RaycastHit2D hitRight = Physics2D.Raycast(rayCastPos.transform.position, Vector3.right, 2f, SuctionCupLayer);

 RaycastHit2D hitLeft = Physics2D.Raycast(rayCastPos.transform.position, Vector3.left, 2f, SuctionCupLayer);

 anim.SetBool("isClimbing", hitLeft || hitRight);

So i did this and is still doing same thing in video and the raycast line still isnt switching to the left when player is facing left

gloomy cosmos
#

hello, still trying to do the unique sprite per particle. One solution I thought of was giving particles a very long lifetime and setting up a curve in the texture sheet animation, but this doesn't seem to work, this is the code:

// There are 17 sprites
particle.remainingLifetime = 9000 + ((i % 17) / 17f) * 1000;
particle.startLifetime = 10000;

I made the curve go from 0 at time 0 to 1 at 0.1, which is 10% of the lifetime, Yet this does not work, all bullets seemingly only depend on the value at zero.

astral falcon
forest summit
#

heres the code

rich ice
#

!code

eternal falconBOT
upper forge
forest summit
rich ice
#

if only large codeblocks was a listed option pensiveFast

swift crag
swift crag
#

no matter what direction you're facing

forest summit
#

yeah thats my bad

upper forge
swift crag
#

don't do that!

#

presumably you want to use the same directions you used in the raycasts

upper forge
swift crag
#

don't you want to draw a ray in both directions, then?

polar acorn
#

Remember that DrawRay does not have a "distance" parameter. You'll need to multiply the direction vector by the length

upper forge
#

So this ?

swift crag
#

This will draw two rays

#

If you give them a length of 2, they'll correspond to the raycasts you're doing

true owl
#

can someone explain to me why I need both a tilemap collider 2d and a composite collider 2d?

swift crag
true owl
#

got it

swift crag
#

I don't see why you'd need one if you only have that single tilemap collider

#

Although, it may change the precise shape of the collider

true owl
#

i was just wondering what the diff is

#

i like both because it lets it smooth out

#

but the issue is

#

I got this code to do a one way platform

 void Update()
    {

        // checking if holding down, this disables the collision of the platform,
        // allowing for the player to drop down
        if (moveInput.y < 0)
        {
            Debug.Log("Holding down...");
            if (currentOneWayPlatform)
            {
                StartCoroutine(DisableCollision());
            }
        }
    }

    void OnMove(InputValue value)
    {
        moveInput = value.Get<Vector2>().normalized;
    }

    private void OnCollisionEnter2D(Collider2D collider)
    {
        if (collider.gameObject.CompareTag(ScStrings.railLayer))
        {
            currentOneWayPlatform = collider.gameObject;
        }
    }
    private void OnCollisionExit2D(Collider2D collider)
    {
        if (collider.gameObject.CompareTag(ScStrings.railLayer))
        {
            currentOneWayPlatform = null;
        }

    }

    private IEnumerator DisableCollision()
    {
        CompositeCollider2D platformCollider = currentOneWayPlatform.GetComponent<CompositeCollider2D>();
        TilemapCollider2D tilemapCollider = currentOneWayPlatform.GetComponent<TilemapCollider2D>();

        Physics2D.IgnoreCollision(playerCollider, platformCollider);
        Physics2D.IgnoreCollision(playerCollider, tilemapCollider);
        yield return new WaitForSeconds(2f);
        Physics2D.IgnoreCollision(playerCollider, platformCollider, false);
        Physics2D.IgnoreCollision(playerCollider, tilemapCollider, false);
    }
#

he can't drop down though

#

nvm the issue is

#

the current oen way platform is null

#

seems OnCollisionEnter2D isnt working

polar acorn
# true owl seems OnCollisionEnter2D isnt working

The Three Commandments of OnCollisionEnter2D:

  1. Thou Shalt have a 2D Collider on each object
  2. Thou Shalt not tick isTrigger on either of them
  3. Thou Shalt be moving via a 2D Rigidbody on at least one of them
grand snow
#
  1. ???
  2. Profit
true owl
#

is it possible it's not working cause my rigidbody on the platform is static?

polar acorn
#

Is the other object moving via rigidbody?

true owl
#

no

#

only my player is moving

grand snow
#

its void OnCollisionEnter2D(Collision2D collision) btw, the argument type is wrong

polar acorn
#

Then condition 3 is not met

polar acorn
#

Oh, also that

polar acorn
grand snow
#

only trigger events have Collider as the arg type

true owl
#

yes

slender nymph
polar acorn
#

I haven't run in to it in a while

grand snow
true owl
#

the platform has all of this
the player has the stuff in 2nd image

slender nymph
true owl
#

i want him to drop down the platform when holding S

polar acorn
#

As opposed to transform, for example

true owl
#

yes I'm using rb.linearVelocity

polar acorn
#

Okay, so that's fine then, fix the parameter and it should be working

true owl
#

I really feel like it's definitely the

#

TilemapCollider2D

#

is messing with things

true owl
polar acorn
slender nymph
#

have you gone through the link i sent?

true owl
#

i took a look at it

#

i'll reread it

#

here's the updated code

public class PlayerOneWayPlatform : MonoBehaviour
{

    private GameObject currentOneWayPlatform;
    [SerializeField] private CapsuleCollider2D playerCollider;

    private Vector2 moveInput;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        Debug.Log(currentOneWayPlatform);
        // checking if holding down, this disables the collision of the platform,
        // allowing for the player to drop down
        if (moveInput.y < 0)
        {
            Debug.Log("Holding down...");
            if (currentOneWayPlatform)
            {
                StartCoroutine(DisableCollision());
            }
        }
    }

    void OnMove(InputValue value)
    {
        moveInput = value.Get<Vector2>().normalized;
    }

    private void OnCollisionEnter2D(Collision2D collider)
    {
        if (collider.gameObject.CompareTag(ScStrings.railLayer))
        {
            Debug.Log("here");
            currentOneWayPlatform = collider.gameObject;
        }
    }
    private void OnCollisionExit2D(Collision2D collider)
    {
        if (collider.gameObject.CompareTag(ScStrings.railLayer))
        {
            currentOneWayPlatform = null;
        }

    }

    private IEnumerator DisableCollision()
    {
        CompositeCollider2D platformCollider = currentOneWayPlatform.GetComponent<CompositeCollider2D>();
        TilemapCollider2D tilemapCollider = currentOneWayPlatform.GetComponent<TilemapCollider2D>();

        Physics2D.IgnoreCollision(playerCollider, tilemapCollider);
        Physics2D.IgnoreCollision(playerCollider, platformCollider);

        yield return new WaitForSeconds(2f);
        Physics2D.IgnoreCollision(playerCollider, platformCollider, false);
        Physics2D.IgnoreCollision(playerCollider, tilemapCollider, false);
    }
}
#

the player code is pasted above

#

its a tiny bit outdated but the movement is still the same so

polar acorn
#

And see what it logs when you hit the platform

true owl
#

in the update method?

#

oh nvm

#

im dumb

#

it logs "Rail"

#

WAIT

#

it works

#

it's just the first time he drops

#

the collider doesn't trigger for some reason

polar acorn
#

Okay, and if it doesn't log "here", then that means that ScStrings.railLayer is not "Rail"

true owl
#

um sorry

#

it works

#

thank you all

polar acorn
slender nymph
# true owl thank you all

so it sounds like you just need to pay better attention to the console if changing the method parameter was all you needed to do

real falcon
#

the ragdoll creator wants the character in a T pose but idk how to make it do that in the editor

#

I have a tpose clip and I made it the default state in the animation controller

slender nymph
#

this is a code channel

real falcon
#

I dont see a ragdoll channel

slender nymph
real falcon
#

is there a help channel

slender nymph
real falcon
#

ok so ill go to physics and someone will say this isnt a physics question

slender nymph
real falcon
#

so ill go to animation and someone will say this isnt an animation question

slender nymph
#

i bet it can tell you where to ask your question

#

or you could just keep ignoring the suggestion and get bounced around the discord as you keep putting your question(s) in the wrong channels

real falcon
#

when I ask in unity talk people say this isnt a help channel

polar acorn
real falcon
#

ill just figure it out myself, cant be bothered to navigate the 5 million rules large discords always have

#

impossible to ever do something in a way that doesn't make a mod angry

slender nymph
#

okay bye then

polar acorn
# true owl what does that mean

Right now, whenever you start colliding with a Rail, you set currentOneWayPlatform. Whenever you stop colliding with a Rail, you un-set currentOneWayPlatform

#

Now, what do you think happens if you're standing on two different rails, and then step off of one

true owl
#

how can i stand on two diff rails

slender nymph
#

either keep a list of the ones you are currently in contact with or just use a physics query when you need to know if you are in contact with any

true owl
#

No i meant, when would the case be when I'm standing on two rails

slender nymph
#

the first option would have you add/remove them in CollisionEnter/Exit, the second is more versatile because you only check if you are in contact with one when you need that information

polar acorn
#

And you are passing through one

true owl
#

I don't think I will have that case

#

In my game

slender nymph
#

you may not think you will experience that, but what if you do. design your systems better and you won't have to track down weird bugs that you may introduce due to poor design

true owl
#

sure

slender nymph
true owl
#

I might have to watch a video on that or something

#

Don't know what those are

static cedar
#

I kinda prefer to have OnEnabled run after start?

swift crag
#

OnEnabled runs when the behaviour is enabled, not a while later

#

that would be a bit odd

teal viper
static cedar
polar acorn
rich ice
teal viper
static cedar
#

Nah, I was wondering how far you'd go for the 1 million salary.

cosmic dagger
static cedar
#

I thought you'd use Start for another step to initialise. And it's only run once.
But I guess I'm fine as long as it doesn't run on frame 0/right after Awake.

slender nymph
#

you typically would use Start for more setup/initialization but the order of operations is Awake -> OnEnable -> Start, it is possible all of this runs on the first frame, but Start may not be called until the next frame depending on when the object was instantiated

static cedar
#

Thinking about it.
What exactly happens if a game object is disabled and reenabled on the same frame?

polar acorn
rich ice
west radish
polar acorn
#

Deactivating an object does not return from the current function

crisp olive
#

i don't think this is the code acting up but who knows.. i get this weird trailing effect, anyone know how to fix it?

rich ice
#

camera background is set to unitialized instead of background or solid colour

#

might be different depending on your RP

crisp olive
#

i cant find those setting but i did figure it out, Clear Flags was set to Don't clear

#

thanks for the help though

swift crag
#

you can run methods on disabled behaviours...or even on destroyed objects!

crisp olive
#

i hate to ask 2 questions in one day but i really wanted to get this to work tonight..how would i go about rotating the top piece? i'm trying to, when Z key is pressed rotate Z axis in increments of 120

ivory bobcat
#

What have you tried?

#

There's no limitation on questions btw

crisp olive
#

but i wanted a cool little visual like if this object was a pyraminx rubik's cube and i was twitsting the top into the next available position

teal viper
#

There's no limitation, but you have to pay $10 for each extra question

crisp olive
#

aye if that was a thing i'd gladly do it

#

something like this but i want it to stay locked into a location in increments of 120 using UnityEngine;

public class TopZ : MonoBehaviour
{
public float rotationSpeed = 30f;

void Update()
{
    
    Vector3 currentRotation = transform.rotation.eulerAngles;

    float newZRotation = currentRotation.z + rotationSpeed * Time.deltaTime;

    transform.rotation = Quaternion.Euler(currentRotation.x, currentRotation.y, newZRotation);
}

}

ivory bobcat
#
if z was pressed
    start coroutine: rotate z```
static cedar
crisp olive
#

still doesnt work i guess i'll try again some other time or skip that

static cedar
#

Once a function is called, it only returns on return or function end.

#

There's no way to stop a function before that.

crisp olive
#

its a 3d object so i wanted the player to see that the game was 3d instead of it exploding into 120 in a split second haha

#

they tell you to make a simple game to learn and i made it more complex than it needs to be

sour snow
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Photon.Pun;


public class Portal : MonoBehaviourPunCallbacks
{
    public Transform Destination;
    public Transform Player;


    public string Tag = "Player";

    public float waitTime = 1;

    public override void OnConnected()
    {
        base.OnConnected();

        if(PhotonNetwork.IsConnected)
        {
            GameObject existingPlayer = GameObject.FindGameObjectWithTag(Tag);

            if (existingPlayer != null)
            {
                Player = existingPlayer.transform;
            }
        }
    }


    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag(Tag))
        {
            StartCoroutine(waitTillTeleport());
        }
    }

    IEnumerator waitTillTeleport()
    {
        yield return new WaitForSeconds(waitTime);

        CharacterController controller = Player.GetComponent<CharacterController>();

        if (controller != null)
        {
            controller.enabled = false;
            Player.position = Destination.transform.position;
            controller.enabled = true;
        }
        else
        {
            Player.position = Destination.transform.position;
        }
    }
}```



shouldnt it have the existingPlayer transform equal the Player transform this is whats confusing for me since i just started using photon pun
i dont know if any of you use it but its probably simple but its confusing for me
livid raptor
#

Pls format your code

crisp olive
#

just going to rotate in blender and call animation haha thanks again

eternal falconBOT
sour snow
mystic lark
#

how do i make a object make a clone every second or so 100 times or until i tell it to stop i just dont get it i tried using courotines but it doenst work anyone help?

slender nymph
#

your coroutine did not have any loop in it so it would run a single time then end

#

but the answer is either use a coroutine with a loop or a timer in update

wintry quarry
mystic lark
#

k ill try

mystic lark
slender nymph
#

then you probably didn't start it correctly

mystic lark
#

see this is what i did but it doesnt even debug anything nether does it spawn a clone but when i put the INstatiatiate in start it works fine

#

and i aslo get this eroer

slender nymph
#

well that would be why the coroutine never starts. exceptions stop execution of the method they occur in

wintry quarry
slender nymph
#

also you definitely don't want to be starting that coroutine in update like that, otherwise you'll end up with way too many instances of it starting

mystic lark
#

k but how then

mystic lark
wintry quarry
#

like the error says

#

scoreNewScore

mystic lark
#

oh thats were i can see the line i didnt know that

#

ty

wintry quarry
#

yes the error says the line number and filename

slender nymph
mystic lark
#

ok

slender nymph
#

also since you just want this to start after a certain condition is met then continue possibly indefinitely, just use a timer in update. it will be a bit simpler to manage than a coroutine

mystic lark
#

il try but i am kinda very new with C# and unity making a timer will be hard is there any tutorial u suggest?

wintry quarry
#

a timer is very easy

slender nymph
#

just google "unity update timer"

wintry quarry
#

something like this:

float timer = 0;
float interval = 1; // 1 second

void Update() {
  timer += Time.deltaTime;
  if (timer >= interval) {
     timer -= interval;

     SpawnSomething();
  }
}```
mystic lark
#

i still have no idea what time.delta time is lol

#

thanks

wintry quarry
#

that's it

#

nothing special

#

by adding that number we're just counting up our timer

#

that makes a simple timer

#

timer += the amount of time that has passed

#

that's all that's happening

mystic lark
#

oh i understand now it is quite simple

wintry quarry
#

for example if the previous frame was 1/10th of a second ago, Time.deltaTime is 1/10 or 0.1

wintry quarry
versed light
#

this might seem like an odd question but does unity gizmos/handles for spheres and discs use signed distance fields to render them or does it generate a mesh

wintry quarry
versed light
#

i see because when radii is rather large they are visually very inaccurate

#

spend the last few hours confused why my geometry math was not matching what i was seeing

wintry quarry
#

Yeah it's definitely an approximation with a set number of subdivisions

versed light
#

i feel like SDF would be perfectly accurate with not much more performance hit

gaunt sandal
#

I am having trouble getting my unity editor to recognize my android device when i build.

  • Unity installation: 2022.3.47f1
  • Android type: Samsung Galaxy Note20 Ultra 5G

So far, I have tried going to the Android environment setup manual entry, but that was really hard for me to understand right now.

versed light
#

other than limits of floats of course

teal viper
gaunt sandal
#

how'd i manage to miss that lol

teal viper
#

As well toggle debugging over USB(if you plan on connecting via USB).

gaunt sandal
#

oooooooo we cooking with gas now

#

thank you; it is doing it's thing now

#

just gotta see if my build works at all

gaunt sandal
#

THE BUILD WORKS

sturdy cairn
#

Can I ask for some Unity support here?

static cedar
#

Reset didn't work apparently.

I ended up with this which ended up a bit more manual. Just put this on the respective EventHandler.

        private void Automate<T>(bool value, BaseEventData eventData, ExecuteEvents.EventFunction<T> functor) where T : IEventSystemHandler
        {
            if (value)
            {
                Transform parent = transform.parent;
                while (parent != null)
                {
                    ExecuteEvents.Execute(parent.gameObject, eventData, functor);
                    parent = parent.parent;
                }
            }
        }
rocky canyon
#

if its beginner coding concepts then sure

sturdy cairn
#

Idk if it is lol

rocky canyon
#

well whats the problem?

sturdy cairn
#

I added a script for player attacking and made it trigger whenever I click. But now when I click, my player goes invisible and is only visible when I do click. I've tried to find the root of this problem for a few hours now and I know for fact, it's the new attack script.

rocky canyon
#

what does the script do?

#

does the gameobject get disabled? is it the graphics that go invisible? like a renderer or something?

sturdy cairn
#

I'm not sure. All I know is that the entire placeholder sprite that I have goes invisible. I don't think that they stop rendering entirely. Would it be better if I just sent the code for this script?

rocky canyon
#

if the issue didnt begin until after the script was added as i think u said.. then ya the script would be useful !code

eternal falconBOT
slender nymph
#

sprite invisible
likely too close to the camera

rocky canyon
#

unless its soemthing super simple like that ^

sturdy cairn
#
using UnityEngine;

public class PlayerAttack : MonoBehaviour
{
   private GameObject attackArea = default;
   private bool attacking = false;
   private float timeToAttack = 0.25f;
   private float timer= 0f;
    void Start()
    {
        attackArea = transform.GetChild(0).gameObject;
        attackArea.SetActive(false); 
    }
    void Update ()
    {
        if(Input.GetKeyDown(KeyCode.Mouse0))
        {
            Attack();
        }
        if (attacking)
        {
            timer += Time.deltaTime;
            if(timer >= timeToAttack)
            {
                timer = 0;
                attacking = false;
                attackArea.SetActive(attacking);
            }
        }
    }
    private void Attack(){
        attacking = true;
        attackArea.SetActive(attacking);
    }

}```
sturdy cairn
cosmic dagger
slender nymph
sturdy cairn
cosmic dagger
sturdy cairn
#

I'm not sure what the inspector is.

slender nymph
#

you should start with the essentials pathway on the unity !learn site
also assuming the component you showed is attached to the Player1 object, the sprite is the first child of that object which is the one you are deactivating

eternal falconBOT
#

:teacher: Unity Learn ↗

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

cosmic dagger
#

As I thought, you are deactivating the sprite GameObject . . .

sturdy cairn
tawny grove
#

Hello, i know it is generally discourage to have two tiles collide/intersect, but if both of them are non moving tiles, what issues can it actually cause? I am asking because i want to have a removable wall, but i dont want to have to manually edit the tiles of the floor below in script to make it flow right. would it be fine for me to overlap some of the walls tiles in a tilemap ontop the floors, so i could remove the wall all at once while revealing a already made floor below?

cosmic dagger
#

Before continuing the tutorial, you need to understand what each line of code does. If you follow along, you can see that your code grabs the first child of the transform and deactivates it

The transform is the "Player 1" GameObject and the first child is the "Gladiator_Player_1" GameObject . . .

sturdy cairn
#

Oh I get it

#

attackArea = transform.GetChild(0).gameObject; This line right?

rocky canyon
#

use Debug.Log(attackArea.name); in ur script

#

you'll see which object u after have assigned in the console

sturdy cairn
#

I have a bit of intermediate java knowledge so I'm not CLUELESS. It's just my first time dipping into unity and it's for a project

#

It's returning this in the log. So it's assigning attackArea as that first thing then?

gaunt sandal
#

This would probably be easier explained that way

sturdy cairn
#

Yeah probably. I think I get the problem now. Just need help with a solution

gaunt sandal
#

I'm down to help set you on the right track over a call

sturdy cairn
#

Sure then.

#

Would it be a vc in this server?

gaunt sandal
#

don't think they have a vc in this server

north scroll
#

hi im following a codemonkey tutorial on the new u6 networking stuff and im having issues spawning in a prefab:

#

the debugs arent even showing on the console

#

whoops theres a networking channel

pulsar violet
#

Apparently everything i wrote didn't save, and all my work was in vain

verbal dome
#

Wrote where? If you mean a discord message, it has Ctrl+Z

pulsar violet
#
  • i can't get the c# extension working in ms visual studio
eternal falconBOT
pulsar violet
#

I installed it manually

edgy tangle
pulsar violet
#

):

#

I am using unity 5

verbal dome
#

Why

edgy tangle
#

Haven’t heard that name in like 6 years

pulsar violet
#

Cause my old pc doesn't support unity 6

edgy tangle
#

Or maybe longer…

pulsar violet
#

It doesn't even support 2021,2022,2023

verbal dome
pulsar violet
#

Or anything

#

Yea

#

It is too old

#

Thats the reason why i am using monodeve

#

Cause it still has some intellisense

#

If you know what i mean

verbal dome
pulsar violet
#

Nope

#

Unity 5.6

#

Is the latest i can use

#

I wanted to use bolt ngl

#

Sadly that too doesn't work

north kiln
#

you're not gonna be able to get much help around here for working with a 8yr old release

timber tide
#

what's the problem with the later versions?

faint agate
#

Is there a way I can do this without tags
Public GameObject[] gameobject;

gameobject.SetActive(true);

pulsar violet
edgy tangle
faint agate
#

Its giving me an error

pulsar violet
#

I was wondering the same thing

#

Lmao

edgy tangle
pulsar violet
#

What is array

edgy tangle
#

You need to get an element out of the array or use a for loop if you want to do it to them all

pulsar violet
#

Ok

edgy tangle
pulsar violet
#

Ok its kinda complex

faint agate
#

heres the script incase but ill look into the forloop method

edgy tangle
#

Yes you need to use a for loop or a foreach loop

#

Just use foreach

#

I’m on mobile so forgive me code format police.

But you need to do:

foreach (var target in Targets)
{
target.SetActive(false);
}

pulsar violet
#

Sorry i am on mobile too atm

pulsar violet
#

I don't understand what is capitalisation

#

You mean Aa

edgy tangle
#

Good night

#

lol

pulsar violet
#

I just started coding yesterday

#

);

verbal dome
pulsar violet
#

Yes i did everything, read the manual, ask ai

#

But nothing worked

verbal dome
#

About capitalization?

pulsar violet
#

No

#

About what was wrong with my script

#

I was making a scoring system

verbal dome
#

Capitalization

#

Is what seems to be wrong

pulsar violet
#

Getcomponent

#

getcomponent

#

What is the difference

verbal dome
#

And GetComponent

pulsar violet
#

Ohhh

verbal dome
pulsar violet
#

I am gonna fry my brain with this one

verbal dome
#

Wdym "what's the difference"

pulsar violet
#

I just started yesterday I don't even know scripting

#

I just looked up for a tutorial on yt

#

And found a flappy bird tutorial

#

I got the bird to jump and pipes to spawn

#

But the ui of the game is killing me

slender nymph
faint agate
spiral glen
#

can someone link the setting up visual studio channel on this discord, i cant find it

slender nymph
#

!ide

eternal falconBOT
spiral glen
#

thanks

slender nymph
burnt vapor
# pulsar violet What is the difference

For your information, capitalization is important in C#. You must use proper capitalization or you will not find the method (or conveniently use a method with different casing if it were to exist)

#

Also, I don't understand how this can be an issue. If your editor is properly configured then it would provide the available methods for you.

#

So I can only assume it's not configured

burnt vapor
pulsar violet
#

The problem is i am using unity 5

#

I changed the preference to visual studio code

#

But Still doesn't work

burnt vapor
#

So if you type Get in the code then it suggests the method?

pulsar violet
#

No

#

Thats why i used monodevelop

#

It kinda helps complete the code

#

But it lacks the basic facilities that visual studio code provides

burnt vapor
#

Monodevelop???

pulsar violet
#

Yessir

burnt vapor
#

Isn't that like ancient and no longer developed?

pulsar violet
#

Yes

burnt vapor
#

Why aren't you sticking to the newer versions?

#

Visual Studio Code now has C# Devkit

pulsar violet
#

Well i am on a older visual studio code too

#

1.70 i think

burnt vapor
#

Why?

pulsar violet
#

My pc is 32 bit and win 7

#

Yea i did know i can never make games on this crap

burnt vapor
#

I don't see how a different plugin would not work

pulsar violet
#

Wait what

#

What other plugins can work

burnt vapor
#

Also, Unity 2022 LTS still works on Windows 7

burnt vapor
pulsar violet
#

It probably doesn't support 32bit

burnt vapor
#

Did you try?

pulsar violet
slender nymph
pulsar violet
#

Yes

#

I just read the requirements

burnt vapor
#

😮‍💨

#

Okay well

pulsar violet
#

Saddd

#

I might just give up and buy a new pc

#

But i am waiting for 50 series to drop

burnt vapor
#

That is probably the best thing you can do here

pulsar violet
#

I swear i am gonna buy the 5070

#

Sure is

lean basin
#

I watched youtube video of someone doing this:

    void ProcessEnemies(List<Enemy> enemies) {
        for (int i = 0; i < enemies.Count; i++) {
            var enemy = enemies[i];
            if (enemy.dead) {
                enemies.RemoveAt(i--);
            }
    }

I was confused why enemies.RemoveAt(i--) doesn't give compile time error. I thought i-- meant subtract i with 1 and return nothing, does it also return the value of i-1? Or am I completely misunderstand it?

scarlet shuttle
rich adder
lean basin
#

waiit a minute shouldn't it be enemies.RemoveAt(i); i--? The script above would remove the previous entry on the list wouldn't it?

rich adder
scarlet shuttle
rich adder
scarlet shuttle
#

So this is bad? In this case

rich adder
#

I have no idea what they're going for tbh. They might be confusing what the function does

scarlet shuttle
#

This is just all sorts of bad

rich adder
#

just cause its not compile error, doesn't mean it does what they think it should

scarlet shuttle
#

Does c# loop indexes? Like -1 is the last element