#💻┃code-beginner

1 messages · Page 758 of 1

cosmic dagger
#

a trigger is an area mainly used as a detection zone that persistently checks objects entering, staying, or exiting . . .

scarlet pasture
#

so gifs are not allowed

#

thanks bro didnt know that

languid pagoda
#
    private void BuildMap(string outPath)
    {
        Debug.Log($"IsValid={Steamworks.SteamClient.IsValid}, IsLoggedOn={Steamworks.SteamClient.IsLoggedOn}");


        Debug.Log(outPath);

        if (Directory.Exists(outPath) == false)
            Directory.CreateDirectory(outPath);

        ModToolUtility.BuildAssignedBundlesFor(mapAsset.mapScenes, outPath, BuildTarget.StandaloneWindows64,
            BuildAssetBundleOptions.UncompressedAssetBundle | BuildAssetBundleOptions.AssetBundleStripUnityVersion | BuildAssetBundleOptions.ForceRebuildAssetBundle);

        var json = JsonConvert.SerializeObject(mapAsset.mapBundlePaths, Formatting.Indented);
        Debug.Log(json);
        File.WriteAllText(outPath + "/mapmanifest.json", json);


        Debug.Log("Created map manifest");
    }

why am I getting this error? Doesn't matter if folder exists already or not it throws that error until I press cancel then it builds the asset bundle anyways??

sour fulcrum
#

iirc this relates to having scene files assigned to assetbundles that have non-scene content?

#

if that maybe helps

agile walrus
#

Hello. I'm from Brazil and I'm still a programming beginner. I have to develop a rhythm system for a project. Does anyone have any tutorial suggestions?

wintry quarry
agile walrus
visual ginkgo
#

hii guys, i have a question. is there a way to speed up unity compiling after script changes? it takes seconds and seconds even if i change a single number in my script hahahah

#

maybe some way to compile at the same time i make changes or idkkkkk D::

teal viper
visual ginkgo
teal viper
#

If automatic compilation in the middle of script changes hinders your development speed, then yes.

rich adder
visual ginkgo
#

thank u guys, appreciate it ❤️

rich adder
#

sad reality of old backend, they're supposed to be merging to new core clr so hopefully that happens compile will be much faster

visual ginkgo
#

i know there'a a "tool" called "hot speed reload" or something like this

#

but idk if it's worth

rich adder
#

hot reload ? don't know much about it but seen mixed feelings on it

teal viper
paper delta
#

never joining a C# server again

#

they telling me to just do it💔

winged ridge
#

Sure that wasn't nike

winged ridge
deft nymph
paper delta
deft nymph
fast relic
paper delta
fast relic
#

i can't know what they are if you don't say the words

#

you can ask about those words or keep not understanding them, which would you rather

winged ridge
#

!learn

radiant voidBOT
winged ridge
#

I'll find a link for you

paper delta
#

ty

winged ridge
green snow
#

hey I'm trying out the navmesh system and I'm having a problem with the enemy starting halfway inside the surface area

winged ridge
#

Is the nav mesh agents property set up right, if you have a capsule and it's a child object you raised 1 unity unit up, and the agent component on the main parent object it will make the capsule go down by 1 unit

green snow
#

my enemy hierarchy is a GO with just a transform and navmesh agent with 2 children, 1 for eyes and 1 for the body and they both have a capsule collider and mesh

green snow
winged ridge
#

I mean I'd put your colliders onto the enemy as well as the agent as opposed to body

#

And set it properly, the eyes wouldn't want to have colliders unless they are physics objects

green snow
#

awesome thanks

#

works

#

I thought I could have a parent GO just for the navmesh agent and the script that I could attach to with children that contains the colliders, etc.

winged ridge
#

In general parent passes down to a child.. scripts go onto parent and on the rare occasions a child needs a script it should be able to be called from the parent too

green snow
#

oh so I'd just get the navmesh agent from the child in the parent script?

winged ridge
#

If you need it yes

#

GetComponentInChildren<>() etc

elder canyon
#

Nice, I did this few weeks back.

#

Same DFS based maze generation

maiden drum
#

For a 2d pickup system. What's the better approach?

  • a 2d criclecast and then iterate over the pickables
  • Registering/unregistering via ontriggerenter then iterating over the items
#

I'm expecting my pickup range to be modified via buffs

tired python
shadow field
#

Hey I'm making a local mulitplayer game, I wanna add a Lobby in which the players can already spawn.
Those players are stored in a static List. When changing to the next Scene a game initator is looking through this static List and is supposed to spawn all player gameObjects in the List.
The problem is that the gameObjects are getting destroyed when loading the next Scene. Does somebody know how I could prevent this or has another take on spawning players in a new scene.
I want to spawn the same gameObject because I think I dont have to handle any things like, which controller is connected to which Player because thats handeld by the Player Input Manager.

tired python
#

i want to play this audio called thruster when the user presses his left mouse button and to stop when he releases it. i know that i am supposed to get the audio loop set to true, but i don't know what to do to access it...

shadow field
#

you cant loop audioClips, only the audio source has a loop setting you can set to true, now you have to load the audio clip into the audioManger and play it now

tired python
#

also, audioManager is an instance of the class Audio

tired python
#

or should i create another moethod inside the Audio class to set loop = true?

sour fulcrum
tired python
shadow field
#

no i think its just rather audioManger.SFXSource.loop = true; instated of audioManager.thruster.loop = true;

earnest meteor
#

i have a problem

sour fulcrum
#

like if an enemy has a component that handles audio, that is more of a "controller"

but if this was a class that is only meant to exist as 1 instance only, that is more of a "manager"

earnest meteor
#

if i try installing unity

#

then it just doesn't work

sour fulcrum
shadow field
#

sure

tired python
earnest meteor
#

i get an error on the last asset I try installing

shadow field
#

thats what im trying to say, you can only enable a loop on a audio Source and not a audio clip

tired python
shadow field
#

the audio clips are just "used" in the audio sources

shadow field
earnest meteor
#

look this is rlly anoing and I tried fixing by switching the location

earnest meteor
sour fulcrum
tired python
#

wait, then how the hell do i manage two diff SFX, one of which i wanna loop and the other which i don't wanna loop?

earnest meteor
#

i try making a vr game but the first step that is hard to fail, I fail at!! AND IT'S ALWAYS MEEEE notlikethis

rugged beacon
shadow field
sour fulcrum
earnest meteor
#

can anyone just help

tired python
#

it would be so much easier if we could set an audioclip to loop....

sour fulcrum
#

that would not help you

tired python
#

why not

earnest meteor
#

ok so look at the latest img i sent in this channel

sour fulcrum
#

imagine this is your audio source

this is 1 AudioSource/Speaker

then you put 1 AudioClip/Cassette into the AudioSource to play it.

you can play the song once, on repeat etc. but if you want to put another AudioClip/Cassette in, you'd have to take the current one out

except with playoneshot, but that is not compatible with looping

rugged beacon
#

you can also do audioclip.length then play it again after that length also

earnest meteor
#

pls HELP MEEEEEEEEE

sour fulcrum
#

What sounds are you trying to play right now? Some context might help

earnest meteor
#

I CANT INSTALL UNITY PLAYER

shadow field
#

or you could implent a boolean in your PlaySFX Method, one that would enable loop, or disable it

shadow field
#

if you gonna cry like that nobody gonna help you

tired python
sour fulcrum
#

Thrusters on?

tired python
sour fulcrum
#

as in

tired python
#

spaceship

sour fulcrum
#

ok cool, and you play as the spaceship right

sour fulcrum
shadow field
balmy pelican
earnest meteor
#

yes

balmy pelican
tired python
sour fulcrum
# tired python https://paste.mod.gg/xnulsxreemel/0

Thank you, gonna give you some more general advice that isn't the fastest/most direct way to solve your problem but might help you understand how to do this abit better in the long run

