#💻┃code-beginner

1 messages · Page 463 of 1

slender nymph
#

that is one reason why many people suggest learning to code before starting with learning game development.
but also a lot of the documentation is easy to understand if you have even a baseline knowledge of coding because it is laid out fairly well and many doc pages include examples

obsidian granite
#

learning from docs is fine for learning engines, but if you don't know how to code

#

then docs won't help with anything

summer stump
mint remnant
obsidian granite
#

this is someone that was asking why curly braces were included in their code. what makes you think they'd be able to decipher docs?

summer stump
#

Rust, c#, python, all languages I know have written documentation, and that is the best way to learn

obsidian granite
#

might take a game dev course

summer stump
obsidian granite
#

the unity docs don't give c# basics

summer stump
obsidian granite
#

earlier you provided w3schools and the unity docs to that person

summer stump
#

Yes, w3schools

obsidian granite
#

w3schools is cool (although i've never found it helpful)

#

but the unity docs would be awful to parse through, no?

summer stump
#

No.
But I linked w3schools and LEARN.UNITY

#

Not the docs

obsidian granite
#

ooooh

#

mb

summer stump
#

But even the docs would be good and easy to parse if they knew some basics by doing w3schools first

#

I HARD disagree with what you are claiming

obsidian granite
#

did you learn your first language through docs?

summer stump
#

Yes

#

That is what I am saying

#

10 years ago I used pythons own documentation to learn it. Then the pygame docs. Then microsofts documentation, then unity's documentation

obsidian granite
#

how did you even understand the docs though. i feel like docs in and of themselves require some amount of knowledge of the language to understand

summer stump
#

I peppered in sololearn and microsofts guide here and there

obsidian granite
#

oh the LANGUAGE'S docs

#

yeah nvm i get u now

summer stump
#

Because they are easy to understand if you are willing to put in any effort
If you don't understand a word, write it down. Then look it up. Then write down the definition next to it. Eventually you have a dictionary

#

Revisit and revise it as you learn

obsidian granite
#

i learned my first language through experimentation with concepts that were shown in YT videos and then research, but i didn't even know what docs were until like 6 months in

#

i guess it's just a foreign concept to me that one can be self-taught entirely off of docs

mint remnant
#

youtube didn't always exist, books was the main way to learn

summer stump
#

Youtube is just... such a bad way to learn. People do it, but they don't learn to learn at the same time, so it hinders their education

#

Learning how to read docs is so important. And learning FROM the docs teaches you that alongside whatever else you are learning

#

Also learning from books helps learn to learn as well

obsidian granite
mint remnant
#

a major problem with yuotube is anyone can make a video, even bad ones

obsidian granite
#

so i wouldn't know

plain abyss
#

Can anyone help me approach this task
I have a unity dropdown with around 40 items
is there a way I can a add a search bar to the dropdown?
to make a searchable dropdown?

ripe shard
plain abyss
ripe shard
plain abyss
ripe shard
#

no

#

just the code itself

#

stuff like this typically has a lot of edge-cases you need to handle, so you can't easily compose it from existing components.

void thicket
#

Pretty sure UI-Extensions have an impl for it

ripe shard
#

it doesn't

final kestrel
#

Hey all good evening. I am having real hard time understanding things right now. I have a parent empty called Handle which is just a pivot for my door child object. On the handle I have this script https://hatebin.com/wzssvlswri. The save method works fine as I can see both the door rotation and handle rotation on my save file. I move the door on interaction with activating its animation. My problem is that when I load back. I expect my door to be open but it does not seem to read the values and put them back on my door.

#

These are the saved values

#

Well I guess people are not online. I'll try tomorrow.

deft grail
final kestrel
#

Yes

deft grail
final kestrel
#

The load gets called on my other objects just fine

#

The ones that implement the interface that is

deft grail
final kestrel
#

okay I will do it now

deft grail
# final kestrel okay I will do it now

they are either the wrong values so the save is wrong.
they are the correct values so you are applying them wrong / they are being overwritten.
or something that idk 😂

final kestrel
#

I must be applying them wrong

deft grail
#

and if thats all correct

#

then you are probably overwritting it somewhere else by mistake

#

also make sure you log the object that you are applying it too

#

log everything that you need to log pretty much

final kestrel
#

I am reloading the scene to see if it works maybe there

#

but again my other objects are where I leave them

#

There is probably something I dont get with Parent Child relation maybe

thorn creek
#

Im being drivin up a wall with a bug in my game, hopefully someone here can give me an idea of whats causing the issue ><

thorn creek
#

uhh im trying to remember the site to send code

eternal falconBOT
thorn creek
#

but tldr when my player is in a trigger box, and they get teleported, the game still thinks they are in the box

deft grail
#

ah using a CC, i think same thing applies

thorn creek
#

i have been self teaching through gpt >< im still extremely new

deft grail
#

need to move the actual character controller too

thorn creek
#

ill try to see if i cant get it to work based off whatcha just said

deft grail
#

oh wait you already do that huh 🤔

thorn creek
#

im stumped >< but ive also been working on this game for 22 straight hours now lol, if anyone has any ideas, ping me and ill troubleshoot tomorrow. I really need some shut eye.

#

here is my trigger box lightswitch script if it helps, i figured it might not be updating every tick to check if the player is still inside or something :/

shell vortex
#

anyone know how to make it so there is a script on object awake that changes the transparency of this shader from transparent to opaque? I got the first part down, but it only works on default URP materials. Idk how to make it change basecolor transparency on this shader.

#

nvm fixed it, reference in the shaader was wrong

queen adder
#

since ur in gtag discord, prolly a gtag fangame

queen adder
#

they gave me something to copy and paste instead...

deft grail
#

the best way of learning is just doing it yourself

queen adder
deft grail
# queen adder i literally just started tho, i have no idea how to do it

for example if you wanna make a 2d top down.
you would need something for collision, something to move it around, then find out how to move it around, how to take input, etc.
you can find all of this on the Unity Docs for basic methods, then you can combine them to make an actual script

#

i think its much better to just look at the docs and try figuring out something yourself

queen adder
#

okay

deft grail
# queen adder okay

and before you do that you can follow 1 or 2 tutorials just to get a feel for Unity and how to navigate some basic things.
or you can do that yourself up to you

ivory flare
#

chat im starting to get the feeling that my ai is not evolving (someone pls help me i dont know why its not working)

queen adder
#

in unity learning should I finish unity essentials or immediately move onto the vr one?

ivory flare
slender nymph
#

or, more likely, you'll actually get a response at some point instead of your question going completely ignored because ML Agents is not something the typical unity user has any experience with so a channel dedicated to AI tools such as ML Agents where people who have experience with that stuff hang out is a better place for that

frosty hound
#

You may want to actually provide information on your implementation as well. Your question is impossible to answer otherwise.

ivory flare
ivory flare
slender nymph
#

if you had bothered providing any useful information then maybe someone would have known that 🤷‍♂️

frosty hound
#

Baiting people actually makes people less likely to help. We require people to actually ask questions in entirety.

ivory flare
#

well can someone help me?

summer stump
deft grail
frosty hound
rocky canyon
#

real quick.. if i instantiate an object within a trigger will its OnEnter get fired?

frosty hound
#

Nope

rocky canyon
#

hm, what would be a smart alternative?

frosty hound
#

Probably just overlapsphere or use ontriggerstay

rocky canyon
#

bet 👍 ill check out both

#

not sure if it'd be better to change which object detects what at this point

frosty hound
#

Not sure, depends on what it's for. If it's something like explosion radius detection, then you wouldn't use a spawned object at all.

rocky canyon
#
    void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("IncomingProjectile"))
        {
            FuturePosition futurePosition = other.GetComponent<FuturePosition>();
            if (futurePosition != null)
            {
                Transform specialMarker = futurePosition.GetSpecialMarker();
                turretController.ActivateTurret(specialMarker);
            }
        }
    }```
#

the turret has a big sphere so. when a projectile enters it gets activated.

#

but theres at times when the projectile may spawn within it.. but i guess that'd be a no-go for detecting it

frosty hound
#

I would overlapsphere (use the nonalloc method) this for sure.

rocky canyon
#

alrighty.. i'll def take ur word for it..

#

the nonalloc part always eludes me

frosty hound
#

It's just predefining the size of the array that will store the things it finds

#

So you're not making a new array each time

rocky canyon
#

all i know is its better

#

lol its been drilled in my head

frosty hound
#

You will have to handle the nulls in it though, but that's simple enough

rocky canyon
#

predictive projectiles and the rotation logic was hard af

#

now this.. (technically i need a collection of all projectiles within the dome)

steep rose
#

remember to commit

rocky canyon
#

and it'll focus on 1 until a hit is made.. and then switch to the next asap

frosty hound
#

Just in order of how they enter the area?

rocky canyon
rocky canyon
steep rose
#

dont be losing projects now

rocky canyon
#

but yes, first.. wait how would i incorporate both?

steep rose
#

i dont want that on my hands 😅

rocky canyon
#

lol.. first and then closest.. 🤔

frosty hound
#

You have to define that. Do you want closest always, or closest when not actively targeting something else?

#

Or is that something the player can toggle?

rocky canyon
#

the player only has control of when to fire atm.. but im still brainstorming.. its leaning towards an autonomous passive system

frosty hound
#

Or technically, you'd probably want the one that is last to enter so that it has the longest amount of time to take it down

rocky canyon
#

right now the projectile has to also find the turret.. so it can get the distance and do the math for projection distance

#

which is a mess.. its actually just a serialized private var atm.. it was outgrowing while i was building

frosty hound
#

That does seem backwards. The turret should be handling all of that in it's target aquisition logic.

rocky canyon
#

yea.. its broken

#

the TurretRange finds the "IncomingProjectile" -> gives it to the TurretController to get its projected position

#

but the IncomingProjectile has to know the turret so it can do its distance/math

hoary citrus
#

Why does the projectile need to know the distance?

rocky canyon
#

it shouldnt but it does.. im workin on that right now lol

#

the overlapshere solves that too

frosty hound
#

Turret:

  1. Overlapsphere to grab all projectiles in range
  2. Find the cloest one by getting the ProjectedPosition property off them and calculating the distance

It's really should be that simple.

rocky canyon
#

the thing the turret actually aims at to hit its mark

hoary citrus
rocky canyon
#

ya. i agee it can be done there..

hoary citrus
#

The turret gets the projectile and its velocity and calculates where it's going to be in the future

#

Makes more sense to me

#

Making the projectile calculate that seems to needlessly complicate things. Unless I'm misunderstanding something

rocky canyon
# hoary citrus Makes more sense to me

ya it does now to me as well, while i was trying to build this.. for the past day and a half.. quaternions for the turret.. and the trig stuff got my brain melted lol

rocky canyon
rocky canyon
#

solid hit 🥳

steep rose
#

you tryna make a CIWS?

twin wagon
#

I’m trying to make a mobile game I need help and a lot of it do you guys know were I should look

deft grail
rocky canyon
twin wagon
rocky canyon
#

they'll get more futuristic/plasma like before im finish

deft grail
twin wagon
stoic oracle
twin wagon
#

I’m fine with paying

deft grail
twin wagon
hoary citrus
hoary citrus
twin wagon
#

And also should I start trying to make a game that is the game I want to make in the long run or just make random games until I feel confident to make it

deft grail
twin wagon
#

I’m really really new to this stuff💀

twin wagon
#

Bucko

stoic oracle
deft grail
hoary citrus
steep rose
#

for a beginner i would not do anything complicated

#

it will only break you and make you quit

#

trust me

#

i know

twin wagon
#

Alright thank you all for helping today is literally my first day

#

So just to sum up what you all said is to just slowly learn until I get good

steep rose
#

you can learn fast or slow depending on how fast you learn, but take it easy and dont do anything to hard

#

when you learn unitys quirks (and general coding knowledge) then you can do something big

deft grail
#

not to say making a mobile game is difficult in your first few weeks, it absolutely is doable
but its better to not start with that AT FIRST

steep rose
#

if you dont want to pay for a course i suggest !learn ing the basics of unity

eternal falconBOT
#

:teacher: Unity Learn ↗

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

twin wagon
deft grail
#

or theres probably some other way to mirror it also that i dont know

#

and the main thing is do you have android or iphone?

twin wagon
deft grail
#

its much easier to do it on android

twin wagon
deft grail
#

and also if you wanna publish games its much easier on google play store

deft grail
deft grail
#

and if you wanna just play it yourself, then thats also pretty much only doable with like mirroring i think

deft grail
cosmic dagger
twin wagon
deft grail
#

^ its called GBP

twin wagon
steep rose
#

its not but alright

deft grail
twin wagon
steep rose
teal viper
#

Btw, to answer your original question, unity remote is still available both for Android and iOS I think. Though, it doesn't really run the game on your phone. It just forwards the output to the phone screen and input to the editor.
So if you want a proper test, you'll need to build.@twin wagon

deft grail
twin wagon
#

Sorry I’m a bit slow

teal viper
#

Build a build of your project

#

Probably shouldn't worry about it until you !learn the basics.

eternal falconBOT
#

:teacher: Unity Learn ↗

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

deft grail
#

like a .exe for example, you might understand better

#

or any normal app

stoic oracle
eternal falconBOT
#

:teacher: Unity Learn ↗

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

timid quartz
#

I am writing an automatic map-creation script, and I have a terrain that I am reading the alphamaps from and associating each location with a pixel in a texture I am creating. however, the alphamaps I am getting appear to be essentially random noise - am I getting the right thing?

here I cache the alphamaps in a float[,,] array CachedTerrainAlphamapData

        CachedTerrainAlphamapData = terrain.terrainData.GetAlphamaps(0, 0, terrainwidth, terrainheight);

        print("Terrain Length: " + CachedTerrainAlphamapData.GetLength(0)); // 1000 - length in inspector
        print("Terrain Width: " + CachedTerrainAlphamapData.GetLength(1)); // 1000 - width in inspector
        print("Number of Terrain Layers: " + CachedTerrainAlphamapData.GetLength(2)); // 8 - number of layers

        int index = 0;

        // find the most dominant texture index
        for (int x = 0; x < CachedTerrainAlphamapData.GetLength(1); x++)
        {
            for (int y = 0; y < CachedTerrainAlphamapData.GetLength(0); y++)
            {
                int layer = GetMostDominantTextureIndexAtLocation(x, y);
                MapColor[index] = colors[layer];
                index++;
            }
        }```

And then I grab the dominant texture here index:

```    int GetMostDominantTextureIndexAtLocation( int x, int y )
    {
        int mostDominantTextureIndex = 0;
        float greatestTextureWeight = float.MinValue;

        for (int index = 0; index < CachedTerrainAlphamapData.GetLength(2); index++)
        {
            float textureWeight = CachedTerrainAlphamapData[y, x, index];

            if (textureWeight > greatestTextureWeight)
            {
                greatestTextureWeight = textureWeight;
                mostDominantTextureIndex = index;
            }
        }

        return mostDominantTextureIndex;
    }```
#

I have to swap the X and Y around because the alphamaps are funky in their ordering, but even if I swap em all around, it shouldn't create the even noise pattern shown here. One of my tests had 8 terrain layers, of which only 2 were used, and I was seeing values of 0, 1, 2, and 3 where 2 and 3 weren't actually painted anywhere

#

It seems like the problem MUST be in my most dominant texture at location function, but I can't see how I'm doing it wrong at all

teal viper
teal viper
timid quartz
#

earlier in the flow - that being said, the colors themselves are totally working - the noise in pic 1 is a blend of color 0 and 1 that do indeed match visually to the only two terrain layers I have

#

I also overrode every pixel with colors[0] and it turned completely brown, no noise variation at all, so the problem isn't texture filters or something being blended visually - it's a sharp brown square