so first of all, your Audio class has some shared responsibilities, it's meant to play some stuff for your player but also it's got stuff like the music for the game. Personally I think it's better to separate this kind of thing as it's important to consider which part of your code should "own" something.

eg. make
AudioManager (or even in a/the GameManager)
-Exists in the scene a single time
-Is basically "god" and is responsible for the "global" audio (eg. music)

then honestly put the audio stuff related to the Player/Ship in Player directly, separate from the AudioManager

then from there, like what we've suggested previously have an AudioSource per type of sound so they can be configured for different purposes. if your game is simple that might just mean an audiosource per audioclip

#

if that is confusing let me know and/or feel free to ignore for now 😄

tired python
#

let me know if i am wrong. what you are saying is for me to make a class called AudioManager which doesn't really have any members which are audioclips. Ideally i would wanna have the audioclips present in the player controller script and access AudioManager to play clips the way i want to using it's methods?

earnest meteor
sour fulcrum
#

you could potentially do what your describing if you want more control in that regard later down the line though absolutely

#

but im more so pointing out how stuff will be abit easier to manage when each part of your game "owns"/controls that part of the game specifically

tired python
#

and this is where i say that i kinda understand the theory part but i don't know how it's even applicable. Once this game is over, and i start my next one, i am gonna have to refer to it....

tired python
sour fulcrum
#

Another example of this is in your Player class right now, your managing the games high score and scene reloading. Should the Player be responsible for the games high score and scene reloading?

balmy pelican
#

Are you using this video as a reference? I really like this one. https://www.youtube.com/watch?v=N8whM1GjH4w&t=48s

In this Unity 2D Tutorial we'll learn How to add MUSIC and SOUND EFFECTS to a Game.
In this Audio Manager Tutorial we'll add background music and various sound effects to our 2D Platformer game. We'll Create very simple Audio Manager C# Script to control music and SFX.

Enjoy the video ☕

——————————————————...

▶ Play video
sour fulcrum
#

the player being responsible for moving around, activating it's booster mechanic, reacting to incoming collisions etc. all makes sense for the Player/Ship to be in charge of

tired python
shadow field
#

helps sometime

earnest meteor
#

ok i will try ty

#

tysm bro

balmy pelican
tired python
#

thx for the info but i wont be making any 3d games, my pc wont be able to handle it xD

sour fulcrum
balmy pelican
#

It's a global audio manager that plays oneshots of sound clips. The audio manager is referenced in scripts and a function is called that plays the oneshot.

sour fulcrum
#

that isn't correlated with 2d vs 3d

balmy pelican
#

it is, as the audio manager is always expected to be 2d (mono) since it's global

earnest meteor
#

My unity wasn’t installing because I had it installed on two discs the C and D and the C was completely full and I had it installing on C so I had to uninstall it on drive C. Now its installing on D

balmy pelican
#

The sound itself is played from the audio manager, it doesn't change position. That's why it can't be played in a 3d space if you're looking for stereo sounds.

earnest meteor
tired python
tired python
earnest meteor
#

Owwww you are so smart how didnt i know

earnest meteor
#

I guess I’ll be uninstalling the temporary files then

paper delta
#

alright

#

people have been leading me to wrong places

#

ima just learn from vids and w3s

#

for scripting

#

final

shadow field
#

👍

earnest meteor
#

I didn’t wanna wait so I just already deleted the files, so yeah

#

Now let’s see how many disc space I have I just got one gig for yes sir

#

Oh never mind there’s an update

shadow field
#

yes does count

#

but you can never be sure if its gonna be the fix

earnest meteor
shadow field
#

oh i can smell that you wanna make game dev videos xD

#

its windows, get used to it

earnest meteor
#

Me?

shadow field
#

from the amount of videos you are already posting, yeah

earnest meteor
#

Oh but not wrong i have a yt channel at 1k rn

shadow field
#

no offense

fast relic
earnest meteor
shadow field
#

oh nah not anytime soon

earnest meteor
shadow field
#

might be an advantage

earnest meteor
#

I am autistic ahh fuh so

naive pawn
#

uh this is the unity server

#

please try to keep it on-topic

earnest meteor
#

Ok sry

#

I will

shadow field
#

you are a unity autist right

earnest meteor
naive pawn
#

there isn't an off-topic channel here

hot wadi
#

How do u know I have autism

fickle plume
#

There's no off-topic here

earnest meteor
#

Oh noo

shadow field
#

gg

naive pawn
#

yeah the server is kinda focused on unity help/discussion

fickle plume
#

@earnest meteor Also this is a coding channel, if you have general questions use #💻┃unity-talk next time

paper delta
#

i love w3s😭

spice shoal
#

I'm super confused on why my bean is floating up, I was reading up on some stuff and I think its something to do with flattening the camera's forward vector, and normalizing it but i have no clue what I need to do for that

keen dew
#

The movement script needs to be on the capsule, not the camera

spice shoal
#

dang i did not see that

#

now he just flops around notlikethis

naive pawn
#

if it's with an RB, make sure you've locked X and Z rotation

radiant voidBOT
spice shoal
#

now its not seeing the rb

fast relic
#

so if the camera points up you're gonna move up

naive pawn
spice shoal
spice shoal
fast relic
#

set it to 0

#

(not on the actual camera, just a copy of the vector)

#

and then normalize it so you still move at the same speed

keen dew
#

The issue was already solved by using the correct object to determine the direction. None of that is necessary anymore

naive pawn
#

make sure you're rotating the right things

fast relic
#

well yeah of course, if you make it so you can rotate the player around the x axis it's gonna rotate around that axis

naive pawn
#

generally, the camera should be a child of the rigidbody, and the camera only pivots up and down, while the rigidbody can rotate left/right

#

also, configure your IDE if you haven't. it's a requirement to get help here

fast relic
#

idk about a requirement but it's definitely a good thing to do either way

keen dew
fast relic
naive pawn
keen dew
#

If you're following a tutorial, set it up the same way as it is in the tutorial

spice shoal
#

I'm mixing a bunch of code and getting bits i need from tutorials

keen dew
#

If you're not following a tutorial exactly then you should at least make it clear to yourself what each part does. The keyboard movement should move the entire player (the capsule), looking up and down should move the camera, and looking left and right should rotate the capsule

spice shoal
naive pawn
#

have you configured it?

spice shoal
#

im trying to figure it out

#

im confused on what its wanting me to do...

#

bc i have it installed and everything it highlights errors but idk

naive pawn
#

what do you mean by "it" here

#

we aren't over your shoulder, man

spice shoal
#

lol im just a bit confused

naive pawn
#

we have no idea what step you're on

chrome apex
#

Why can I not rotate my head bone via transform even if I masked it out with a layer mask?

naive pawn
#

layermasks don't inhibit movement

spice shoal
chrome apex
tender mirage
#

Curious, question about the unity tilemap if anyone is familiar with it. is streaming enabled for it by default? i feel like it is, since i loaded a massive amount of tiles using bounds and the game performed just fine.

naive pawn
fading spade
#

are patterns beginner coding concepts

naive pawn
naive pawn
spice shoal
naive pawn
#

that links to the same page

naive pawn
fading spade
#

i'm bit dumb so i'm considering MVC pretty beginner level

#

rn I am making a gui manager and scene manager interface that gets implemented to pass stuff between the two. This is what i have but it just feels like a fancier type checking.

fast relic
#

-# i mean aren't most programming patterns just fancier type checking

fading spade
#

-# they run command of implementations without knowing the type, just an overarching interface 🤓 🤓 🤓

fast relic
#

yeah, that's usually a good practice

#

something something solid

fading spade
#

yeah, which i got half of it down, not checking what type of scene it is.

#

but the other half

#

idk if there's a way to do away with hiding what type of data is being passed.

fast relic
#

you could also pass interfaces or abstract classes in there if you're feeling very fancy

calm hare
#

Hey guys im trying to figure out which game engine to stick to, tried godot,roblox,unity and unreal engine, im trying to start out with a 2d game, what do yall recommend i pick

#

Im also not good at scripting