#

turning on debugging mode atm, so we shall see what's up

eternal falconBOT
#

:teacher: Unity Learn ↗

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

timid quartz
#

alrighty. the texture weight at cell 0,0 is apparently 3.8322425E-29 which makes me think this is a rounding problem

#

adding a math.round to 2 places makes the noise much less pronounced

teal viper
#

Floating point error

timid quartz
#

gross that it's a floating point error from GetAlphamaps though

#

that's unity's code 😦

teal viper
timid quartz
#

fair enough

summer stump
#

It is kinda implicit to how computers function. You are storing an infinite amount of numbers in a finite amount of bits

pulsar forum
#

If your dealing with a fixed range, try to always use uint, you get more precision. There’s probably a render texture data format that’s like this, but worse come to worst, you can store it as a buffer.

timid quartz
#

unfortunately the data comes out of the terrain as a float

summer stump
timid quartz
#

I have not, trying that now

sour fulcrum
#

Not sure where to put this or what to google for this but every time i scope to a specific folder it resets on solution and/or project reload. Is there a way to permanently scope to a specific solution and/or permanently hide unwanted solutions from appearing here?

foggy saffron
#

Hey peoples.. sorry if this is a bad question... but if I have two game objects and both have colliders and at least one has a rigid body they should interact right?

timid quartz
#

my next plan is to try to display the alphamaps themselves to see if something I am doing is just really wrong

summer stump
#

They should collide even without the rigidbody
Physics messages require it though

pulsar forum
#

They won’t move without a rigidbody

foggy saffron
summer stump
#

The Three Commandments of OnTriggerEnter:

  1. Thou Shalt have a 3D Collider on each object
  2. Thou Shalt tick isTrigger on at least one of them
  3. Thou Shalt have a 3D Rigidbody on at least one of them
sour fulcrum
foggy saffron
#

yeah all those rules are checked

summer stump
#

The Three Commandments of OnCollisionEnter:

  1. Thou Shalt have a 3D Collider on each object
  2. Thou Shalt not tick isTrigger on either of them
  3. Thou Shalt have a 3D Rigidbody on at least one of them
foggy saffron
#

OnCollisionEnter?

summer stump
pulsar forum
#

You have to manually move them without rigid bodies

sour fulcrum
#

@summer stump you forgot the forth commandment that the layer on both objects are an approved collision in the projects collision matrix

summer stump
foggy saffron
cosmic dagger
summer stump
sour fulcrum
pulsar forum
#

You mean collision resolution right?

foggy saffron
summer stump
summer stump
foggy saffron
#

on both or at least one? I'm 99% certain it was working when both on istrigger checked.

summer stump
#

OnCollisionEnter will never work if one of the two is a trigger

cosmic dagger
summer stump
#

So you remember wrong. You likely were using OnTriggerEnter

teal viper
mint imp
#

no idea why this isnt working but i have a script that starts a sound when you die can anyone help?

foggy saffron
#

oh sorry its onTriggerEnter

summer stump
sour fulcrum
pulsar forum
#

Wait he probably means collision resolution. Like, you can’t apply forces to get movement without a rigidbody, so you can’t get two objects to collide without physically changing their position

foggy saffron
teal viper
summer stump
# foggy saffron

Set collision mode to continuous. Then show the script

That collider on the second object is tiny it looks like

sour fulcrum
#

hm alright lemme peep that, ty chef

teal viper
foggy saffron
summer stump
pulsar forum
cosmic dagger
summer stump
# foggy saffron

What script is this? It is on the object NOT tagged Farmer, right?

mint imp
#

its working for me and it is not called every frame btw

#

im worried about the sfx

foggy saffron
summer stump
#

I have no idea what they are saying honestly. Very confused about all their responses

sour fulcrum
#

perfect ty @teal viper, i've tried that before but had some problem that must have been unrelated. on some bigger projects i get a suprisingly notable performance drop in VS with so many solutions loaded

cosmic dagger
summer stump
# foggy saffron correct

Ok, then 1, are you moving with the rigidbody?
2, put a debug.log BEFORE the tag check in OnTriggerEnter, see if that triggers

mint imp
#

ok it works now

#

i fixed it

cosmic dagger
pulsar forum
summer stump
mint imp
#

its called in another function which is called from an if statement in update

pulsar forum
summer stump
#

Absolutely incorrect

pulsar forum
#

Why?

foggy saffron
summer stump
#

OnTrigger requires a dynamic rigidbody on one of the objects, or PhysX will not send the message
It will be sent to both objects involved though, even one without an rb

pulsar forum
#

Is that not the purpose of a collider to detect collision?

cosmic dagger
mint imp
#

bro i told u i fixed it mg

summer stump
mint imp
#

both of the issues

summer stump
#

Instead of transform.Translate or transform.position =

foggy saffron
cosmic dagger
mint imp
#

i did tho check it

summer stump
mint imp
#

i said the issue was the sound

#

not directly but you could tell

summer stump
pulsar forum
foggy saffron
#

Yeah Im just confused because I have GameObjects that are interacting just find one has Rigidbody and one without and they are both checked for Is Trigger

summer stump
summer stump
foggy saffron
#

not yet trying to keep up with this.. one sec

summer stump
#

Ok yep, transform.Translate, PLUS the tiny collider leads me to suspect you are just teleporting right over it