spice shoal
#

UnityChanThumbsUp configured

sour fulcrum
#

your gonna have to get some experience scripting

fading spade
fast relic
fast relic
calm hare
#

I want unity because i just feel used to it

fast relic
calm hare
fast relic
#

well.. yeah sorta?

calm hare
fading spade
fast relic
#

but i started actually seriously learning programming/gamedev around summer of 2024 iirc

calm hare
naive pawn
fast relic
calm hare
fast relic
naive pawn
calm hare
naive pawn
#

it can take 2 different people 2 weeks or 5 years to reach the same point

calm hare
#

Alright well

naive pawn
#

and what you learn will be specific to what you want to make as well

calm hare
#

Thats about all i wanted to ask for now

#

See ya thanks

fading spade
#

neither the game you make nor half of the skills you use.
it's also a bit limited

fast relic
#

tbh, from my experience, a lot of skills in terms of coding transfer between (even seemingly completely different) languages and engines

naive pawn
#

definitely

#

(in general) there's 3 major parts to programming:

  • Language - The syntax, structure, and paradigm of each language
  • Library - The interfaces and utilities that each environment or toolset provides
  • Logic - The algorithms to do work at runtime

Logic is almost completely transferrable between each language and environment, you just have to learn the specific Language and Library that you're using
Language is also shared quite a bit between languages

of course, learning 1 part at a time is easier than learning everything at once, which is why tools like scratch or code.org are popular as coding courses for beginners, especially kids, because it only focuses on the Logic aspect

fading spade
#

coding transfers definitely
but effectively using the editor doesn't

naive pawn
fading spade
#