foggy saffron
#

I know my code is messyt

#

so the collison meshes are just missing?

summer stump
foggy saffron
#

looking at it now and they are big enough to cross through each other

summer stump
#

Generally if you have a rigidbody, you should move with it

summer stump
foggy saffron
#

where do you see that>?

#

ah the collider size I see it now

foggy saffron
#

yeah no its small but they pass through. I'll get a screen

summer stump
#

I mean, you are still moving with the transform though. Which is a problem

foggy saffron
summer stump
#

If you have a rigidbody, use it
You should pretty much NEVER move a player with transform imo

timid quartz
foggy saffron
#

I only have a rigidbody for the trigger should I use OnCollisionEnter instead so I don't need the Rigidbody?

summer stump
foggy saffron
summer stump
#

Rigidbody movement is quite simple

foggy saffron
#

You said OnTriggerEnter requires it and OnCollisionEnter does not..

summer stump
foggy saffron
#

oh no you said they both need it

summer stump
#

Have you done the debug.log. we may be chasing the wrong issue 🤷‍♂️

#

That log is absolutly crucial knowledge

real falcon
#

I'm trying to make a flashlight follow where you're looking on a delay, and with a maximum "drift" from the center, but I can't figure it out

#

something about trying to get the motion of the camera's rotation maybe? im not really sure

foggy saffron
#

like that?

real falcon
#

also is there a way to turn off gizmos without turning off debug rays its very annoying

summer stump
summer stump
real falcon
#

I dont want to manually unselect all of them and then manually reselect all of them once im done looking at a debug ray

#

I just want the ray to not turn off when gizmos are

summer stump
#

Then no afaik

real falcon
#