(maybe, i'm not fluent in terminologies)

fading spade
#

and hope it doesn't become a nightmare to upkeep

#

on another note

#

should i give every class monobehaviour
i heard as long as Update methods are not declared, the cost should be insignificant

naive pawn
calm hare
#

Btw

naive pawn
#

not all classes need to be components

naive pawn
calm hare
#

Is it better if i just watch tutorials, try to make a game and watch relevant tutorials as i go

runic lance
#

and if it absolutely needs to care, then the caller should be provided as parameter

naive pawn
fading spade
fast relic
naive pawn
fast relic
#

i see way too many people blindly follow tutorials and then be unable to do anything on their own

fading spade
runic lance
# fading spade

so in this case Building needs to implement handleTypeA even though it has nothing to do with it?

#

this handleTypeX approach also looks a bit weird, when working with OOP you expect to have this kind of thing abstracted
I can't think of many similarities between "building" and "sailing", what do they have in common?

#

I think the root of the issue here is mixing data with implementation
if you consider that the instances always have their data set up, what other interface methods are left?

chrome apex
#

Stupid question: If I use a dynamic rigidbody and move it with movePosition and rotate with moveRotation but set its drag and angular drag to Inf, does it basically act like a character controller? I.e. simple controller but reacts to collisions

fast relic
chrome apex
fading spade
fading spade
naive pawn
fading spade
#

the other strat would be to pass a delegate from building / sailing to the ui manager for the scene

#

i think

#

but that sounds cursed and doesn’t really resolve the type issue

chrome apex
fading spade
#

unless i keep the delegate in a dictionary
which sounds even more cursed

chrome apex
#

impossible with char controller

naive pawn
#

you can use angularVelocity or AddTorque for that

#

angularVelocity would have similar logic flow/behaviour to MoveRotation, so sounds like you want that

chrome apex
naive pawn
#

so why have them at infinity

#

you can set angularVelocity to 0 yourself if you want it to stop rotating at some point

chrome apex
naive pawn
#

that seems like a separate issue

#

make sure you have constraints where appropriate, and make sure you aren't touching transform which would cause desyncs and unpredictable behaviour

#

also make sure your values aren't wildly high - might happen if you put in deltaTime where it's not supposed to go, for example

chrome apex
naive pawn
#

rigidbodies work for a lot of cases, so im inclined to believe it's something to do with your setup rather than an inherent issue of rbs

#

make sure you aren't doing AddX/MoveX in Update, as well

runic lance
fading spade
#

yeah that seems off

runic lance
chrome apex
naive pawn
#

if you're turning in said tunnels, are you sure the colliders actually fit through the turn

chrome apex
naive pawn
#

...you expect the rigidbody to be able to turn even when it doesn't fit?

chrome apex
naive pawn
#

and what were you using to move in that instance?

#

(as in, what method)

chrome apex
#

when I tried? I can't remember honestly, I've tried multiple things like addForce, addVelocity, MovePosition etc

#

and for rotation too

#

currently I'm using a char controller but now I need to fix that cause it can't do what I want

naive pawn
#

so have you tried the setup ive been describing

chrome apex
#

what? I think I added the forces in fixedUpdate, isn't that what you're supposed to do?

naive pawn
#

yeah, that's correct - i'm referring more so to using velocity

#

to recap:

  • no charactercontroller, only the dynamic rb
  • normal or 0 drag
  • movement using assigning to linear/angularVelocity, and setting them to 0 when you don't want to move
  • appropriate rotation constraints on rb (X+Z, it sounds like?)
#

make sure the velocity doesn't compound as well

chrome apex
naive pawn
#

you want the RB to roll around too?

chrome apex
#

I can't remember what setups I tried honestly. I don't think I set velocity to 0 when not moving tho

chrome apex
naive pawn
#

have you considered like, just rolling the camera rather than the rb for that

#

but sure

chrome apex
#

I would need to roll the collider too

naive pawn
#

isn't it a capsule

chrome apex
#

the purpose being to twist the body if it can't fit while fully horizontal

naive pawn
#

it's radially symmetric, no?

chrome apex
#

No, I would actually make it rectangular

#

or however you call that in 3d

naive pawn
#

ah, mb. i mustve gotten mixed up from the character controller discussion

chrome apex
#

no, I actually meentioned a horizontal capsule but that was wrong. THat was what I was trying to get from a CC, but anyway a rectangular one would work better

naive pawn
#

i'd recommend constraining X/Z rotation for now just to reduce variables though

chrome apex
#

it would go from shoulder to shoulder, thin on the height and down to the belly or something

#

Wouldn't it be simpler to tell rigidbodies to fuck off? I Could detect collision while rotating but I don't really know how to do that as it would need to detect in an arc, rather than a straight line

naive pawn
#

collisions don't really care whether they're from rotation or movement

fossil swift
#

hey, is there any command that replaced "LookAt"?

#

LookAt(Vector3.zero);

naive pawn
#

no

#

it wasn't changed

chrome apex
naive pawn
chrome apex
#

could I not instead use trigger enter and then I wouldn't care about all that stuff

naive pawn
#

i don't see how that would solve anything

chrome apex
naive pawn
#

turn transform + trigger enter just doesn't really make sense

#

you shouldn't touch transform at all when you have rigidbodies. that can cause physics desync

chrome apex
naive pawn
#

dynamic rigidbodies are what drive the physics engine
no rigidbodies means no collision/trigger detection

chrome apex
#

but still, I don't think I would have problems with transform rotation there

dense sierra
#

Hi, I'm new to unity programming. I'm trying to make a simple first person movable character, but there is an issue. For some reason, I'm not sure why, the camera only moves on the X axis and not both X and Y. But if I select another camera, It only shows the Y access. Why is that?

keen dew
#

Show how the objects are related in the hierarchy

naive pawn
#

it could manifest as inconsistencies or perf issues

#

the transform would not be rotating, it'd be teleporting in the eyes of the physics system

#

no interpolatation or continuous collision detection

chrome apex
#

it that the gist of it?

#

also, what about checking for overlaps?

naive pawn
#

interpolation is for checking between steps

chrome apex
#

I see

#

well, that sounds like minor precision issues to me

naive pawn
#

man, what can i do to convince you that the physics system is just not meant to be working with modified transforms

dense sierra
chrome apex
naive pawn
#

all the same issues.

#

to be blunt, you have 2 options. you can use the existing physics system or you can rebuild your own. you can't mix them

keen dew
# dense sierra I'm I missing something?

Well everything is just flat with no hierarchy there. The idea is that the camera should be a child of the player model so that when the model rotates on the Y axis the camera rotates with it

naive pawn
#

charactercontroller effectively builds its own, for example

chrome apex
#

so what you're saying is I must use physics to rotate a mesh?

naive pawn
#

not what i'm saying, no

#

if you're using physics for other stuff, then you have to use physics for the rotation

keen dew
#

Probably yes

naive pawn
chrome apex
#

so what if I'm not using physics for anything

naive pawn
#

see my previous message

chrome apex
#

ok but what do you mean by that? You mean checking for collisions while using a rigidbody, rather than rotating with torque, or whatever does that naturally?

naive pawn
#

could you rephrase your question? not sure what situation you're referring to

chrome apex
#

when you say I have to do physics checks, you said I essentially need to use a rigidbody and rotate in the appropriate way (not with transform).

Are you going back to saying I need to use physics and torque for rotation, or just that I can detect collisions and rotate in another way, but still with a rigidbody?

naive pawn
#

ah, no, the physics checks im referring to would be stuff like overlap and cast checks

chrome apex
#

yeah, excellent, I was steering towards that

naive pawn
#

you can do all those yourself with no rigidbodies, or you can let the existing engine handle it for you

chrome apex
#

with transform

naive pawn
#

no? that was referring to using the physics engine combined with a rotating transform

chrome apex
#

that's not what I meant in that case

#

I meant rotating via transform and checking for overlaps

naive pawn
#

but without involvement of the physics engine, you'll just have to do the interpolation yourself

naive pawn
chrome apex
#

so, if I'm a big hater of physics. Let's say I slap on a kinematic rb and a collider on my char. Then I check for overlaps only while moving or rotating, that seems legit?

dense sierra
naive pawn
#

(so far it sounds legit, just that it's not quite a complete picture without that detail)

chrome apex
#

overlap the shape of my collider at the exact point of my collider. If it overlaps with the terrain collider, I stop moving or rotating.

To go back or rotate the other way, I'm not quite sure if I would need to bring it back first to stop it from overlapping

#

but that's essentially the plan

naive pawn
#

you'd also have to snap it back to depenetrate

chrome apex
#

yeah, that's what I'm saying

naive pawn
#

make sure to consider cases where you'd phase through collision

chrome apex
naive pawn
#

basically what continuous detection is

#

give me a bit to get back on pc to draw it

chrome apex
naive pawn
#

basically that, but also consider it with rotation and corners

chrome apex
#

imo, I don't need such precision

#

it's a first person game

#

wouldn't be visible anyway

#

I consider it a non-issue

naive pawn
#

it wouldn't be about precision

#

it'd be about consistency regarding timing

chrome apex
#

I don't quite follow but that's ok for now

#

also

#

at first, I considered keeping the char controller for motion and using that special collider for collision checks, but would it then make sense to ditch the char controller now?

#

like, does it do me any good?

naive pawn
#

well, the charactercontroller and the rb previously mentioned, not the collider

#

charactercontroller itself is already a collider, so you could consider using that. not sure it can be horizontal though

chrome apex
#

also it can't turn, which is a problem for me

naive pawn
#

probably not the right choice then

chrome apex
#

I think it has a nice feature where you go diagonally if you hit a wall at an angle which would be nice, but that couldn't happen anyway with my new rectangular collider

#

so I could just code that or something

#

it would be perfect if rigidbodies would work for me but I already went through the trouble of simulating drag and inertia with the speed of movement for my char controller so best not reopen that can of worms

naive pawn
# chrome apex what do you mean

i'm referring to cases like this. if you don't have continuous detection, then whether or not you can phase through the corner would be up to timing and the time step

naive pawn
chrome apex
naive pawn
#

what? no definitely not

chrome apex
#

I meant physics specifically

#

dynamic rigidbody

naive pawn
#

yeah that doesn't change what i said at all

#

why reinvent the wheel

chrome apex
#

precisely because you can't control rigidbodies how you want. I heard it's basically very bad practice to use them in car games, even though it might seem natural to use them

naive pawn
#

sometimes you need something more specific that the physics engine doesn't cover or handle well. in that case you would consider making your own physics engine built with the specific task in mind

maybe this is one of those cases, but honestly with the context you've given it doesn't seem like that to me

chrome apex
#

it shouldn't. It's probably a perfect case for a rigibody in theory, but in practice I want get it to work so idk

naive pawn
chrome apex
#

but at that point why use it?

naive pawn
#

you can prevent things from giving forces

#

you can prevent things from receiving forces from certain things

#

if you want to control every aspect, then maybe you don't actually want physics - and that's fine, you don't need to use an RB for everything

#

but RBs definitely aren't useless

#

if they were, they wouldn't be in the engine

chrome apex
#

so do you agree they are bad practice in racing games?

naive pawn
#

depends on the kind of racing. for something akin to mariokart, yeah probably - the physics there aren't very realistic, you'd want more customization

#

for something hyper-realistic, like racing sims, there's a lot of complexity that would probably benefit from a dedicated system. like, it could work with RBs, but it'd be better with something built with racing in mind

#

for something like trackmania? RBs would probably be fine.

scarlet pasture
#

i also maked sure that the Ground Collider is flat, i mean i also useing a "BoxCollider2D" so its should be in a straight line

#

hey, i use this map currently in my Game. i know that this game maybe took some years so i just wantet do make a Collider2D for every Ground, Wall etc. i know that i can use a Tilemap Collider but i actually want to set every ground by my self for hidden roomst etc etc.. but curently i use a Ground better said a Empty GameObjct with a Collider2D, i stretched it around the whole ground but the Player is falling a liitle bit. I cant really explain what i mean because of my Englisch Skills. For that reason i want to share a Video =>

naive pawn
#

well, check in that location if there's a gap in the collider or something

scarlet pasture
#

okay i will do it, but tbh the collider is still around the whole ground: Hers is also a picture.

chrome apex
#

@naive pawn so I tried checking overlaps for rotation. It kinda works, the only problem being I get jittering when I keep trying to rotate to an unrotateable position.

What I'm doing to saving the rotation of the player every frame, and when an overlap happens, I start checking when there's NO overlap but I also return the player's orientation to the last saved one before the overlap.

naive pawn
#

perhaps check the y position if it's actually falling or if it's an animator issue

hot wadi
#

I swear Discord is taking forever to load a few seconds video

scarlet pasture
#

i hope that the Players Code dont make this problem, i use my costum Gravity and im also Apllying Gravity when the Player is not on "Grounded" better said i apply Gravity when the Raycast is not hitting the Ground

scarlet pasture
#

there is a Website for postiing Videos, they give u a link that u can share here, its 10000 faster than discord

naive pawn
scarlet pasture
#

i actually found the Problem of the Colliders

#

lets gooo

chrome apex
#

Only, it would have a slight delay

#

So, actually trying to prevent it from overlapping in the first place

earnest meteor
#

I NEED HELP _WITH MY VR

#

how do i view my game in vr

fickle plume
#

@earnest meteor This is a code channel, if you need help with code post your problem

mint imp
#

How might i use a custom Polygon collider 2D as the "area" a particle system uses to spawn particles from?
Im dynamically creating shapes with a line renderer, using those points i create a Polygon collider 2d. That i want particles to spawn in

scarlet pasture
#

hey where can i ask my 2d Animation Prblems, the Enemys Animation sudenly change his Position on a few Frames, What channel should i use?

frail hawk
fallen mountain
scarlet pasture
#

Thanks u!

frail hawk
fallen mountain
chrome apex
#

is Collider.cast as difficult for rotation as is sounds?

frail hawk
wintry quarry
fallen mountain
chrome apex
# wintry quarry what do you mean?

I mean, it goes in a straight line for movement, seems easy. But to prevent rotational clipping, it needs some proper math I'm guessing

wintry quarry
chrome apex
wintry quarry
hot wadi
#

Are u talking about Collider2D? 3D colliders don't have cast. There is Raycast. They are different

wintry quarry
#

you'd have to do something like make a secondary physics scene and simulate it moving and rotating in there for however many timesteps you need

wintry quarry
chrome apex
wintry quarry
#

It has not - but 3D has always had Rigidbody.SweepTest

chrome apex
chrome apex
languid pagoda
#

My unity started randomly doing something weird, if I am coding and save the file it will randomly pull unity as a the focused window until its doen rebuilding the script.

Also since this started happening my unity will get stuck at reloading domain randomly, and I have to close with task manager. How can I fix this?

mint imp
#

How might one create a sprite mask from a polygon collider 2d?
Ive read so far i need to convert a sprites shape to fit the collider but ive had no luck

torpid spindle
#

can someone teach me how to make vs code do auto filling for my code

#

auto suggestion thingy

radiant voidBOT
mint imp
rich adder
torpid spindle
#

bless up

#

stupid question

#

sorry mate

scarlet pasture
rich adder
#

You haven't been here long enough

#

they do

scarlet pasture
rich adder
#

but yeah no reason to steer this into offtopic

tender mirage
#

What’s an gameobject.

#

Just kidding

mint imp
# rich adder not sure, wouldn't hurt if you were more specific on your particular issue / use...

So im making "clouds" for my game that are any kind of shape i can draw in editor.
I want the polygon collider 2d of these clouds to act as a sprite mask to show a particle system (Cloud visuals) ONLY within the bounds of clouds.

I have the sprite mask properly showing clouds only within a sprite i select.

but im struggling to "reshape" the sprite to match the polygon collider2d's shape.

chrome apex
mint imp
#

SO i need to either reshape a sprite to fit a polygon collider 2d's shape
Or somehow mask through a collider?

rich adder
rich adder
burnt rampart
#

Anyone know why my classes that inherit from an abstract class seem to be unable to get reference to a singleton,
gameCon = Gamecon.Instance works just fine in my classes that do not inherit.

Here is the abstract class and its awake method

public abstract class EnemyAI : MonoBehaviour
    {
    private ShipObject shipObject;
    private WeaponObject weaponObject;
    [SerializeField] GameCon gameCon;

    private void Awake()
    {
        shipObject = GetComponentInChildren<ShipObject>();
        weaponObject = GetComponentInChildren<WeaponObject>();
        gameCon = GameCon.Instance;
    }
}
sour fulcrum
#

private is default

#

serializefield just explicitly serializes (and shows in inspector as a result), doesn't mean it's public or protected

mint imp
burnt rampart
rich adder
#

this is a code channel

sour fulcrum
#

private is private, inheriting classes can't touch their ancestors privates

#

you might want protected

sour fulcrum
whole dome
#

sorry

torpid spindle
#

is there anyone i can ask basic ass unity questions to lmao

rich adder
chrome apex
torpid spindle
#

id rather talk to someone than rely on a tutorial

radiant voidBOT
# rich adder !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

burnt rampart
sour fulcrum
#

gotta find it for the first time eventually 😄

burnt rampart
#

lol true

torpid spindle
rich adder
#

I mean you should make an attempt to even debug / google things on your own first

#

without knowing how to self-debug / problem solve you will not go very far in development

mint imp
torpid spindle
#

but theres like

#

500 different ways to do it online

rich adder
torpid spindle
#

and its 3 am

short gust
#

some (very old/classic) architectural questions:
with heavy usage of composition - where do "normally" one put a state management logic? like, do I make "a meta component" who orchestrate on decoupled components OR do I make the components with tiny state machines inside them with some "meta state machine" enabling/disabling the components, dunno? I kinda want to try to make a composition as my core structure, but I still don't know HOW/WHERE do I put the state logic itself, not the business logic of "an action gameObject be doing", if I can phrase it like that, lol.

torpid spindle
#

and i want to like

sour fulcrum
#

then your fucked

torpid spindle
#

not do anything

#

urghhhh

thorn holly
rich adder
hot wadi
#

Sleep and pray

torpid spindle
#

just to not know a thing

rich adder
burnt rampart
# sour fulcrum you might want protected

hmm I tried private protected, protected, and even public, it seems the inheritors still can't get the reference but for some reason the fields that are getting reference via GetComponentInChildren<>() are all working fine?

sour fulcrum
#

you'd need to show code

hot wadi
#

Btw its a singleton, u can just call the class directly without caching a reference

sour fulcrum
#

this is also true

limber bolt
#

Talking about movement, ill explain the situation. I'm making a restaurant game, so when you walk to a client and select a table, the client walks to the table you selected. Just like in Dead Plate. But I'm not quite sure how to move my NPCS to the table, Ive watching some videos but it seems that their case isnt exactly similar to mine. So im a little confused of what to do now. Any good advices about moving NPCs from a starting point and changing their path depending on what the player selected would be so nice

burnt rampart
# hot wadi Btw its a singleton, u can just call the class directly without caching a refere...

hmm I tried that, I'm specifically trying to get access to an event in the GameCon singleton, this however gives me an "Object Reference is required for the non-static field, etc, "GameCon.TickEvent"

public class GameCon : MonoBehaviour
{
    [SerializeField] private int Ticks;
    public event EventHandler TickEvent;

    public int getTicks { 
        get{ return Ticks; } 
        private set=>Ticks=value; 
    }

    public static GameCon Instance;
}
public abstract class EnemyAI : MonoBehaviour
    {
    [SerializeField]private ShipObject shipObject;
    private WeaponObject weaponObject;
    [SerializeField] public GameCon _gameCon;

    private void Awake()
    {
        shipObject = GetComponentInChildren<ShipObject>();
        weaponObject = GetComponentInChildren<WeaponObject>();
        _gameCon = GameCon.Instance;
    }

    private void OnEnable()
    {
        GameCon.TickEvent += OnTickUp;
    }
}
sour fulcrum
#

GameCon is a monobehaviour, an instance

#

Instance is a static field in GameCon

#

(youd want GameCon.Instance.TickEvent)

burnt rampart
#

aaaahhh okay, yeah that looks like it works

#

sorry, been a bit since I did this stuff, my memory is half there

rich adder
#

you generally want to access Instance of singleton in Start
since most of the times assignment is done in Awake, you wouldnt want to rely on the order of scripts to hope the accessing awake runs after

prisma crypt
#

I'm very new to this so I hope this is the right place for this. I have my player capsule set up and I set the values to my liking, but when I hit play, they reset. Like "Jump" keeps unticking, movement speed and rotation speed keep resetting to defaults. I don't know why this keeps happening.

rich adder
burnt rampart
#

hmm I'm still getting a nullref using GameCon.Instance.TickEvent += OnTickUp;
no error in editor though

rich adder
scarlet creek
#

any idea why this script isnt working correctly

#

using UnityEngine;

public class MouseMovementScript : MonoBehaviour
{

public float mouseSensitivity = 100f;

float xrotation = 0f;
float yrotation = 0f;

public float bottomClamp = -90f;
public float topClamp = -90f;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
    //locking the cursor to the middle of the screen and making it invisible

    Cursor.lockState = CursorLockMode.Locked;
}

// Update is called once per frame
void Update()
{
    //getting the mouse inputs
    float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
    float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

    // rotation around the x axis (look up and down)
    xrotation -= mouseY;

    // Clamp the rotation
    xrotation = Mathf.Clamp(xrotation, topClamp, bottomClamp);
    
     // Rotation around the y axis (look left and right)
    yrotation += mouseX;

    // Apply the rotation
    transform.localRotation = Quaternion.Euler(xrotation, yrotation, 0f);
}

}

burnt rampart
rich adder
rich adder
#

also 👇

radiant voidBOT
rich adder
#

also you do not want to multiply mouseInput with Time.deltaTime

scarlet creek
#

it just goes all over the place

scarlet creek
#

this is what happens

burnt rampart
#

ok I tried having the object disabled and manually enabling it in the scene after starting, everything is working correctly, so yeah I'm guessing OnEnable() was just coming in before the GameCon script

#

thank you for the help, nav

rich adder
# scarlet creek

well rotating both the x and y on the playerbody would not make much sense
if you remove the x rotation on the localRotation it will probably work better but you still need to rotate the x on the CameraHolder if the goal is a FPS

mint imp
rich adder
#

I'm sure spritemask could probably do it I jus don't know, but with shader should be as simple as doing that

scarlet creek
languid pagoda
#

Everytime I add a script i am getting stuck at this until I end task on the editor just randomly popped up and am not sure whats causing it in the slightest unless this is a side effect of multiplayer play mode?

rich adder
rich adder
languid pagoda
rich adder
languid pagoda
#

oh yeah that didn't fix it any other ideas?

rich adder
#

( a blank scene will be open)

rich adder
#

when did it start happening?

languid pagoda
#

when I started using multiplayer play mode

#

so I guess its because of that

rich adder
#

which version ?
I use 1.3.3 without issues in Unity 6.0.33f

languid pagoda
#

if its not because of that I wouldn't have a clue

#

i commented out the code I have running in ondomainreload

rich adder
#

was about to say.. start disabling stuff and see what happens

scarlet pasture
#

do i need to use two collider? for the legs? and would that not mean that tha player can do 2 times damage?

pine cedar
#

Have you checked editor logs after terminating the editor process to see if that gives any clues on what it was working on?

pine cedar
rich adder
pine cedar
#

1 attack can hit 20 colliders in one enemy

#

But the attack should register if it's hit an enemy or not in it's lifecycle.

naive pawn
scarlet pasture
pine cedar
scarlet pasture
rich adder
pine cedar
#

"Is weak point" on one of the colliders (or first collider) hit within an object = critical hit.

scarlet pasture
rich adder
#

putting a component is easier

scarlet pasture
#

component?

#

whitch component?

rich adder
languid pagoda
scarlet pasture
#

okay so i will add 2 Colliders, but one for the weakpoint, but how can i say "Player dont hit two Collider at one time"?

rich adder
scarlet pasture
#

could i say? "If the Player hits the Enemy Combarrrrring , diesable his "AttackRegisterColliders" for 0.2f Seconds but enable his "Body Collider" that dont receive any Damage?

#

so this Enemy cant fly out of the Map.-

languid pagoda
rich adder
#

I think soo...I know streaming assets doesn't process the file at all, I think plugin does but I'm not 100% on it

rich adder
scarlet pasture
#

wait.

languid pagoda
#

I wonder if this is some kind of undefined behavior in valves native api, this started when I started using MPPM so the server calls SteamServer.Init the client calls SteamClient.Init might not be supported by the library internally and causing some sort of bug

scarlet pasture
#

AI

#

“If the player hits the enemy during combat, disable the enemy’s AttackRegisterColliders for 0.2 seconds, but enable its BodyCollider, which doesn’t receive any damage. This way, the enemy won’t get knocked out of the map.”

#

can i use that to prevent that the Player can hit boht Collider? (CritCollider) (NormalCollider)?

rich adder
rich adder
languid pagoda
#

when I open other instances its seperate processes in task manager

rich adder
#

yes but parrelsync is a bit more mature

languid pagoda
#

ah got ya

#

ill give that a try now

sour fulcrum
#

it's way worse for iteration times but something i picked up from modding stuff is there's a nice third party asset called UnityExplorer that provides serialised inspectors at runtime which i've found handy for debugging my own multiplayer builds

thorn holly
scarlet pasture
thorn holly
#

Keeping the collider active prevents future issues, such as falling off the map not registering

rich adder
scarlet pasture
#

the Sword will be added with "TriggerColliders" to do damage and the Rifle deals Damage with a RayCast

sour fulcrum
#

i think so maybe

languid pagoda
# sour fulcrum eg.

I hope I dont have to result in going that route. benefit of mppm was not having to build each time you want to test.

#

however I may use this none the less for other stuff

#

it looks like it could be useful

sour fulcrum
#

amazing for modding 😛

scarlet pasture
sour fulcrum
#

google it

thorn holly
scarlet pasture
thorn holly
#

So in the example you gave that would be 0.2 seconds of invincibility

scarlet pasture
sour fulcrum
#

google before asking

thorn holly
#

Uh oh

scarlet pasture
#

okay, i will do it next time.

tough lagoon
#

Its as much work to help them as to tell them to Google

#

If you aren't up for it, I dont think sitting in help channels with folks trying to learn is a good idea

sour fulcrum
swift bane
#

whenever i try to make a 3d movement i always got that error

tough lagoon
radiant voidBOT
# rich adder !input
How to Set Input

To set Active Input Handling, go to:
Project Settings > Player > Active Input Handling

• Input Manager (Old): Use the original Input settings.
• Input System Package (New): Uses the new input system package.
• Both: Use both systems.

valid violet
#

@sour fulcrum Now you are in situation that I was before 🙂

fickle plume
# scarlet pasture this is literlly a dev channel for asking

This channel does not substitute a search engine. If you find an unfamiliar concept search first, then if you still don't understand then ask questions here. Doing personal reserch yields a lot more information than a simple answer as well.

scarlet pasture
scarlet pasture
#

its really not that deep

tough lagoon
#

Ok, now your on your own 😄

thorn holly
swift bane
scarlet pasture
rich adder
valid violet
#

@sour fulcrum okay you are not in situation that I was before because I did know my point of view but you are not realize your situation

sour fulcrum
#

ok man

swift bane
rich adder
#

using a InputActionAssetReference will pretty much make things a lot easier

tough lagoon
#

Its a lot more flexible, on the one hand, but more cumbersome to setup (if doing it from scratch)

#

Imho

#

But you should be moving to it

rich adder
#

and there are dozens of ways to use the system which may come off intimidating at first

rich adder
swift bane
#

alr

rich adder
#

instead of doing

 Vector2 input = new (Input.GetAxis("Horizontal"), Input.GetAxis("Vertical") ;
Vector3 move = new Vector3(input.x, 0, input.y);```
you're doing
```cs
 Vector2 input = moveAction.action.ReadValue<Vector2>();
Vector3 move = new Vector3(input.x, 0, input.y);```
tough lagoon
#

I do think (given input is often the only way players can really interact with your game), its worth putting time into it and learning it. And it'll pay off in the long run.

rich adder
#

especially when you need to do rebinds 😭

#

old system was so trash for that they had dozens of assets for it

swift bane
thorn holly
scarlet pasture
#

i just realized somthing

#

it would be extremly smart to make one flip Script and use it for every enemy

#

a tipp for every other begginner!

sour fulcrum
#

thats a great learning step 😄

#

eventually you gain a bunch of learned knowledge that makes every project easier like that

thorn holly
#

this allows them to have common behaviours but also allow said behaviours to be overridden or changed by a certain enemy if necessary

rich adder
#

double edge sword of inheritance

#

what if you also want non-enemies do the same thing ?

thorn holly
rich adder
#

Behold! Interfaces 🌟

thorn holly
#

oh wait yeah

#

lol

rich adder
#

I wish Unity would actually let you serialize them in the inspector by default 🙄

wintry quarry
chrome apex
vital otter
#

Is there a way to render a gradient?

sour fulcrum
#

sure

#

you'd have to be more specific for a more specific answer though

vital otter
grand snow
#

you need a shader to do it but it can be done easily with shader graph

sour fulcrum
#

yeah its like, two nodes(?)

vital otter
#

Time to learn shader graph then...

#

Any resources to help me learn it?

grand snow
chrome apex
scarlet pasture
#

Hey if i use this in my Script => [ExecuteAlways] and the Script is NOT in the Scene better said my GameObject that uses This Script is disabled would that cost performacne?

cosmic dagger
scarlet pasture
#

okay thanks!

cyan carbon
#

So this channel is only for code related topics, right? sorry i tend to overthink.

cosmic dagger
#

If unsure, just read the channel description . . .

cosmic dagger
grand snow
#

the old attribute ExecuteInEditMode does not work in prefab stage (what the prefab editor thing is called)

scarlet pasture
#

okay i currently using them in 2 Scripts. and im deactivaitng them if i dont use them.

grand snow
#

well it only affects you in edit mode and if its not doing much its okay

#

just dont over use it for no good reason

scarlet pasture
#

i use it for debug pourpuse

#

Hey i use this Script ```using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

[ExecuteAlways]
public class BaseGroundCheck : MonoBehaviour
{
[Header("Ground Check Settings")]
[SerializeField] private bool useGrounded = true;
[SerializeField] private Transform RayCastOrigin;
[SerializeField] private LayerMask GroundLayer;
[SerializeField] private float GroundCheckDistance = 0.3f;
private bool isGrounded;

[Header("Gizmo Settings")]
[SerializeField] private bool useGizmos = true;

void Update()
{
    isGroundedCheck();
}

private void isGroundedCheck()
{
    if (!useGrounded || !RayCastOrigin) return;

    RaycastHit2D hit = Physics2D.Raycast(RayCastOrigin.position, Vector2.down, GroundCheckDistance, GroundLayer);

    isGrounded = hit.collider != null;
}

private void OnDrawGizmos()
{
    if (!useGizmos || !RayCastOrigin) return;

    Gizmos.color = isGrounded ? Color.green : Color.red;
    Vector3 start = RayCastOrigin.position;
    Vector3 end = start + Vector3.down * GroundCheckDistance;
    Gizmos.DrawLine(start, end);
}

private void OnValidate()
{

#if UNITY_EDITOR
SceneView.RepaintAll();
#endif
}
}

#

i want that the Frog a Boss in my Game should see from this Script if he is Grounded.

#

the Problem is or better said i think in the future will be that maybe another Enemy that use this same Script can manipulate tha "isGrounded" Check for the Boss

#

i want to know, how can i read for every GameObject the right "isGrounded Bool"

#

i needed because i want to Impement the Jump Code for my Boss, here is also a Script =>

#

!Code

radiant voidBOT
scarlet pasture
wintry quarry
#

One of the prime use cases

scarlet pasture
#

I also want to Implement the Logic, i learn that i can find the Direction from the Player to the enemy, i do that and i save the value inside of a Vector2

#

but for this case i saw a Syntax in Unity Docs but i dont now how to convert a Vector in a float, in Unity Forum i saw that doesnt work beacuse Vectors took more Data than a float (X, Y, Z) etc. i thought about Filtering it down to a float, because for this Case i only need to know tha X Achses, but i dont find the Syntax. Can sombody help me also there?

rich adder
scarlet pasture
#

it currently testing

#

would that work?

rich adder
#

no idea, not even sure what you're going for lol

scarlet pasture
#

HAHAH, i want that the Boss Jump at the Player

#

im just try somthing, im also dont know that this work tbh

scarlet pasture
#

Chis theacthed me this

#

this is why i wanted to filter it down to a X Value

#

but maybe i dont even need to filter it down

vital otter
rain solar
#

how hard would it be to train an AI agent to run a complex enemy entity?

scarlet pasture
#

it didnt work, i found a other way but this also dont work i actuially dont know why

#

but this also dont work, i dont know why

fast relic
scarlet pasture
#

but i have a idea, i think the could be a problem from .normalized

#

its reduce my upwardforce again

#

i will try it

rain solar
fast relic
scarlet pasture
#

this is what i thinked

#

i do this everytime

fast relic
scarlet pasture
#

Arc Ryders have that

eternal needle
scarlet pasture
#

they are extremly smart

eternal needle
#

it is unneccessary for the vast majority of games

fast relic
# rain solar why

it's costly and probably won't produce better results than manually coded enemies

scarlet pasture
#

my Code finally worked

#

Thanks Cookie

maiden crest
#

can someone help me with a problem i have been having for over 10 hours now and its driving me crazy, i am new to coding and unity but this help would really make my day, am i in the right place for support?

scarlet pasture
#

yeah

#

here is Coding begginer

#

im also new but im readdy to TRY to help u

maiden crest
radiant voidBOT
# eternal needle !ask

:thinking: Asking Questions

:mag: Search the internet for your question!
:book: Use the API Scripting Reference and User Manual and this troubleshooting site for commonly posted issues.
:wrench: Attempt to debug your issue.
:thought_balloon: Find an appropriate channel by reading the name and description in #🔎┃find-a-channel
:grey_question: And don't ask to ask, ask a full question illustrating with screenshots if needed.

-# For more posting guidelines, go to #🌱┃start-here

eternal needle
#

you need to paste relevant code if you expect help with the code

fast relic
maiden crest
#

it was a free package that came with code etc, and because of my issue I asked chat gpt for the fix and it was giving me code but didn't fix my problem, is there a way i can show someone?

fast relic
#

!code

radiant voidBOT
maiden crest
#

so i just paste in my cs code and it will tell me where I went wrong?

fast relic
#

what's the "it" you're referring to?

maiden crest
#

sorry i am very tired i was supposed to say "in"

fast relic
#

what about the other it

#

what's supposed to tell you where you went wrong?

maiden crest
#

what is this !code you sent me what do i have to do

#

i am very new to this

scarlet pasture
#

past u code inside, click in top left on save

fast relic
#

it's just showing how to send code

scarlet pasture
#

copy the URL and post it here

fast relic
#

it's not some magic that will fix the problem for you, it's just a way of sending code to make it easier to read

scarlet pasture
#

with 3 of this => ´´´

maiden crest
#

i have 8 cs files

#

to go through then

scarlet pasture
#

DAYUMN

maiden crest
#

yes lol

#

this is why my head hurts

scarlet pasture
#

bro u are a pro

maiden crest
#

10 hours trying to fix something that would take a real pro 2 seconds lol

scarlet pasture
#

i wish i can help u but im goofy at coding

maiden crest
#

is there a way i can screenshare might be easier?

fast relic
rich adder
#

true

scarlet pasture
#

Mr woz u allowing that he is talking with u like this?

fast relic
rich adder
maiden crest
#

it doesn't bother me I have only been doing this for 1 week

#

so yes they are probably right

scarlet pasture
fast relic
maiden crest
#

I can't settle till this is done, only because I had it working this morning

#

and i just can't figure it out

rich adder
#

thats even more reason to take a break.. it happens.
i had same thing happen, i come to the problem next day and solve in 2 mins..

#

mind needs time to reset a bit

#

subconscious still works on the problem

maiden crest
#

i wasn't exactly doing code I was just changing the ui asset I had etc and maybe I deleted something by accident, i really do not know. I took many break today 🙁

#

i would screenshare to show someone who has experience if no 1 is busy for a few minutes

eternal needle
#

all you've shown is a video of something "not working". no one here can provide help without more information

maiden crest
#

that is why i mentioned about screensharing. But it's ok.

#

I thought this was a discord to help people, but I guess not.

eternal needle
#

if you aren't sure what code is relevant to your issue, thats something you need to figure out first then

valid violet
#

@maiden crest you don't know what you do to get what you get so you here to figure what did you do to get what you get, whould you be able to help somebody with such issue?

maiden crest
#

thanks for nothing

umbral hound
#

Hey guys, what's up with my code? My timer is not incrementing normally. For context, I'm using the new input system and I set up a positive/negative binding to change my camera, so < is -1f and > is 1f, but Idk I logged my timer, it isn't really incrementing. Just kinda fluctuating

using System;
using UnityEngine;

public class RotateCamera : MonoBehaviour
{
    private bool m_IsRotating;
    public float m_MoveTime = 1f;

    private void Awake()
    {
        Application.targetFrameRate = 60;
    }

    private void Update()
    {
        // We set m_IsRotating to true when we press the button
        if (PlayerInput.Instance.Camera())
            m_IsRotating = true;
        if (m_IsRotating)
        {
            // We're rotating
            // Assign a timer and reset it to zero
            float timer = 0f;
            if (timer < m_MoveTime)
            {
                // Increment the timer
                timer += Time.deltaTime;
                transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), timer / Time.deltaTime);
            }
            else
            {
                timer = 0f;
                m_IsRotating = false;
            }
        }
    }
}
naive pawn
#

@maiden crest one of the goals of community support servers like this is to facility asynchronous help - one person can post a question, and someone can answer some indefinite time later
VCs or screensharing kinda go against that, hence why a vast majority or servers like this don't use VCs for support

we also can't help without necessary info/context though. it's kinda on you to figure out what exactly is the thing you need help with

naive pawn
umbral hound
naive pawn
#

timer / deltaTime is also almost certainly not correct

#

oh it's wronglerp too

umbral hound
#

Okay, so do I just pass in the timer to Quaternion.slerp?

#

Oh

naive pawn
#

consider using one of the proper smoothing methods, though i don't remember if quaternions have that. ill have to check

umbral hound
#

it worked, but it doesn't work if I press it again

#

I removed Time.deltaTime from float t and just used timer

naive pawn
#

ok yeah quaternions don't, though there is Mathf.SmoothDampAngle

umbral hound
#

No it does

naive pawn
umbral hound
#

I changed it to this and it works

#

Yeah I fixed that

#
using System;
using UnityEngine;

public class RotateCamera : MonoBehaviour
{
    private bool m_IsRotating;
    public float m_MoveTime = 1f;
    private float timer;

    private void Awake()
    {
        Application.targetFrameRate = 60;
    }

    private void Update()
    {
        // We set m_IsRotating to true when we press the button
        if (PlayerInput.Instance.Camera())
            m_IsRotating = true;
        if (m_IsRotating)
        {
            // We're rotating
            if (timer < m_MoveTime)
            {
                // Increment the timer
                timer += Time.deltaTime;
                transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), timer);
            }
            else
            {
                timer = 0f;
                m_IsRotating = false;
            }
        }
    }
}
naive pawn
#