:(

#

guess ill just keep them off always

foggy saffron
#

its working Looks like I'm getting a NullReference for the line 31 thats not being used atm

real falcon
#

oh right, I've been through this before and I can't even turn the ones for lights and particle effects off at all

summer stump
#

So that is the problem. Absolutely nothing wrong with OnTriggerEnter or the interaction

foggy saffron
#

whats a good one to use?

summer stump
#

!code has a list

eternal falconBOT
real falcon
#

so I just can't turn these off?

rich adder
summer stump
real falcon
summer stump
#

That is it 🤷‍♂️

foggy saffron
#

it shouldn't be anything that would mess up the OnTriggerEnter

summer stump
foggy saffron
#

oohh

summer stump
#

That is literally the entire problem

#

That is the ONLY problem

foggy saffron
#

I didn't realize that was killing the code

summer stump
#

Errors HALT execution of the code

#

Nothing after the error happens

foggy saffron
#

Ah

summer stump
#

Errors should also NEVER be ignored. Even in other scripts or something

#

If you want to ignore them, the only "safe" way is to comment out the code causing them (or delete of course, or put behind a nullcheck condition in this case)

foggy saffron
#

yeah of course.. that makes sense.. I just didn't realize that was killing the code like that.. and I didn't think to try at least commenting out that line to see what would happen

summer stump
#

No worries. This is a good learning opportunity

foggy saffron
#

indeed

#

thanks for you patience

summer stump
#

No problem at all. Best of luck with everything

foggy saffron
#

now I just gotta tackle the other shit I broke when I tried to organize this thing

mint imp
#

can someone help me with this, the sfx isnt playing

lean anvil
#

I got this issue and im pretty confused about this namespace error.

north kiln
lean anvil
north kiln
#

!vs

eternal falconBOT
#
Visual Studio guide

If your IDE is not underlining errors in red or autocompleting code,
please configure it using the link below:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

rich adder
mint imp
#

its when you die

rich adder
mint imp
#

it runs

#

cuz the rest of the things in the if statement run

north kiln
rich adder
mint imp
#

nah

#

i checked that too

north kiln
rich adder
lean anvil
north kiln
mint imp
#

ok gime a sec

#

it happens with collisions so that might be why

rich adder
mint imp
#

ok

rich adder
#

nvm i think it would throw warning

#

try putting another audiosource on a new object and leave loop and play on awake on, see if you hear anything at all

mint imp
#

im lowkey getting kinda tired

#

i will continue tmr

young magnet
#

Hi there, not sure if this is the right place to ask, I have a pretty basic level here, just a cube moving forward on a flat plane dodging some obstacles, but I've noticed that very shortly after beginning and moving a bit left and right using AddForce(-sideForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange); (opposite of this for the right movement), my cube seems to slightly rotate, I've thought about adding a constraint on rotation, but then hitting objects wouldn't give me the same physics result that I want, having a proper collision.

Not really a coding issue, just looking for ideas on how to keep my rotation while being able to still rotate on collision.

lean anvil
wintry quarry
young magnet
#

is there a reason not to use deltaTime as I did? and yes it is in FixedUpdate.

that's the weird part about the rotation, I have 0 friction, really unsure what makes it spin

teal viper
# young magnet is there a reason not to use deltaTime as I did? and yes it is in FixedUpdate. ...

In this particular case(fixed update) the only downside of multiplying by delta time is that it's confusing you(or whoever reads it) and makes you adjust the value of the force to compensate the multiplier.
In fixed update delta time is basically a constant, so you're just multiplying your force by something like 0.02 every time.

Now if it was in update, that would be a problem, because then you'd make it frame rate dependent, as the delta time in update changes based on the frame time. So you would have different force applied every frame. However, due to the way unity physics works, the force is actually applied at fixed intervals. So basically you're introducing a variability into these fixed intervals.

teal viper
wintry quarry
foggy saffron
#

ok this one has been confusing me for a while when using this script https://hatebin.com/bomtpcothv on the highlighted prefab how do I get the scorecounter on the prefab? am I needing to drag the script on the open prefab to save it there before its called?

#

it works because im using FindObjectOfType but that's not how I want to make it work right?

young magnet
onyx tide
#

Hello whats the best network tool for a first multiplayer project ?
I saw a lot of option like Miror, Photon...
I just want to make a 1v1 FPS game with LocalHost

strong wren
strong wren
thorn creek
eternal needle
# thorn creek https://paste.ofcode.org/35RiqFYk8aS6Qe9EcuQMKKx

is this AI code or something?
Also what about this is "game still thinks they are in the box". The game thinks nothing here, no values are being saved and this method would just run once when touching the trigger and thats all. Whats actually happening thats not supposed to happen

real quarry
#

does anyone know what the "PPtr cast failed when dereferencing! Casting from GameObject to Transform!" is about i cant seem to locate what needs to be fixed

cosmic dagger
thorn creek
#

The second code isn’t ai and was built by a prof of mine

#

Which is why I thought the first would be the issue

eternal needle
thorn creek
#

The second script is just on a trigger box next to a light switch that when the player is in allows them to press e to start the light switch animation, and play an audio of a switch being turned on/off

#

When the trigger box with teleportation is attached to a monster, that paths into the player next to a light switch, the player does teleport but can now activate the light switch from anywhere on the map

#

Because the player never “onexits”

#

Or at least it’s not picking up that the player is no longer there, the value only saves once, if the player teleports again, the new location is saved and the bug gets fixed

mint remnant
#

so you wrote neither script?

thorn creek
#

Correct

eternal needle
#

add debugs to see whats specifically happening. You really arent gonna get much help with AI code that you dont understand yourself

thorn creek
#

I’ve been working with ai for 8 months and have an almost completely polished game, just a few small bugs such as this one remain, this is the way I’ve chosen to learn to code as being in a classroom setting with deadlines does not work for me

mint remnant
#

interesting way to "learn"

thorn creek
#

I understand quite a bit of the code that’s given to me at this point, it’s been painful but I have a lot of trail and error experience

mint remnant
#

turn in your programmer badge on the way out

eternal needle
#

especially since you have 0 debug logs in your code

thorn creek
#

I have tried using debug logs but knowing that onexit isn’t called doesn’t help me understand why it isn’t being called

thorn creek
#

Ai is a very valuable tool, if you don’t like it, don’t use it. But don’t call other people stupid for trying.

eternal needle
#

did you even read the code it gave you?

#

You cant call it a valuable tool when its filled with bugs you dont understand

mint remnant
#

your going to need a bigger toolbelt, one with debugging skills in it if relying on AI

thorn creek
#

< this is the last big remaining in my hour+ long game that has been in development for 6+ months, I wouldn’t be reaching out if I believed that ai could fix this particular problem

eternal needle
#

this is likely part of the issue from your useful AI code

                    // Disable the collider temporarily to force the OnExit event
                    playerCollider.enabled = false;
thorn creek
#

Hmm I believe that was added to try to remedy the bug and I had forgot to take it out before posting here

#

Because onexit was never being called I think..?

#

I’ll throw some debug logs in and come back with a more solid question

eternal needle
#

again, read the code you're actually using. AI doesnt know how to code. Its generating the most likely text to make you happy, and you've fallen for it. The comments are complete bullshit

#

its really clear you didnt even read the code. Look at these 2 lines

    private void OnTriggerEnter(Collider other)

and later on


                Collider playerCollider = other.GetComponent<Collider>();
#

Also part of the issue could be if you dont have a rigidbody (kinematic) on the character

thorn creek
#

I really appreciate the info, I’ll see if I can make it work based on that. Sorry if I was getting a bit heated.

#

yeah i do have rigidbody, using unitys FPC, ill look into the rest though

#

but i mean i did read the code, it looks good to my eyeballs... maybe? "if collider enters trigger, execute" for the first line right?

#

bah nvm lol ill look into it XD

thorn creek
#

working now, thanks

dapper egret
#

Not sure where to post this but i am having issues with my unity hub,some tabs being opened and closes looks strange like this

#

same thing happens for unity 6

languid spire
dapper egret
#

look at the top left

#

if i open and close some menus their ghosts remains

dapper egret
languid spire
dapper egret
#

Ah crap i was hoping it wouldent be the case thx

languid spire
#

it may even be a monitor issue, can you try to use a different one?

dapper egret
#

i have a second one let me check

dapper egret
deft grail
dapper egret
#

Wonder if this could be a nvidia driver issue

languid spire
languid spire
dapper egret
dapper egret
final kestrel
#

Hey all. I'll post it again since it was late yesterday. I have this handle empty object parented to my door acting as pivot point. I play the open and close animation on interact. I am trying to save the handle's rotation on y. It gets saved to the file correct. Also logging the saved rotation seems correct. When I load however, It does not put the values back on the handle parent object, which is just the rotation.The script that is responsible for holding the empty's rotation data is on the child object. https://hatebin.com/rtsqhholku

#

Also the Load and Save methods gets called just fine if that matters.

#

Okay I had to disable the animator...

deft grail
final kestrel
#

yeah you were right but I never thought animator would be the issue...

#

Thanks a lot for yesterday also. Was so sleepy and frustrated I went to bed 😄

deft grail
final kestrel
#

I had an idle animation T_T

deft grail
final kestrel
#

Haha yeah you're right. Thanks again!

round mirage
#

Hello i want make a slow falling effect for my game (like in minecraft) someone know how i cant do it ?

verbal dome
#

Drag might give the effect you want too

round mirage
#

oh ok

#

i dont undertand drag slow down the rigidbody speed ??

fading dune
#

Hey everyone.

I've recently built a player controller for my 2D game that lets the player move in 8 directions. It works well overall, but there's an issue when moving diagonally. For instance, if I'm moving southeast by pressing S and D, and then release the keys, the character goes into an idle animation. However, the character often ends up facing east or south instead of southeast. This probably happens because I don't release both keys at the same time. Any ideas on how to fix this? Perhaps a small delay might help, but I'm not sure how to implement it.

Thanks in advance for any advice!

verbal dome
round mirage
#

oh

short hazel
#

Yes it simulates the friction of air over the rigidbody. Like with real life physics, drag increases exponentially the faster you go, the more drag you get

round mirage
#

and i cant do it with only the Y axis ?

short hazel
#

Nah drag is applied on the whole velocity at once. If you want the effect like the "slow falling" potion, apply upwards force only

round mirage
#

ok

#

thank you 🙂

fossil tree
#

how can i change asset pixel per unit programatically ? i try GetComponent<UnityEngine.U2D.PixelPerfectCamera>().assetsPPU = 300; but that dosnt work i got this error:

CompleteCameraController.LateUpdate () (at Assets/Scripts/cameraController.cs:28)```
willow scroll
languid spire
willow scroll
#

There is no PixelPerfectCamera found

fossil tree
#

but i have a pixel perfect camera in my camera

willow scroll
#

You, probably, don't

languid spire
#

screenshot inspector

fossil tree
languid spire
# fossil tree

so why use GetComponent when you can directly reference?

willow scroll
#

Why directly reference if it's on the same object?

#

GetComponent is correct, I'm just not sure why you do this in LateUpdate

#

I've checked assetsPPU and its setter does not throw any errors

#

Please, show the full code

languid spire
#

that is exactly why you directly reference, because it is on the same object,

fossil tree
# willow scroll Please, show the full code
using System.Collections;
using UnityEngine.InputSystem;

public class CompleteCameraController : MonoBehaviour {

    public GameObject player;       
    public Control control;
    private Vector3 Origin;
    private Vector3 Difference;
    private Vector3 ResetCamera;

    private bool drag = false;
    private Vector3 offset;         

    // Initialisation
    void Start () 
    {
        ResetCamera = Camera.main.transform.position;
        offset = transform.position - player.transform.position;
    }

    private void LateUpdate()
    {
        if (control.gameStarted)
        {  
            GetComponent<UnityEngine.U2D.PixelPerfectCamera>().assetsPPU = 300;
            transform.position = player.transform.position + offset;
        }
        
        else
        {
            GetComponent<UnityEngine.U2D.PixelPerfectCamera>().assetsPPU = 150;
            if (Input.GetMouseButton(1))
            {
                Difference = (Camera.main.ScreenToWorldPoint(Input.mousePosition)) - Camera.main.transform.position;
                if(drag == false)
                {
                    drag = true;
                    Origin = Camera.main.ScreenToWorldPoint(Input.mousePosition);
                }

            }
            else
            {
                drag = false;
            }

            if (drag)
            {
                Camera.main.transform.position = Origin - Difference;
            }

            if (Input.GetMouseButton(2))
                Camera.main.transform.position = ResetCamera;

        }


    }
}```
willow scroll
fossil tree
#

transform.position = player.transform.position + offset; here

willow scroll
fossil tree
willow scroll
#

There is no player?

fossil tree
#

there is ?

willow scroll
#

Debug it

fossil tree
#

public GameObject player;

willow scroll
#

Debug it

fossil tree
#

that work if i remove the GetComponent<UnityEngine.U2D.PixelPerfectCamera>().assetsPPU = 300;

#

that not a problem with player

willow scroll
#

Why do you have 300 pixels per unit, despite having 320x180 resolution

fossil tree
#

ok that work i make it in a other way

#

just put a [serialized field] pixerlPerfectCamera variable

plain abyss
#

I have a dropdown with long options, is there a way I can avoid options from overlapping like this

willow scroll
plain abyss
willow scroll
queen adder
#

guys im tryna make a baldi;s basics mod

#

how do i fix this

desert plinth
#

Unity tells me I'm creating a stack overflow, but idek what that means, can someone tell me what's wrong about this? According to my Debug Logs the error is at line 94.\

#

Oh yeah line 94 is the first line in the function

#

Or float

plain abyss
desert plinth
eternal needle
desert plinth
willow scroll
eternal needle
eternal needle
#

Even that else if statement would be problematic

desert plinth
#

Okay thanks I'll try improving my script, my approach indeed was kinda stupid

queen adder
eternal needle
#

You can also just google the errors.

queen adder
#

last post was 2 years ago

#

💀

warm rock
#

hey, when i try to disable the PauseMenu it doesn't. . . but when i press to enable it. it works here is the main code for it public GameObject PauseMenu; public PlayerMovement playerMovementScript;

#
{
    PauseMenu.SetActive(true);
    playerMovementScript.enabled = false;
    Paused = true;
}
if (Input.GetKeyDown("escape") && Paused == true)
{
    PauseMenu.SetActive(false);
    playerMovementScript.enabled = true;
    Paused = false;
}```
#

I tried using Input.GetKey for both of them and it didn't work

wispy finch
#

Generally you'd want to use getkeydown for these, since it runs once, whilst getkey runs several times during the keypress, keyhold and keyup actions.

languid spire
warm rock
#

yes in update

languid spire
warm rock
#

its normal

languid spire
#

what happens if the first if is true?

warm rock
#

it will allow the second to run

languid spire
#

yes, immediately, so whatever is done in the first if is immediatly undone in the second

warm rock
#

ohh

#

then what do i do

languid spire
#

add an else

warm rock
#

ok

wispy finch
#

Just want to give a tip here; instead of rising these things of happening with several if-statements that are basically the same thing, you can make it "toggle" with one if-statement here.

warm rock
wispy finch
#

For each press, the 'Pause' boolean will toggle between true -> false -> true -> false, etc.

warm rock
#

i still dont get it

wispy finch
#

You'd have to complete this script with the player's movement in mind, since you seem to disable it when the game is paused, I believe you could finish it.

warm rock
wispy finch
#

If you don't understand it, it's fine.

warm rock
languid spire
warm rock
#

ok

#
{
    PauseMenu.SetActive(true);
    playerMovementScript.enabled = false;
    Paused = true;
}
else
{
    PauseMenu.SetActive(false);
    playerMovementScript.enabled = true;
    Paused = false;
}```
languid spire
#

you took the if out. Why?

warm rock
#

cuz i didnt work too

languid spire
#

I said ADD an else

warm rock
#

wdym

#

i added an Else

languid spire
#
else if (Input.GetKeyDown("escape") && Paused == true)
warm rock
#

ok

#

still not working

languid spire
#

So now change it as Victor showed as that is much better code. But you really need to learn how to read code

warm rock
#

i keep pressing ESC and nothing happens after enabling the PauseMenu

#

i will afk for a min sry

magic panther
#

Can someone help me figure this out? I need changing colliders in my tilemap objects, and the only way I could think of is check for neighbouring poles and enable boxColliders accordingly. This for some reason gives the result as in the screenshots.
Pole script -> https://gdl.space/ipecuhotoy.cs

normal rose
#

uh anyone here have tried using huggingface api?

#

im trying to find how to apply different model

#

but i dont know how

magic panther
#

If there's a better way to do this, I'd appreciate it

fossil tree
#

why the hell my character flying when i grab my falling block

my grab code:

onWall = Physics2D.Raycast(transform.position, Vector2.right, 0.05f, groundLayer) || Physics2D.Raycast(transform.position, Vector2.left, 0.05f, groundLayer);
            if (onWall && Input.GetKeyDown(KeyCode.LeftShift) && Time.timeScale != 0)
            {
                Debug.Log("grab");
                isGrabbingWall = true;
                animator.SetBool("IsGrabing",true);
                rb.velocity = Vector2.zero; 
                rb.gravityScale = 0;

            }```
verbal dome
magic panther
fossil tree
#

the objet is not here so my raycast dont detect it why he continue grabbing

normal rose
fossil tree
#

oh wait i think i know

normal rose
#

do i modify the code

#

or the package manager

languid spire
steep rose
#

They do, I'm not sure in middle school though 🤔

fossil tree
#

that work !

warm rock
#

what do I do

verbal dome
languid spire
steep rose
#

I dont keep track of all the age groups and where they apply in the school districts

languid spire
warm rock
#

!code

eternal falconBOT
warm rock
#

most of it is useless

steep rose
languid spire
warm rock
#

i changed it again to this

#
{
    TogglePause();
}```
```void TogglePause()
{
    Paused = !Paused;
    PauseMenu.SetActive(Paused);
    enabled = !Paused;
}```
#

is that better? but it doesnt work

languid spire
#

setting enabled to false is a problem, it means the code wont run anymore

warm rock
#

oh

#

i will undo everything to the first phase

languid spire
#

no, just remove that line, the rest is fine

warm rock
#

ok

steep rose
#

Do you have version control?

warm rock
#

idk what that is

#

but give me 30min i will go eat and come back

thorny basalt
willow scroll
cosmic dagger
steep rose
#

Nah I did that for my project and almost lost everything lol

#

I always ask people that to see if they want to set it up

cosmic dagger
#

I must admit it: I have it, but I am terrible at using it/keeping up with it. It's definitely smth I need to do constantly. My commits are stories at this point . . .

#

Speaking of, it has been a few months since my last one . . .

steep rose
#

That's a blunder on your part

#

I scared commit

thorny basalt
#

Who needs commits when you can put your project in a zip folder and upload it to one drive. 😎

cosmic dagger
#

Oh, definitely; it's all on me. I'm too inconsistent when I sit down to work on anything, so I don't really do much to have a commit, and it slowly adds up over time . . .

thorny basalt
#

I used to do that when I was new to Unity lol.

#

Wasn’t a good idea. Took 3 hours to zip the project

steep rose
#

Insanity

warm rock
languid spire
warm rock
steep rose
#

Look up what Git is and what version control is

#

Or just look at a brackeys tutorial

#

On Git with Github version control

warm rock
#

is that supposed to be smth good?

#

what does it even do

steep rose
#

It tells you immediately what its about

warm rock
#

ok but i still cant fix the problem

steep rose
#

Did you follow what steve said correctly?

warm rock
#
{
   if (Input.GetKeyDown("escape"))
    {
        TogglePause();
    }
}
void TogglePause()
{
    Paused = !Paused;
    PauseMenu.SetActive(Paused);
    playerMovementScript.enabled = !Paused;
}```
#

i think thats what he said to do

#

idk if its correct or no

verbal dome
#

Looks ok to me. In what way does it not work though?

#

Have you confirmed that TogglePause even gets called?

warm rock
#

when i press Esc it pauses the game

#

when i press it again, it doesnt continue or make the player move

warm rock
verbal dome
#

Are you disabling the object that has this script?

warm rock
#

ye

#

wait no

verbal dome
#

Because Update wont run on disabled objects

warm rock
#

oh

#

i was disabling the movement script on the player (and the script to pause was on the player)

#

Ok i will make an object for pausing

verbal dome
#

This kinda stuff is usually kept in a game manager sort of script, not on the player

steep rose
warm rock
#

ok, i thought its the player cuz player is the one that pauses but i didnt know update wont be running when disabled

warm rock
steep rose
warm rock
#

thats why, i was disabling the movement script inside the movement script

verbal dome
steep rose
#

Well that's why

warm rock
#

i remember when i did a loop inside a loop 1 year ago

steep rose
#

Make a game manager script and do that there

steep rose
#

Make sure to reference everything you need

warm rock
#

ok

#

ty

#

does anyone know how to open 2 Inspectors to reference a script inside another script in 2 different objects

verbal dome
#

Also you can right click an object -> Properties
It will open an inspector in a new window

warm rock
#

ty

#

Yay it works

#

Ty all (I was annoying sorry)

fossil tree
#

wtf

#

i just restart my unity that propose me to update something and now i have code error anywhere

#

cant use tmpro or anything like that please help

rich adder
#

close vscode, click regen project files in unity external tools

fossil tree
#

tysm that work

thorny basalt
steep rose
#

im glad you dont

ionic zephyr
#

Hi, could somebody help me with Binary Space partition?

#

I want to tweak my algorythm to create a fixed central zone that can´t be changed by the algorythm

#

but the surrounding areas can

#

Im using a Bounds Int Space to Split, is it possible to make a "hole" in this space which represents the central area?

brave compass
ionic zephyr
slender cargo
#

Hello. I've been doing some research and I'm struggling to find any good recourses. Is there a way to pull step data from smart watches to unity? How easy is it to test unity apps on an Iphone & apple watch?

#

I see that apple has their HealthKit API.

brave compass
slender cargo
ionic zephyr
brave compass
final kestrel
#

Does the animator have to finish its animation to update its state?

wispy finch
#

No, don't believe so

languid spire
wispy finch
#

At any point during the animation, you can transition between states with conditions or triggers

#

Or wait have I misunderstood the question?

languid spire
#

Or I did

verbal dome
polar acorn
polar acorn
final kestrel
#

I have a door. It has Idle, Open, Closed states. I have 2 triggers which are open and close. On interact with my door i settriger Open or close if it is closed. I try to get the AnimationStateInfo and store it in a bool then print it to console. I had to write it in a coroutine because the bool returns false OnInteract

polar acorn
#

So, if you wanted to check if a transition occurred after setting a value, you would need to wait a frame to make sure it's had time to run

final kestrel
#

All right. Thats why I got confused then. I executed them in the same block it did not get updated correctly and when I waited a second in a coroutine it updated correctly.

polar acorn
#

You wouldn't need to wait a full second. Even just a yield return null would be enough

wispy finch
#

Oh, that's what you ment

final kestrel
wispy finch
mild plank
#

Hi, could anyone help me with cinemachine? I have 3 virtual cameras + main camera, when I switch to the main camera from virtual camera, it like orbits the player when rotated, until player moves, then the camera goes "inside the head", where it is supposed to be. Code for switching:

void SwitchToVirtualCamera(CinemachineVirtualCamera vCam)
    {
        if (activeVirtualCamera != null)
        {
            activeVirtualCamera.gameObject.SetActive(false);
        }

        activeVirtualCamera = vCam;
        activeVirtualCamera.gameObject.SetActive(true);
        isUsingVirtualCamera = true;
        Debug.Log("Switched to Virtual Camera: " + vCam.name);
        //camPosSave = mainCamera.transform.position;
    }

    void SwitchToMainCamera()
    {
        if (activeVirtualCamera != null)
        {
            activeVirtualCamera.gameObject.SetActive(false);
        }
        activeVirtualCamera = null;
        isUsingVirtualCamera = false;
        Debug.Log("Switched to Main Camera");
        //mainCamera.transform.position = camPosSave;
    }

https://streamable.com/udmgy0

wispy finch
#

You mean that initially you had the camera inside the head of your player, and upon switching, its outside and does not keep that position?

#

aha, and then upon movement it goes back, I see

mild plank
#

Well it is under Player in 0, 0.4, 0 and when the player moves it goes back

wispy finch
#

Right, what scripts affects the camera position?

mild plank
#

because the camera bobbing is caused by walking, and the camera moves after walking, so its caused by the camera bobbing

#

but other cameras move correctly automatically

wispy finch
#

In the hierarchy, you dont seem to have a gameobject holding the correct camera position, or do you?

#

And yes, sounds reasonable

wispy finch
#

This might just be a setting inside the virtual camera

mild plank
#

sorry kind of a beginner in here

wispy finch
#

Just good practice

mild plank
#

So I should try to do a "Main camera holder" ?

wispy finch
#

I'll take a look in the engine, meanwhile someone else might have an idea

#

Shouldn't change anything here, was just wondering

mild plank
#

okay

wispy finch
#

I mean, a work-around would be:

  • Create a camera holder, this will just be a gameobject (as a child) on your player character, where you want the camera position to be
  • Once the virtual camera becomes active again, reset the position of it

This should make this issue resolved for the time being, until you can resolve it properly

mild plank
#

but the brain should smoothy switch right?

#

on its own

wispy finch
#

it will work the same as before, but since the bobbing updates the camera position, I belive that the "standard" position of your camera would be in front of the player's head

#

you can try to remove the bobbing part of your virtual camera, and I bet you will see the cameras location ahead of the player

mild plank
#

I removed everything that moves with the camera and found out that after switching back to the main camera, the camera is at the same position as the virtual camera before, not the correct place (in player)

#

@wispy finch should I have a main camera as well as another virtual camera?

#

so it knows where to go back-

wispy finch
#

When you removed "everything", the virtual camera is in front of the player's head? If so, it is as expected

mild plank
wispy finch
#

You could use several cameras, that's up to you. Just understand that either you correct the position inside the virtual cinemachine camera, or you reset the position upon switching as said before.

I recommend making a camera holder - also as explained before - or you simply correct the position in the cinemachine, so that the bobbing of the player's head does not offset the position drastically.

mild plank
#

Okay, thanks for the tips!

wispy finch
#

No worries, best of luck

sudden pilot
#

guys ı have some dash mechanic

#

but player when touch any buıldıng that happens

#

how can ı fix

verbal dome
#

You are using a rigidbody2D or no?

#

Moving a rigidbody via the transform is not correct, it will lead to glitchy collisions and such

#

Move it with rigidbody instead. AddForce/velocity/MovePosition

sudden pilot
#

but thıs ıs for dash

#

thıs need 2 locatıon and go to other locatıon

#

when ı look ınsıde the wall collider and dash there This choosenTransform wıll be ınsıde the wall

#

and player all tıme tryıng to go in wall

#

ı used stopcoroutıne or return break for stop thıs dash when goıng ınsıde the wall but dıdnt work

verbal dome
#

Oh and better use yield return new WaitForFixedUpdate() instead, since you are dealing with physics here

#

Might need to change Time.deltaTime to Time.fixedDeltaTime, but not sure

sudden pilot
#

but they wıll never fix

#

because problem is

#

one sec

summer stump
sudden pilot
#

@verbal dome

#

player tryıng to go red poınt

summer stump
#

Teleporting (using transform.position) will cause issues of course

sudden pilot
#

but ıt ıs ınsıde the wall

#

and always while loop active

#

that ıs why never over

#

this is the problem

summer stump
sudden pilot
#

my englısh not very well

#

that ıs why

summer stump
#

But yeah, everything osmal said will fix that issue

sudden pilot
verbal dome
summer stump
sudden pilot
verbal dome
#

Like storing the started coroutine in a Coroutine variable and then using StopCoroutine to cancel it when you collide

summer stump
sudden pilot
verbal dome
sudden pilot
summer stump
summer stump
verbal dome
sudden pilot
#

ı wıll try agaın

verbal dome
#

^That, except instance would need to be a private variable in the class

sudden pilot
#

@verbal dome should this work?

#

this is the wall's tag

#

when ıt touch the wall thıs should happen

#

but still ın unıty same error

verbal dome
#

StartCoroutine returns a Coroutine that you should store in a variable

#

Then call StopCoroutine(myCoroutineVariable) when you need to

wispy finch
#

I strongly recommend using RigidBody2D here, as well as reading up on FixedUpdate() and Update()

#

Oh you are using it, but why then use the transform to move the character?

wispy finch
sudden pilot
verbal dome
wispy finch
mild plank
#

@wispy finch Fixed it! Now, last question, how do I do culling mask? Because it seems I can see everything even if I have set in culling mask to not see player body

#

the virtual cameras dont have any option for that

wispy finch
mild plank
#

I didnt move with them since I created this project

#

so they are all correct

summer stump
sudden pilot
sudden pilot
summer stump
#

StartCoroutine returns a reference to the coroutine

You make a variable on the left, do an = sign, then startcoroutine

Pass that variable into StopCoroutine

#

It will never work with SpeedBuff()

StopCoroutine(SpeedBuff()) is incorrect

wispy finch
sudden pilot
#

oh so ıt ıs not correct okay

summer stump
#

Does that make more sense? My first example code was more like pseudocode

sudden pilot
#

like " Coroutine "

summer stump
#

Use Coroutine, not anything else

#

I mean, you can save it as an IEnumerator iirc. But Coroutine is gonna be simpler

sudden pilot
pastel mesa
#

guys I'm new to unity

#

i made 3 projects but none of them load

wispy finch
sudden pilot
summer stump
pastel mesa
#

when i click it it says project failed to open

slender nymph
sudden pilot
summer stump
wispy finch
sudden pilot
summer stump
summer stump
#

No, that is right! Good work

sudden pilot
#

but stıll unıty does same bug xd

#

wait let me check agaın

woven crater
#

why sphere cast at position need ray that have direction?

sudden pilot
verbal dome
#

If you don't need a cast then try OverlapSphere or CheckSphere

vocal wharf
#

can someone show me why my player is falling upwards? When I click play it's fine but whenever I walk off a ledge it falls upwards indefinitely

sudden pilot
#

@summer stump maybe while loop is never stop with stopcoroutine

verbal dome
sudden pilot
#

player stucks ın wall

verbal dome
#

Are you calling StopCoroutine from OnCollisionEnter?

#

That was the idea, anyway

sudden pilot
#

ı am doing that yes

#

ı was already did that

#

maybe ı dıdnt undurstand because my englısh not well

verbal dome
#

Send your whole script !code

eternal falconBOT
sudden pilot
verbal dome
#

Press save 💾 , copy the URL link, paste it here

round mirage
sudden pilot
vocal wharf
verbal dome
sudden pilot
verbal dome
#

Should probably check if the coroutine is null or not, before calling StopCoroutine. Not sure if unity will throw an error if you try to stop a null coroutine

final kestrel
#

How can I set the state of my animation in script without triggering the actual animation? What method do i use if it exists.

wispy finch
#

Set the state?

#

You can store the Animator and apply "SetTrigger()", "SetBool()" and such, to transition between states

wispy finch
#

if that's what you ment

final kestrel
# wispy finch Set the state?

I do not want to see the animation play though. For example I have this door and I want to set its state to open or close without seeing the door actually opening and closing.

wispy finch
#

ah, you mean literally "setting the state"

final kestrel
sudden pilot
#

@verbal dome ıt worked but when ı so close to wall and press shift lıke 3-4 tımes ıt was happenıng agaın and ı put there 2 collider and problem fixed xd

sudden pilot
vocal wharf
#

why's it not working

vocal wharf
wispy finch
#

Please paste code as it should. !code

eternal falconBOT
vocal wharf
#

it's not workinng

sudden pilot
sudden pilot
vocal wharf
#

not really new but kind of a beginner ye

sudden pilot
final kestrel
vocal wharf
#

everyone is ignoring my question

sudden pilot
sudden pilot
wispy finch
vocal wharf
#

can someone show me why my player is falling upwards? When I click play it's fine but whenever I walk off a ledge it falls upwards indefinitely
'''cs
public class PlayerMovement : MonoBehaviour
{
public Rigidbody rb;
float speed;
public float sprintSpeed = 5f;
public float walkSpeed = 1f;
bool isSprinting;
void Update()
{
float horizontal = Input.GetAxisRaw("Horizontal");
float vertical = Input.GetAxisRaw("Vertical");
Vector3 moveDir = new Vector3(horizontal, rb.velocity.y, vertical).normalized;
rb.velocity = moveDir * 100 * speed * Time.deltaTime;
if (Input.GetKeyDown(KeyCode.F))
{
isSprinting = true;
}
if (Input.GetKeyUp(KeyCode.F))
{
isSprinting = false;
}
if (isSprinting == true)
{
speed = sprintSpeed;
}
if (isSprinting == false)
{
speed = walkSpeed;
}
}
}
'''

final kestrel
vocal wharf
#

why is it not working dude