alright, just keep in mind that that's wrong lerp

umbral hound
#

but it works?????

naive pawn
naive pawn
#

oh god it isn't even wronglerp too

#

new pattern 😬

#

i would advise not inventing these new patterns

#

you basically have an accelerating wronglerp

#

it... reaches the target though, lmao

umbral hound
#

Okay

using System;
using UnityEngine;

public class RotateCamera : MonoBehaviour
{
    private bool m_IsRotating;
    public float m_MoveTime = 1f;
    private float timer;

    private void Awake()
    {
        Application.targetFrameRate = 60;
    }

    private void Update()
    {
        // We set m_IsRotating to true when we press the button
        if (PlayerInput.Instance.Camera())
            m_IsRotating = true;
        if (m_IsRotating)
        {
            // We're rotating
            if (timer < m_MoveTime)
            {
                // Increment the timer
                timer += Time.deltaTime;
                Quaternion rotation = transform.rotation;
                rotation.y = Mathf.Lerp(rotation.y, 90f, timer);
                transform.rotation = rotation;
            }
            else
            {
                timer = 0f;
                m_IsRotating = false;
            }
        }
    }
}
#

Let's hope this works

rich adder
#

timer/duration
prob

naive pawn
#

that's definitely wrong

umbral hound
#

Okay well I went to the link you gave me and it said used Mathf.lerp

#

What lerp do you want me to use?

rich adder
naive pawn
umbral hound
#

ohhhhhh

#

So Slerp wasn't the problem

naive pawn
#

yeah

#

Slerp is a Lerp that follows a different path
it still has the logic of a Lerp

umbral hound
#

Okay is this right?

using System;
using UnityEngine;

public class RotateCamera : MonoBehaviour
{
    private bool m_IsRotating;
    public float m_MoveTime = 1f;
    private float timer;

    private void Awake()
    {
        Application.targetFrameRate = 60;
    }

    private void Update()
    {
        // We set m_IsRotating to true when we press the button
        if (PlayerInput.Instance.Camera())
            m_IsRotating = true;
        if (m_IsRotating)
        {
            // We're rotating
            if (timer < m_MoveTime)
            {
                // Increment the timer
                timer += Time.deltaTime;
                transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0f, 90f, 0f), timer / m_MoveTime);
            }
            else
            {
                timer = 0f;
                m_IsRotating = false;
            }
        }
    }
}
#

One issue is that it doesn't rotate 90 degrees again when I press the button again

rich adder
#

arent you telling it to go to the same rotation ?

#

you probably want currentRot * Euler(0,0,90)

#

as target

umbral hound
#

So I make a variable that keeps the current rotation?

rich adder
#

you'd need to cache it so it doesn't always keep going 90

#

I think this is probably why doing it with a coroutine is easier

#

you see the coroutine example caches those before the while loop every frame

umbral hound
#

Okay, I got it thank you so much

#

it doesn't go the opposite way with the negative binding, I wonder why

rich adder
umbral hound
rich adder
#

are you not using a binding ? I think thats easier for WASD

umbral hound
#

This isn't WASD

naive pawn
umbral hound
#

This is a bool for changing my camera angle

rich adder
#

same thing

umbral hound
#

please

naive pawn
#

i'd probably go with smoothdampangle to allow consecutive changes before the previous one is done

umbral hound
#

Let me tell you something, I have a learning disability, I can't intepret social cues well.

#

So sorry if I feel a little annoyed

naive pawn
#

do you understand what lerp/wronglerp are, actually

umbral hound
#

No idea

#

I mean

naive pawn
#

i feel like you're kinda missing the point of what wronglerp is

umbral hound
#

I know what a lerp is, it transitions A to B

naive pawn
#

the intended, "correct" use of lerp is along the lines of y = lerp(a, b, t) where a and b don't change and t increases

#

the common wronglerp pattern is where a does change - a = lerp(a, b, dt) where dt is deltaTime. that gives smoothing but mathematically doesn't make sense, and it's framerate dependant

#

what you have now is like, somewhere in between, a = lerp(a, b, t)

umbral hound
#

So I just need Time.deltaTime in place of dt

naive pawn
#

that would be wronglerp, it'd at least be following a known pattern, sure

rich adder
#

the last one they sent was fine

naive pawn
#

but i mean, it's called wronglerp for a reason - it has its issues

naive pawn
rich adder
naive pawn
#

im not saying it doesn't work, to be clear - im just saying it's an "incorrect" use that can lead to inconsistent results

rich adder
#

adding the timer/duration give it correct t

naive pawn
rich adder
#

oh like the startPoint ?

naive pawn
#

yeah

rich adder
#

I think the target is the one that should be careful changing it

naive pawn
#

also true, would cause spikes in speed

#

and weird behavior regarding timer

#

im not convinced this is framerate independent though

rich adder
#

I usually use IEnumerator though so I do it correct with caching it.
but I have seen it used in Update and a long as t was timer/duration & timer+=delta instead of timer * delta

#

I think doing timer * delta is what keeps with that vague arbitrary constant

swift crag
#

multiplying an increasing time value by deltaTime would not make any sense, yes

#

There are two common ways that people use the lerp function:

  • Fixed start and end points with an increasing t argument
  • Variable start and end points with a constant t argument
    • This is the 'wrong lerp' that was described above
umbral hound
#

Okay let me ask this. How do I turn these into floats? Like yeah this action is a bool, but how do I make it so the negative one is -1 and the positive is 1?

swift crag
umbral hound
rich adder
swift crag
naive pawn
#

yeah it's definitely framerate dependant @rich adder

naive pawn
#

a = lerp(a, b, t)

#

with t as a normalized value increasing over time (as in the normal lerp)

swift crag
#

indeed: that cannot possibly be framerate-independent (and also does not have a very clear meaning)

swift crag
#

This input action will produce values like 1, 0, and -1

naive pawn
naive pawn