#💻┃code-beginner

1 messages · Page 749 of 1

wintry quarry
#

yes - use your equipment system

#

no, it was renamed to CinemachineCamera

grand snow
#

Well yea I think you need to do it a good way to achieve what you want
trying to take a shortcut by "finding all uses of the sprite rn" will surely backfire

wintry quarry
drowsy flare
#

I'm using the game data to perform the actual spells and stuff, but here I just want to do a simple thing in the presentation layer, that's why

dark laurel
twin pivot
dark laurel
#

my visual studio is having a fit today 😐 constant stream of errors, visual studio installer not finding the installation.. grr

drowsy flare
#

Okay @grand snow and @wintry quarry and @dark laurel , thanks for your advice. Guess I'll do it the "real" way and not use shortcuts ...

dark laurel
#

I mean, you can do it however you want.. but I promise that if you do something like foreach gameobject in my entire scene every frame, your game's framerate will quickly go to a flip album and you'll wonder why

fervent bramble
#

I am so confused becasue like 20 people are telling me diffrent things can you sned me the whole script because I have been told 20 diffrent other things and am having a brain anurism

twin pivot
# drowsy flare You're right

last time i ignored that i ended up with a vector2 called realplayerpos that had 0.5f added to the y position for some reason

drowsy flare
grand snow
dark laurel
#

@fervent bramble All the advice you've been given is correct and while overwhelming.. just needs some time (on your end) learning. 🙂 Just go back to the editor, read the advice, google what you don't understand, and try again and you'll get it.

wintry quarry
drowsy flare
#

Should actually be doable in like half an hour, thanks again

untold shore
#

Hey, don’t know if you’re still on, but I’m a little confused on the y => . Would you basically check if the enemy is inside the enemy list?

dark laurel
#

This is called an "expression lambda" if you want to google it up. In this case, the two methods (OrderByDescending() and FindFirstOrDefault()) take a parameter that restricts what they search for, but conveniently plop it into a variable you can use yourself.

#
public class Thing
{
  public int Speed;
  public int Size;
}

...

List<Thing> allTheThings = ...;

var speediestThing = allTheThings.OrderByDescending(x => x.Speed).First(); // assumes at least one thing
var speediestThingBiggerThanTen = allTheThings.Where(x => x.Size > 10).OrderByDescending(x => x.Speed).First(); 
var fattestThing = allTheThings.MaxBy(x => x.Size);
#

the "x" just means "declare a variable named x that is a Thing for the parameter"

grand snow
fervent bramble
#

i figured it out all i had to do was make the camera a child of the player head under armeture not the mesh and i didn't evenneed a script

dark laurel
#

It's also not at all necessary for your code (like, it's unrelated to unity.. it's just a fancy C# thing to reduce code). Simpler code, if you're used to for loops, is something like this:

Thing biggestThing = allTheThings[0];
for (int i = 0; i < allTheThings.Count; i++)
{
  if (allTheThings[i].Size > biggestThing.Size) biggestThing = allTheThings[i];
}
untold shore
#

Gotcha. Still have a little bit of learning to do with this, but this definitely helped. Thank you so much!!!

granite nimbus
#

is it normal that my character's position.y is 0 but when i test the game it's set to something like 0.07999989 and no matter what i did i couldnt keep it 0

slender nymph
#

are you certain it is actually 0.079 and not a number in scientific notation that just happens to start with 0.079 then has E-(some other number)? because that would just be floating point imprecision and is effectively the same thing as 0

granite nimbus
granite nimbus
slender nymph
#

it sounds like you are applying some sort of gravity to your object and it is simply falling to touch the ground

granite nimbus
#

i used claude for my playercontroller script but i checked it and not sure what does that

slender nymph
#

well you'd have to show the code, but you'd also have to find someone willing to help you debug AI generated code

radiant voidBOT
granite nimbus
#

so people still code their scripts by hand, i thought everyone uses ai then debugs the code for scripts

weak cloud
#

I find AI is sorely lacking in a lot of things, and being competent is one of them
It's never actually helped me once in programming

#

Only use I have for it is for it to be my rubber ducky and help me explain my issue better Shrug0

twin pivot
#

The companies usually just steal work so im just generally against it

granite nimbus
#

i can write my own code too but it's usually like 10 times slower since i'm beginner

weak cloud
#

People who use AI tend to not learn and lean more on the AI to do the thinking for them, I can't say this for certain with everyone because I don't know everyone but if you're starting out using AI is probably worse for you because it makes things that look correct

lime sigil
#

heyo was wondering, as i'm having a little hard time understanding
i have bones in a skeleton as a prefab in the scene, a standard character

if i need to get the children of a parent bone in that hirearchy is there a way with a specialized bone class or it's a matter of hirearchy sifting?

couldn't find much online

twin pivot
lime sigil
twin pivot
#

Should be next to layer

#

Sorry its 7 30 am and i havent slept XD

twin pivot
lime sigil
#

oh wait i see what you mean
no worries
i don't think that's a way to go tho
i have the parent bone game object reference directly
i'm struggling tho to navigate from there

this is working with importable characters meaning relying on a pre set tag wouldn't really work

lime sigil
twin pivot
#

How about shooting a ray and using an interface

lime sigil
twin pivot
#

Im sorry but im too tired to understand what you mean XD

lime sigil
#

i'm extending the unity editor with a plugin
but i thougth the how to navigate a bone hirearchy was a beginner question so i thought this was the more fitting channel

twin pivot
#

Oh idk much about that you'll need to ask someone else sorry

lime sigil
#

yeah no worries, was my bad for asking editor extension stuff in the non-editor extension channel, cooked by the hour too almost 2 am, thanks tho^^ atwhatcost

tardy lagoon
#

hi i would like to know why i got these errors bc i think i did same as in the vid

tardy lagoon
#

11 min in

polar acorn
# tardy lagoon
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 196
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2025-10-14
valid violet
#

puplic

polar acorn
#

Configure your !ide so you don't make spelling mistakes like this

radiant voidBOT
valid violet
#

puplic line 5 use public instead

#

your first error link to line 5

tardy lagoon
#

oh shi mb yo im dum

north kiln
radiant voidBOT
polar dust
# tardy lagoon

Take this as a good opportunity to learn how read the console. It prints text there for a reason.

Going by the very first command shown here, what is it telling you?

sour fulcrum
#

@wicked venture can't blame you for asking that kinda question as it's absolutely something that can be done in a bunch of varying ways.

I tend to have them instansiated or enabled/disabled living somewhere under a UIManager esque object. In your specific example it sounds like you have just the 1 instance to manage but in more involved cases something like this may warrent some sort of object pooling too.

You also mentioned re-using in multiple scenes, Depending on the way your game is setup you may want this UIManager to live in a scene that is always loaded (via additive scene loading) or existing in the DontDestroyOnLoad scene

#

I think some people have messed with UI Toolkit nowadays for this kinda thing since I believe it's less gameobject/component based?

#

I spent some time tinkering with Unity's older GUI stuff to see if it was worth it but there's some issues with the lack of batching and font scaling that put me off it

#

eg. this little test gif was entirely powered by Unity UI/IMGUI stuff with no canvas or anything

wicked venture
wicked venture
wicked venture
sour fulcrum
#

I'll have to chuck my example project up on git, I'll let you know if I do. Although overall I do recommend against this route for the reasons i've described

sour fulcrum
wicked venture
#

Yeah I will have to rewrite it since i deleted all the work after it did not work , but in general I wanted to confirm the right path if instansiate is one of the correct solutions I will go with that again

#

also checking ui toolkit might learn something new that will help me in UI in general , its about time i learn about UI

#

Ok that UI tookkit is insane wish I knew about this way sooner thanks man

primal lagoon
#

i just installed hdrp package and all the shader graphs i made are purple now help

sour fulcrum
#

shadergraphs are built to target either built in, urp or hdrp pipeline

#

you would need to remake/adjust/modify them in order to replicate the same behavior in the differing pipeline

primal lagoon
#

ok

fringe leaf
#

Anyone have any idea why my textmeshpro button and texts are gaining focus whenever I hit a TMP dropdown? I have a 50% opaque background applied on my SettingsPanel and it is getting overriden in just the text and button spots. Maybe something to do with layers or tags? A bit new sorry, any help would be appreciated, video a bit laggy but you should get the point

rugged beacon
#

what the different between these 2

rugged beacon
fringe leaf
rugged beacon
#

zindex?

#

higher number mean its on top

fringe leaf
#

Sweet, this worked perfect, thank you so much!!!! @rugged beacon

cosmic dagger
cosmic dagger
#

Okay, so it's for the ObjectPool class. That helps . . .

teal viper
cosmic dagger
hallow acorn
#

hey i made this marching cubes algorithm and i also tried interpolating it but i always get these weird artifacts idk how well you can see the in the image. i dont know how to fix it or whats wrong but its very annoying

these are the most important pieces of my code:
https://paste.mod.gg/lueynfznykew/0

#

also these artifact lines are always on integer y values

burnt vapor
upper fable
#

Is there like an easy way to have one canvas on top of another?

#

Aka like its priority is higher?

#

But i still need both of the canvases active at the same time

#

Nvm theres a sort order setting

floral garden
#

Does unity run a script event if it is not in play mode ? Like the drawgizmo

grand snow
#

yes it will execute those functions in edit mode

#

and if you add [ExecuteAlways] then it will even run Awake/Start/Update/OnEnable/OnDisable/OnDestroy in edit mode

floral garden
#

Oh

floral garden
#

Thanks

sullen epoch
scarlet pasture
#

Hey, can i ask here 2d Coding Quastion?

hexed terrace
#

yes

scarlet pasture
#

also 3d?

hexed terrace
#

read the topic.

scarlet pasture
#

where can i find it? im using Discord not often. Most of the time my Brother.

#

"Ask questions and discuss anything related to beginner coding concepts in Unity?" this?

hexed terrace
#

yes, that is the channel topic.

#

The below bot msg is gonna be useful for you too.

#

!ask

radiant voidBOT
# hexed terrace !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

fathom tartan
#

Guys this is my code, I want my movement script for the character to be in a separated script, how do I do that?

sour fulcrum
#

a pdf is a new one

fathom tartan
#

xd

#

what was I supposed to do, paste the whole code in here?

fickle plume
#

!code

radiant voidBOT
fathom tartan
#

oh xd

teal viper
fathom tartan
#

How do I share it?

hexed terrace
#

the url will change when you paste your code, copy that

fathom tartan
hexed terrace
#

ok.. that's obvs not done it

fathom tartan
#

wdym?

hexed terrace
#

I mean.. look at the url, it's obviously not a unique address that's going to take us to your code..

#

Click the save button, top left, first.

fathom tartan
#

there we go

#

mb xd

#

any idea on how to separate the movement part into it's own script?

hexed terrace
#

yeah, create a new script.. then cut and paste all the movement code into that

fathom tartan
#

no shit, but idk which parts to separate

#

don't wanna mess up the other things going on

hexed terrace
#

make a backup, so you can play freely with it

hallow acorn
sullen epoch
#

what does it say?

#

the error i mean

fathom tartan
keen dew
#

I don't see anything other than movement related stuff in that script. What exactly do you want that should stay in the old script?

fathom tartan
#

I want the camera movement, animation stuff, friction, etc to stay. I want the character movements only to be moved to another script

#

❤️

keen dew
#

Why?

fathom tartan
#

easier to understand + can add more things easily, also need present this in school so would be nice for them to be separated to not cause confusion.

keen dew
#

Lines 82-103 are the ones that handle specifically the character movement so you can copy-paste them to another script but then you have to set up all the communication between the scripts and references in the new script so IMHO it just becomes more complicated for no real benefit

#

If you want to make it cleaner and easier to expand you can just move it to another method but still keep it in the same script

keen dew
#

The same way you've made the UpdateAnimations method. Make a new method (void HandleMovement() { }for example), move the code there and call the method where the code used to be

fathom tartan
#

ahhhh okkk

keen dew
#

Although the code looks AI generated so you probably didn't make it

fathom tartan
#

sadly I didn't do all of it, I had ai help with camera movements bcs character movement and camera movement were colliding with each other

sour fulcrum
#

please dont ask for help with code you didn't write

fathom tartan
#

I literally wrote most of it, I don't see the issue

hoary heath
#

Hello there,
Quick question :
For handling asynchronous operations, I have a cubic game where I generate chunks of voxels. The generation takes time aswell as the instantiation in Unity, so I can't make it in the main thread.

What would be better :

  1. Async/Coroutine tasks for each chunk
  2. Second thread that generate each chunk

I'm not sure if the first or second one is better, I would think the second one would make less overhead for large amount of chunks generated, but the first one could be easier to code

Also, is their a way to force an execution to slow to takes less CPU ? For instance i don't want the CPU to overload If i want to generate 100 chunks, I want it to slow down but the general execution of the game continue with low impact.

scarlet pasture
#

Hey

#

why should i learn coding or make a Game?, i have that feeling in my Stomach that everthing i try to learn is usless because? Why would sombody ply My Game? there is hundreds of better Games.

#

are u guys also struggelying with this feeling?

keen dew
ivory bobcat
hoary heath
scarlet pasture
# ivory bobcat You probably shouldn't if you've got no reason to

i have, i dream since im a Kid to make a Game. I Never startet... Now im 19 Years old, i dont have much time enymore, im getting old and i need to invest in my Future. But this Dream i have consitently "Remmbers" me on my thought i had as a child. But evertime im sitting and Code Somthing the problem rise again. Like "Why would sombody in the World play u game"

#

sorry for Bad Englisch

#

i have the feeling the i maybe lose to much time for somthing thats nobody cares

keen dew
tardy lagoon
hoary heath
hoary heath
scarlet pasture
#

so i will Continue, thanks G u really dont know how much that helped me even it is basic reasons? (sorry for my Bad Englisch Skills)

tardy lagoon
#

when i put the "myRigidbody" in the "if" statement it stopped working

scarlet pasture
#

its not in the Updatze function i thinl

#

im also new..

teal viper
scarlet pasture
#

HAHA

hoary heath
teal viper
scarlet pasture
#
    {


        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("Ich springe!");
            rb.velocity = Vector2.up;
        }
    }````
digital hawk
#

Hi ! I want create a good characontroller for a platformer 3D in Unity 6 but I don't know how to take me.......

naive pawn
radiant voidBOT
naive pawn
scarlet pasture
#

what is spoonfeed?

naive pawn
#

providing full code like what you did - it takes away agency for the asker to actually learn themselves

sullen epoch
# scarlet pasture its not in the Updatze function i thinl

3 bits of advice

  1. its not something you can half commit, you have to give it your all and make sure you're making an effort to retain what you lean.
  2. if your goal is to just make money then you're going to fall for a trap that many people do. if you focus all your time on one big project then you're going to get burnt out quickly, start small and try to make a variety of different things
  3. do the little things that might seem pointless. like taking notes, explain to yourself out loud, or to someone what lines of code do, this helps you commit to memory what you've learnt. and once you've learnt a little bit, always attempt things yourself before asking for help. it might seem silly leaving notes, but trust me they are like gold.
naive pawn
#

it results in askers/beginners relying on answers rather than learning how to fix issues

scarlet pasture
#

ahhh, i understand what u mean. I mean its the same code from him. i just triyed to say that he need to but it in the {}

naive pawn
rocky canyon
#

one of these is not like the other 😄

#

where theres an opening bracket { there must be a closing bracket }

#

u have 1 that doesn't have an open

#

pair them up... and find the one that doesn't fit..

#

its a rogue bracket

naive pawn
#

it changes the behavior, without really explaining the core cause
imagine they just copied the code replacing their Update

they could leave or remove more brackets than necessary, leading to the same issue
if they did place it correctly, they'd now have different inputs and different outputs, and no guarantee that they actually understand why it worked

support servers aren't just answering machines, there's somewhat of a duty to teach here as well
@scarlet pasture

#

all that aside - their ide isn't configured.
if it were, there'd be a lot of errors complaining about what's wrong lol

naive pawn
rocky canyon
#

ya, config ur ide real quick... can't really work professionally w/o it

red cedar
#

Hello, does anyone know how to make this wheel rotation smoothly? I'm rotating using z but it's a little bit off

naive pawn
sweet bough
#

hi, i made this script to make any object that block view to the player transparent, almost everything works fine (material changes to the instance, the settings are all ok) but in the game i cant see the opacity change of the material until i update any setting manually
making it with layers changed nothing, i use URP

https://paste.myst.rs/wp09um3f

naive pawn
#

!code

radiant voidBOT
naive pawn
#

is it really a code thing though

sweet bough
#

idk

#

if i do it manually it works fine

rocky canyon
naive pawn
#

there are also probably existing ways to do so, like near plane clipping

rocky canyon
sweet bough
rocky canyon
#

try copying the material.. changing it and applying the copy

#

just to test real quick if im right

sweet bough
rocky canyon
#
  • Renderer.sharedMaterials edits the shared project asset (not instance-specific).
  • Renderer.materials makes runtime instances that can be updated per object.

not 💯 this is correct (google overview) but i do recall needing to copy it out

#

You might want to consider trying to cache the materials n things you need — so you’re not constantly creating new instances all the time

sweet bough
#

is there any other way i can do that?

rocky canyon
#

^ oh yea i forgot bout that

lunar axle
rocky canyon
#

its better to learn how movement works

#

as a bare necessity.. nothing wrng with using assets as referenece..

#

but i wouldnt build off that

lunar axle
#

well if they asked to make one then ill just throw them a link

rocky canyon
#

and they asked for a platformer..

#

not many first person platformers i know of

scarlet pasture
#

Hey, how can i check if the Player runs. I want Play the idle Animation.

#

from my Player. im also using 3d and only Character Controller

rocky canyon
#

don't discount learning basics tho !learn

rocky canyon
scarlet pasture
#

Applying the run Input?

rocky canyon
#

yes... when ur input is running.. u just mark a flag/boolean
like isRunning

scarlet pasture
#
        float ix = Input.GetAxisRaw("Horizontal");
        float iz = Input.GetAxisRaw("Vertical");
        Vector3 inputDir = (transform.right * ix + transform.forward * iz).normalized;
#

how would i manage that=?

rocky canyon
#
if (Input.GetKey(KeyCode.LeftShift))
{
    isRunning = true;
}
else
{
    isRunning = false;
}
``` something like this
scarlet pasture
#

can i just say "If the Player isint pressing somthing like WASD he is not Running?"

rocky canyon
#

u could also just check if ur movement is greater than something..
using its magnitude

hot wadi
#

U might wanna learn blend tree

rocky canyon
#

say ur end movement vector is movement
it'd be

if(movement.magnitude > x){
//ur running
}
else
{
//ur not running
}```
#

magnitude is always positive no matter which direction ur going..

scarlet pasture
# hot wadi U might wanna learn blend tree

i dont like them, i only need a few Animation like maybe 3 or 4 for a Horro Mobile Game. I Animatet the Players "Breatch Animation" and i need to play it correctly otherwiese it would overwrite my Camera Script

rocky canyon
#

debug the value at first just so u can get an idea..

#

if any movement counts as running u can just check if its greater than zero

#

or some small value like .01

#

that way it'll ignore any tiny input (deadzones for example)

scarlet pasture
hot wadi
scarlet pasture
#

this would be safe?

scarlet pasture
#

so i need to fix my code not my Animation?

rocky canyon
scarlet pasture
#

Nice!

#

Thanks u so much!

#

But why is my Code bad if the Animation of the Camera overwrite my Code?

rocky canyon
#

may want to check the x and z seperate tho..

#

if u have verticallity.. wouldnt want to count that as running/animation

rocky canyon
#

so instead u'd do something like animate a empty gameobject
put the camera inside it.. and run code on the camera..

#

that way the animator isn't controlling the actual camera's transform..

#

but it would still influence it.. b/c its moving its parent

rocky canyon
#

best just play around with them.. inspect the code.. see how they work..
do a little research urself.. ask around parts u dont understand..

#

eventually you'llwant to know it inside and out.. and how it all works

#

movement code is the backbone of most games

digital hawk
# rocky canyon movement code is the backbone of most games

okayyy thanks for your help I'll try to watch all that, I found videos on state machines do you think it would be good to use them? https://www.youtube.com/watch?v=Vt8aZDPzRjI

Learn the fundamentals of programming State Machines in Unity with this new video break down!

This tutorial explains important concepts of the State Pattern, and how to use State Machines when programming! Today we will walk through an example project to showcase the benefits of using state, the state pattern and state machines in Unity!

This ...

▶ Play video
scarlet pasture
patent wedge
#

hey is there any way to subtract the last frame's platform velocity and the current one?

naive pawn
rocky canyon
#

if ur doing platforming tho. u might want to find one that has momentum.. or find out how to do that urself (like aircontrol)

rocky canyon
#

do what chris say

patent wedge
naive pawn
#

basically:

var oldValue;

void Update() {
  var currValue = getValue();
  var difference = currValue - oldValue;
  // ...
  oldValue = currValue;
}
naive pawn
#

it's already a velocity delta between frames

rocky canyon
# scarlet pasture So the breathing „animation“ would be better if I coded it?

i do.. breathing is prettty simple sinwave or mathf.pingpong
i use seperate containers to keep my logic seperate to avoid conflicts and frustration..

main root gets rotated left right
then down one object moves up and down
then i have my "bobber" or cam breathing code..
andthen finally the final child is the camera.. (nothing is actually running code in it) just all its parent containers

patent wedge
naive pawn
#

are they perhaps applying deltaTime to acceleration

rocky canyon
#

log ur values like i said earlier...

#

get an idea of what values ur working with

naive pawn
#

make sure you actually understand what's happening rather than just copying blindly

rocky canyon
#

Debug.Log(movement);
Debug.Log(movement.magnitude)
Debuig.Log(etc)

naive pawn
#

TargetVel - LastPlatVel is a delta of velocity
if you multiply in deltaTime, you end up getting a value that represents how much extra distance the new velocity travels compared to the old one

#

you'd be adding a delta position to linearVelocity

scarlet pasture
#

Thank u Rental

rocky canyon
rocky canyon
patent wedge
naive pawn
#

what is Final there

#

the delta?

patent wedge
naive pawn
#

cool, then that's probably what you want

#

remember, that's the delta per frame/tick

patent wedge
naive pawn
#

what is the goal here exactly?

#

im really confused

#

you're getting the acceleration and applying it to the player as velocity?

#

yeah that's.. that doesn't make sense come to think of it lol

rocky canyon
#

ya, im a bit confused too.. i thought we were talkin about magnitude for animations and stuff.. i got lost when u started talkin about platforms

patent wedge
rocky canyon
#

anyway on a side note.. i'll throw ya a bone 🦴 https://paste.myst.rs/kap36emz here's the CameraBob affect the video i sent shows:

float yOffset = Mathf.Sin(Time.time * bobSpeed) * bobDistance; being the Sinewave i was talkin about @scarlet pasture

naive pawn
naive pawn
rocky canyon
#

ohh okay

#

oh damn, confusing lol

rocky canyon
scarlet pasture
#

Thank u for the code and the commentary’s

#

So I can understand the code also better

rocky canyon
naive pawn
#

ok going through the math - it seems like there would be / deltaTime and then * deltaTime, so no deltaTime is correct

naive pawn
rocky canyon
#

and whats not working exactly?
is it still when it changes directions?

naive pawn
patent wedge
jaunty wing
#

I'd just use a rigidbody to make it less complicated, but basically, if you want to do it, you get the floor's position, and match it to your player position

rocky canyon
#

ya, but if it has any kind of horizontal movement u wouldn't wanna overwrite ur players movement

rocky canyon
jaunty wing
#

I mean, if it doesnt use velocity anyway, you add a position already when you use wasd

naive pawn
jaunty wing
#

for the platform

naive pawn
#

that seems... detached to the issue

patent wedge
naive pawn
#

the previous answer about transform positions was.. not relevant to the question lol

patent wedge
naive pawn
#

that's not what i asked

#

the moment the player gets on - is the platform's existing velocity applied?

#

is that baked into the delta check?

patent wedge
naive pawn
#

the platform following code is on the player, right?

naive pawn
naive pawn
#

also, check how you're moving the player, make sure you aren't resetting the velocity or anything

patent wedge
#

if so yes!

naive pawn
#

was that meant to reply to my previous message?

#

im so confused

tulip stag
#

Hey, how do I open the Windows system dialogue to allow the user to select/upload local files?

patent wedge
naive pawn
#

i don't think making the platform kinematic would really affect.. any of this logic
just that you'd have to retreive/manage the velocity differently

#

but again - leave that for later

#

focus on the actual issue

naive pawn
patent wedge
tulip stag
#

Very simple snippet

naive pawn
#

it could be with the lastplatvel thing

#

or it might be the GetPointVelocity you mentioned?

#

at this point you're just being cryptic, just share the code so we actually know what's going on lmao

#

!code

radiant voidBOT
grand snow
jaunty wing
patent wedge
jaunty wing
#

Director Class is what is used to create custom file pickers

naive pawn
#

they asked for the windows system dialog though

grand snow
tulip stag
sweet bough
#

maybe i forgot smth

scarlet pasture
dark laurel
#

Note that this was for local use - ie, not public facing. If you're planning to give something like this to users it might need some more bulletproofing and error handling.

grand snow
#

Good old win 32 com

dark laurel
#

imho this ought to be something that exists somewhere in the unity API.. seems like a file selector is pretty common for apps (maybe there is one on asset store 🤷 )

grand snow
#

There is something for editor use but not runtime

#

Probably because it's only applicable for desktop

#

I did use a cool in unity file browser before but forgot it's name

dark laurel
grand snow
#

Well for android it's complex and too different

#

For iOS id presume even worse

scarlet pasture
#

Hey, im trying to implement my Camera System for my First Horror Game. I dont understand why the Lean Effct dont work? can it be that the HeadBob overwhrites my Lean Effect? and how do seperate them? how do Unity Devs do that?

naive pawn
#

!code

radiant voidBOT
scarlet pasture
#

i dont have the Premium version. i can send code over 2000 characters

#

sorry

naive pawn
#

use the large code blocks section

scarlet pasture
#

how can i use it?

naive pawn
#

click one of the links, paste your code there, hit the save button, copy the link here

scarlet pasture
#

thank u Chris

radiant voidBOT
naive pawn
scarlet pasture
#

i did use target Rot

#

oh u mean i need to lerp it?

naive pawn
scarlet pasture
#

ahh i only defind it but never used it

scarlet pasture
naive pawn
#

just inexperience, you'll learn to check for that kind of stuff as you get more experience

scarlet pasture
#

yeah, i will give my best. I learn everthing more about code

hallow acorn
#

how bad is it to have 31k tris and 95k verts per chunk in a procedurally generated open world? (16x16 units)

#

with 16 chunks thats nearly 300k tris and 1mil verts

cosmic dagger
#

You'd have to test that. No way to tell; especially without the environment models . . .

hallow acorn
#

okay thats 400fps with ease on my 2070 super

#

thats not even that bad

#

except id have to render or atleast load many many more for a viewdistance that isnt equivalent to minecraft on a raspberry pi

sullen epoch
#

i'm researching reference types, in particular, classes, i already know how they work, but i've always wondered, when do you opt to use a class as opposed to just using a second script? or is it purly prefernce? i know that making a new script creates a new class anway, i was just curious if there are circumstances where it needs to be allotted into the same script

slender nymph
#

a class as opposed to just using a second script
this doesn't make a lot of sense. your scripts presumably contain classes (or other types if you are them)

#

if the distinction is "defining a class within the same file" vs using a new file, then you should prefer using a new file as that keeps your code organized better and more easily searchable at a glance

sullen epoch
#

sorry for the weird phrasing, you essentially answered my question 😅

naive pawn
#

alternatively - if a class only really pertains to a single other class, you could have them nested, potentially even inaccessible from the outside, for example in something like this

public class LinkedList<T> {
  Node<T> head;
  private class Node<T> {
    T value;
    Node<T> next;
  }
}
boreal frigate
#

Anyone know why my sprite has another outline when I export it into unity? It happens as soon as I put it in unity so the settings are all default.

boreal frigate
#

ok thanks

zenith wren
#

I don't know why this is happening but out of nowhere whenever I set an object to the player it starts floating away whenever the player moves, this wasn't an issue before and only started happening after updating from the security risk.

zenith wren
#
using UnityEngine.PlayerLoop;

public class Pickable : MonoBehaviour, IInteractable
{
    public Interactor player;
    public BoxCollider Collider;
    public Rigidbody rb;

    public BaseScriptableObject objectData;

    private bool isHeld = false;

    public bool Interact(Interactor interactor)
    {
        player = interactor;

        isHeld = !isHeld;

        if(isHeld && !player.isHolding)
        {
            transform.position = player.pickupLocation.position;
            transform.parent = player.pickupLocation;
            transform.rotation = player.pickupLocation.rotation;

            player.isHolding = true;
            rb.isKinematic = true;
        }
        else if (!isHeld)
        {
            transform.parent = null;
            transform.position = player.dropLocation.position;

            player.isHolding = false;
            rb.isKinematic = false;
        }

        return true;
    }
}
twin pivot
#

Maybe some funky interaction between setting the transform before setting the parent?

zenith wren
#

maybe

#

lemme switch em

twin pivot
#

Try swapping the order for that and if it doesnt work im not too sure

zenith wren
#

it was not an issue before, this all started happening after I updated from the security risk editor

slender nymph
#

you're not using something like Rigidbody.MovePosition to move the object, right?

zenith wren
slender nymph
#

i see that in this component. i mean in a different component. because MovePosition is how you move a kinematic rigidbody so simply making this object kinematic won't stop that from working

zenith wren
#

I can send the interaction code as well if that helps

naive pawn
#

parenting a rigidbody to a moving object would count as moving via the transform wouldn't it thonk

#

which would be a physics desync

zenith wren
#

so making it kinematic just does nothing?

slender nymph
#

no, it certainly makes it kinematic. whether that has any impact on preventing your existing code from working on it is unclear because you've not shown how you normally move that object

naive pawn
#

it keeps the rigidbody from falling due to gravity

naive pawn
zenith wren
#

this is how I move my player, don't know if it affects it or not

{
    Vector2 input = movementControls.action.ReadValue<Vector2>();

    Vector3 finalMove = new Vector3(input.x, 0, input.y); //Converts 2D movement to 3D

    if(canMove)
        controller.Move(finalMove * playerSpeed * Time.deltaTime); //Moves character by world time

    float smoothing = 10.0f;

    if(finalMove != Vector3.zero)
    {
        transform.forward = Vector3.Slerp(transform.forward, finalMove.normalized, Time.deltaTime * smoothing);
    }

    //If Player not grounded apply gravity
    if (!controller.isGrounded)
    {
        controller.Move(new Vector3(0, gravity * Time.deltaTime, 0));
    }
}```
naive pawn
#

you should not be calling Move more than once per frame, btw.

twin pivot
#

Also shouldnt you be using fixedDeltaTime for this kinda stuff?

naive pawn
#

you shouldn't check isGrounded to apply gravity either, you kinda need gravity to check for the ground continuously

naive pawn
#

(also might want to add normalization to the input)

#

i'm getting off track, these issues can be fixed later 😅

zenith wren
#

and what's weirder is before it worked perfectly, didn't change any code relating to player or objects

slender nymph
naive pawn
naive pawn
zenith wren
#

I used to just set the position every frame but that was dumb in so many ways

naive pawn
#

it's fighting the physics engine, but the physics engine tries to cope
and it was surviving the other times you tested, but not now

not sure if it has to do with the update though

zenith wren
#

if only I could disable rigidbody during play

naive pawn
#

apparently joints might help? im not familiar with those, but might be worth looking into

zenith wren
#

omfg

#

I got it

#

I did change something on the objects

#

I set the rigidbody interpolation to interpolate

#

setting it to none fixes it

naive pawn
#

i mean for most cases i believe it should be interpolated

#

im frankly scared to find out why that "fix" works lmao

slender nymph
#

and we're absolutely certain that there's no MovePosition calls happening on this object during this time frame?

teal ice
#

Can somoene can help me … like tomorrow evening bcz i started today and i am really lost …

zenith wren
#

would that be a line of code?

twin pivot
radiant voidBOT
# slender nymph !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

zenith wren
marsh canyon
#

so in Visual Studio.... if I do Rename, it seems to impact the same name on multiple files? Is there a way to easily change all the names only on the same file?

For example if I have the same name "bottomAd" in Script A and Script B.... but I want to change "bottomAd" to "botAd".... it'll apply it for both Script A and B even though I only want it for Script A

zenith wren
#

also what is the difference from interpolate and extrapolate because extrapolate works but interpolate doesn't

naive pawn
grand snow
#

so use find and replace to not do this

naive pawn
#

you could just find&replace for more control (checking individual instances) i suppose, but vs should be able to track references accurately

slender nymph
#

if the ide is properly configured it should update that specific variable in all places used and not anything that just happens to have the same name but is unrelated

polar dust
#

surely it renames the references in both files, because those are all part of the same reference. It wouldnt allow for a partial rename because in the other file it'll have a broken reference

grand snow
#

Yea exactly

naive pawn
#

ive seen it just do a find & replace all in contexts where it can't figure out references (uninitialized project kinda deal)

grand snow
#

Hm thankfully i havent had it be that dumb yet

polar dust
#

Something I wonder is they say that A and B have a property with the same name. Suppose that the properties dont actually reference each other, would visual studio then have ctrl+r+r rename both of them?

slender nymph
#

it would not if visual studio is properly configured. whether it would do that when unconfigured is not entirely clear

fickle bane
#

Hey everyone, Im new to unity and Im taking this tutorial: https://www.youtube.com/watch?v=7PYREq2OmHA

Would someone know why my wheels are spinning in circular motion and not adhering to the parent (Car).

please se video attached.

In this video, I walk you through how to create a complete off-road vehicle controller in Unity from scratch. We’ll build everything step-by-step, including the car setup, physics, custom wheels, suspension system, and working skid marks.

📁 Get the code & project files, and other links:
GitHub Link: https://github.com/SimonVutov/Simple...

▶ Play video
jagged leaf
#

hello guys im hoping to get some help with a small bug thats driving me insane notlikethis
i made this character controller script and attached a cinemachine free look camera to the player
everything works fine and dandy but when i move laterally left and right, the character doesnt go in a straight line but like curves slightly (look video)
ive been struggling to find out what is causing this
https://paste.myst.rs/jjx6iut7

naive pawn
radiant voidBOT
jagged leaf
fierce edge
#

Hello, I am new to C# and learning is going smooth. However, I am curious on how I should handle cleanup when it comes to lists and arrays of objects? For example, if I instantiate a prefab a few times into a list, do I need to clean that up, by destroying them and clearing out the list, or let the garbage collector handle it? I don't think Unity will tell me if there's a memory leak (I don't know that for certain).

hoary heath
#

Hi guys, I'm currently working with jobs, and I have an issue.

Here is the problem :
I have a quite big data input that is stored in a class, this class (in the job) is only used to read data
The job returns values.

However in jobs, you can't have managed variables (ie, classes)

I don't want to transform this class into a struct because its used elsewhere where I would like to preserve references. And also because I don't want this big data copied over and over.

Is their some key words or stuff like that where i would be able to use that class as readonly without reworking the whole code ?
Or some other ways ?

grand snow
#

Use c# threads instead

keen dew
# fierce edge Hello, I am new to C# and learning is going smooth. However, I am curious on how...

It's in general very difficult to create a true memory leak in C#. You don't usually need to worry about that, just do what the game needs to do anyway (i.e. destroy gameobjects that aren't needed anymore) and let the garbage collector do its thing. When a scene ends everything inside gets cleaned up and while working within a scene it's best to reuse things instead of destroying and creating new stuff

grand snow
#

It is a pain that with how jobs are designed we are restructed to blittable/unmanged types even without burst

hoary heath
hoary heath
keen dew
#

Well you asked for options and that is one option, up to you to figure out which one is the best

grand snow
#

The job system is better suited for unity related components/apis but general data doesn't have to use it

#

UniTask makes it easy to use a thread pool and await results on the main thread

hoary heath
rich adder
hoary heath
grand snow
#

Ah right then the job system may be best as I know there are structs made for this. I guess you can make a struct to hold this input data

hoary heath
# rich adder > its used elsewhere where I would like to preserve references Just curious wha...

That's the issue, I have a class named Chunk which handle all the voxel's data and will handles some triggers
It will be called if the user clicks to add or remove voxels for instance

In the same time, i have to send the chunk to the mesh optimization algorithm to be able to work with. Because a chunk is 50x50x50 voxels, copy/paste using struct (value type) can be bad for the memory
And because its used in jobs, the burst don't want unmanaged types anywhere in the algorithm

rich adder
grand snow
#

unusable with async though

polar dust
# fierce edge Hello, I am new to C# and learning is going smooth. However, I am curious on how...

C# is pretty smart when it comes to memory management, afaik it was probably a core principle for the language when they designed it.
Unless you get into the more technical aspects of managing data, think of memory management more like "objects (every type,class in C# is an object) , really only exist if and whenever you need them too" https://learn.microsoft.com/en-us/dotnet/standard/automatic-memory-management says

Automatic memory management can eliminate common problems, such as forgetting to free an object and causing a memory leak, or attempting to access memory for an object that has already been freed.

rich adder
#

C moment

hoary heath
nocturne parcel
#

Also, the GC probably knows more than you do, so don't try to outsmart it.

polar dust
#

you can mess things up, but eeehhh, i dont think its ever become a concern for me in all my time using c# (im no spring chicken)

hoary heath
grand snow
#

Well unless c# can do copy elision but I doubt it

grand snow
polar dust
#

if anything the only thing that i have had to deal with in C# is the ability to make infinite loops that hang the process 😆

fierce edge
#

Thanks for the replies. I am comming from a ancient history of c++, where if you make an object and use it, you have to free it. Also more recently, my coding skills have been with Python and variants of it. Another thing I noticed, is that when I run my game and close it, the memory in task manager increases for Unity, which makes me wonder; but it gets all cleared out when I fully close everything.

rich adder
hoary heath
# polar dust C# is pretty smart when it comes to memory management, afaik it was probably a c...

C# is pretty smart when it comes to memory management
Yes and no, it has a GC which can "easily" be passed and have a lot of leaks, that's a thing I both like and dislike with C# compared to C or C++
Its managed automatically but its not perfect nor intelligent, the compilation doesn't provide optimisation in these areas.
Compared to C and C++ where you have to handle all, but at the same time you can pinpoint where the leak is from

A basic thing we can't do in C# is static size arrays, you can't have a fixed sized array, it will always be handled like a variable size. Technically you can use Span or stuff like that but you'll have to explicitly write unsave and also its a pain to work with

rich adder
#

You can still cause memory leaks, is just very very slim
(mostly when dealing with events and not cleaning properly)

grand snow
#

Thankfully we can do things like stack allocated arrays with span but tis a shame its not easier

fierce edge
#

If arrays were dynamic, I wouldn't need List 😛

rich adder
#

Lists are just arrays anyway 😛

fierce edge
#

Doesn't matter, clean up is the same if I have to handle it. It's only a concern to me when a scene changes or app closes.

grand snow
#

wait till you learn about manged shell objects

rugged beacon
# jagged leaf 🥹

Vector3 moveDirection = (camForward * _movementInput.y + camRight * _movementInput.x).normalized;
your movement is dependent on the camera, you need to seperate these 2 out

fierce edge
#

I am also trying to understand another quirk. While running the game (roll a ball), I notice dips in the fps which is capped at 60, whenever a instantiated object is deactivated and reactivated (i am using pooling). But I noticed the exact same thing when I was creating and destroying prefabs. So is using activateSelf creativing over head similar to creation/destruction?

rich adder
#

no there should not be cause all the items are loaded into memory

#

its also hard to judge exact numbers in the editor, the editor has overhead and even interacting betwen windows will cause spikes up/down

#

If you want accurate numbers you should always run it on a build

fierce edge
#

I'll have to figure out how to make a debug build (that shows info), thanks. I just thought, because prefabs were being activated/deactivated and moved, that it was causing it. Maybe it was a coincidence.

rich adder
#

yeah maybe.. I'd keep in mind the script itself can still have runtime operation that could cause other garbage

oblique ridge
#

complete coding noob following the programmer pathway here:

managed to get WASD movement for an isometric controller (script screenshot attached)
but my 'player' phases through solid objects with enough pressure,
even though it has a collider (tested with both box and sphere presets) & rigidbody.

additionally, i've also been unable to get normalized vectors to work (prevent character moving faster diagonally)

things i have tried:

  • change the character collider from sphere to box
  • increase invisible bounds' collider thickness
  • make the character move slower
  • implement player control the rigidbody way, using AddForce (specifically Velocity.Chang) & increase linear damping to reduce 'slipperyness'
  • but Input.GetAxis + transform.Translate still feels the best for what im trying to achieve, just a simple 8 direction movement with no jumping
rich adder
#

you're literally bypassing the physics

oblique ridge
#

oh that seems right
sucks though because rigidbody feels so unnatural and i haven't been able to get a good combination of parameters to fix it

rich adder
#

you get a weird time where it does collide cause it has time to "catch up" from the physics scene

oblique ridge
#

should i move back to rigidbody AddForce(Vector3, ForceMode.VelocityChange)?

rich adder
#

you could probably use .linearVelocity and get a similiar feel to Translate

fierce edge
#

I think of translation like warping to the point, so there is no collision happening, you're just there.

rich adder
#

remember the physics are running in a separate scene

#

normally PhysicsMove/Simulate => Pass information to the Transform

#

if you do Transform -> Rigidbody you get weird inaccuracy because the physics is trying to catch up

oblique ridge
#

it's actually on a separate thread?

#

oh my god

rich adder
#

threads got nothing to do with it

oblique ridge
rich adder
rugged beacon
jagged leaf
#

ill just try a bunch of stuff

rugged beacon
#

maybe stop rotate the camera when you move left right like that

oblique ridge
rich adder
#

or maybe
camRight.y = 0;
should be
camRight.y = transform.position.y

rugged beacon
#

yeah i think camera forward is enough

jagged leaf
#

excuse my stupid ill try that right now

oblique ridge
#

yea collision solved
BUT sideways AND diagonal movement is still way faster

jagged leaf
rich adder
rich adder
oblique ridge
rugged beacon
#

moving transform twice is first i have seen
usually you combine the direction and move that direction

jagged leaf
jagged leaf
#

yeah no that makes it so when rotating my camera the player just keeps going in that initial direction

#

grtrrrr

#

ill just turn off x axis damping for now i cba

#

its the slight camera follow that messes it up

#

ill need to rewrite that part to be independent it seems

rugged beacon
#

if you rotate the character already then left right dont need to depend on the camera rotation

jagged leaf
#

when they dont then i just end up going in one direction, it only rotates the player when moving forward

rich adder
jagged leaf
#

ill give it a try

oblique ridge
#

thx for da help

jagged leaf
#

i love getting stuck on the smallest things!! truly

rich adder
#

better than something complex where you take days to figure out 😭

oblique ridge
#

how?

rich adder
#

also yeah you should only call a move method once

rugged beacon
#

idk havent dont this movement based camera before i would just spam a few tutorial and see what work then comeback later

jagged leaf
oblique ridge
#

how does one merge movement directions and still specify where to go with what keypress

rich adder
rich adder
#

vector 3 is (x, y, z)

#

if you put another number it will move up/down

jagged leaf
#

Cannot convert initializer type '(UnityEngine.Vector3, int, UnityEngine.Vector3)' to target type 'UnityEngine.Vector3'

i hate vectors ive always hated vectors

scarlet pasture
#

hey in a top Down Game, how can i Attack in Diffrent Direction, With the Mouse? What is the Logic behind?

rich adder
rugged beacon
#

you rotate and you shoot

scarlet pasture
#

like top right, top left, down left and down right

jagged leaf
rich adder
jagged leaf
#

Vector3 moveDir = new Vector3

rich adder
#
Vector3 moveDir = new Vector3 ( 
Vector3 moveDir = new (
var moveDir = new Vector3 ( ```
these all work
jagged leaf
#

Vector3 moveDir = new Vector3(camRight * _movementInput.x, 0, camForward * _movementInput.y);

Argument type 'UnityEngine.Vector3' is not assignable to parameter type 'float'

#

interesting

#

where did the float come from

#

ah the .x

#

is a float

rich adder
jagged leaf
#

then im confused at why im getting the error

rich adder
#

what is camRight a float or v3 ?

jagged leaf
#

camRight and camForward are all v3s

oblique ridge
rich adder
#

i thought they were floats mb

jagged leaf
#

so im cooked?

rich adder
#

then you just need
moveDir = camRight * _movementInput.x + camForward * _movementInput.y);

#

myb I'll take a look rq on a computer now I'll better be able to give a solution, was hard on mobile lol

jagged leaf
rich adder
#

can you send the codebin link to it

jagged leaf
#

this is the original code i came here with

#

but yeah i noticed when i turn off damping in the cinemachine camera it stops doing that so its gotta be something with my cam setup

rich adder
#

weird..are you sure its not the lookat

jagged leaf
#

honestly its just some code i grabbed from a 50 second short showing how to do billboarding

rich adder
#

wait nvm i thought it was the sprite tilting but that shouldnt affect the movement cause its seperate

jagged leaf
#

i wrote the rest of the movement based on another project of mine

#

but its the first time i use cinemachine

#

so i dont know the lil quirks

rich adder
turbid plover
jagged leaf
#

its definitely got something to do with my billboarding
since the camera damps, and the sprite always looks towards the camera

#

it just conflicts

#

lowkey might have to write my own camera script 😮‍💨

rich adder
jagged leaf
#

im 100% sure thats the case

rich adder
#

as you move your char left - right your camera is rotating too

#

but your camera is trying to fllow player at the same time

#

so its a weird circular thing going on

jagged leaf
#

im gonna need to find a different solution or turn off x damping entirely

rich adder
#

ya I can see why the damping is causing that

worthy gale
#

man guys I need some very specific help, i used a character controller to make my guy move, and now Im making moving platforms, and now I have no clue how to make my character stick to the moving platforms

rich adder
#

needs specific help, doesnt ask help in specific/exact way.. 👍

worthy gale
#

Sorry, about to drop my code

#

just sorting the paste out

#

I believe the issue lays with how character controller moves in world space, and as a result anchoring movement to a locally moving object is kind of difficult/or I am not seeing a hacky fix before me

rich adder
worthy gale
#

Parenting?

rich adder
worthy gale
#

Ahhh ok, I will see to it

teal panther
#

hello

#

should i use vs22 or rider?

#

for unity of course

slender nymph
#

rider is generally considered "better" (mostly because of its better UI and analyzers), but they are both tools that get the job done so use whatever you like

teal panther
#

thank you, rider it is

slender nymph
#

just note that rider's licensing is more restrictive than visual studio's is. you can only use rider for free if you are working on a non-commercial or open source project

teal panther
#

i am aware

#

i get the license from my uni

worthy gale
#

Huzzah!

rich adder
worthy gale
#

I used simple raycasting to pass on velocity

#

might be hackier than needed but it works

rich adder
#

whatever works

worthy gale
#

yessir, I feel like a bethesda dev already!

#

I will test parenting tho just to get a proper grip on it, since this seems much easier than the hoopty way I did it

rich adder
#

Character Controller is basically kinematic so you can get away with parenting also

worthy gale
#

Gotcha boss! And yeah thats what I thought as well and Im glad it worked out

sour fulcrum
#

Also worth noting that in general getting player controllers to work nicely on moving platforms is one of those things thats just really tricky to get feeling fantastic

#

If your struggling that's not necessarily a you issue 😄

spare herald
#

hi i have another problem
so my jumping and moving works pretty well
only thing is that theres a bit of momentum
like it keeps moving even after I let go
how do i stop that from happening

rich adder
languid pagoda
#

Question if I choose to simply not await an async method will it still return a value or will it be null since I didn't wait for it to finish?

spare herald
slender nymph
teal viper
#

Doesn't that depend on the return type?

slender nymph
#

it would have to return a Task<T> if it were awaitable and returning a value (or if relying on unity's built in stuff, return Awaitable<T>)

spare herald
#
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space) && isGrounded())
     {
         rb.linearVelocity = new Vector3(0, rb.linearVelocity.y, 0);
         rb.AddForce(Vector3.up * jumpForce, ForceMode.Impulse);

     }


 }

 private void FixedUpdate()
 {
     Vector3 move = new Vector3(0, 0, 0);
     
     if (Input.GetKey(KeyCode.W))
     {
         rb.AddForce(Vector3.forward * force, ForceMode.Force);
     }

     if (Input.GetKey(KeyCode.S))
     {
         rb.AddForce(Vector3.back * force, ForceMode.Force);
     }

     if (Input.GetKey(KeyCode.D))
     {
         rb.AddForce(Vector3.right * force, ForceMode.Force);
     }

     if (Input.GetKey(KeyCode.A))
     {
         rb.AddForce(Vector3.left * force, ForceMode.Force);
     }
 }

 public bool isGrounded()
 {

     return Physics.Raycast(transform.position, Vector3.down, 1.1f);
 }


#

heres my movement code

#

assume everything else is initialized fine

slender nymph
teal viper
slender nymph
#

you probably want to move by assigning the velocity if you want entirely snappy movement with no momentum

slender nymph
#

and if you go that route you'd want to consider using GetAxisRaw rather than polling the keys individually

spare herald
#

but then jumping doesnt work properl

slender nymph
#

don't overwrite the Y velocity then

spare herald
#

it wont use the momentum

spare herald
#

how do i do that?

#

do i just to rb.linearvelocity.y?

#

SHITT i didnt think of that

languid pagoda
spare herald
#

right

slender nymph
spare herald
#

or am i tweaking

slender nymph
#

it's the same buttons though

languid pagoda
spare herald
#

ohh wait

#

Input.GetAxisRaw("Vertical") would be forward and backward

rich adder
#

"Horizontal" a/d - left/right arrow
"Vertical" w/s - up/down arrow

spare herald
#

Input.GetAxisRaw("Horizontal") would be left and right

slender nymph
#

also using GetAxisRaw will allow you to create a Vector3 from your input that you can normalize or clamp the magnitude of to prevent moving faster by moving diagonally

gaunt zenith
#

hello, can you help me about unity ai. i cant use it

slender nymph
tacit prism
#

just asking how input buffering is implemented

trying to set up an attacking state and i have the input set up like so, but i want this to combo into a seperate light attack animation as well without having to press it at a specific time for it to work (as far as until the initial animation ends)

im just wondering how most people do it? timer with a bool? or like..whar

if my question isnt specific enough ill try to elaborate more, just kinda tired rn from running around all day

#

im using isAttacking as a bool for my walking state and targeting state to determine if they can transition into the attacking state or not, in case that causes any confusion

spare herald
#

finally fixed my jump

analog pendant
#

I know the basic structure of C

teal viper
# tacit prism just asking how input buffering is implemented trying to set up an attacking st...

There are probably many ways you can implement combos. A simple idea I can think of is:

  • have a combo manager that keeps a list of the recently recorded inputs.
  • record the time of the first or last input in the list(design choice).
  • have some kind of time threshold. When the time since the recorded time in previous point exceeds the threshold, evaluate the list of inputs, if the sequence matches any of the combo definitions, perform a combo, otherwise just the last attack/input in the sequence.
  • after that clear the list.

There might be many nuances that you'd want to adjust or change in that logic.

tacit prism
tacit prism
#

https://paste.mod.gg/jvulnnsfgjqj/4

Once again tearing my hair out because i dont understand whats wrong. Current Error being thrown is "Invalid Layer index -1" so i initially thought "oh so it doesnt like negative ones" so i removed all them from the code yet it still threw the same error???

ive fiddled with it for the last hour but i cant even get a compiling error out of this code anymore, it just hates that -1 and i have no idea what to do im sobbing

spare herald
#

hi i would like help with something

#

is there any way to rotate the camera when i collide with something?

#

what im trying to do is in the objects onCollideEnter() method Im checking if the player collides and if it does then turn the camera

#

but im not sure how

strong wren
tacit prism
#

But how does that affect my issue? It says the -1 is invalid.

Should I remove the = -1; from the ComboStateIndex in Attack.cs

#

I’ve already tried that though so that can’t be it

#

I’ve shut my computer off for the night anyhow, tired and don’t feel like ruining my scalp anymore with how much confusion I’m developing

#

It’s probably an issue with my assignment of values in unity knowing me

thorn vine
#

Hello everyone 🙂

left reef
#

How to learn unity

eternal needle
radiant voidBOT
eternal needle
#

you'd need to show the relevant setup/code. a script for growing plants and an object sliding sound completely unrelated so id assume you just have some rigidbody business going on in there

surreal sable
#

Does anyone use Unity Dialogue system by Pixel Crusher here? Would anyone be able to guide me on how to create a dialogue flow where.

The user speaks to the NPC. After 1 turn, the custom dialogue panel will open the panel to my custom survey.

Depending on whether the user has completed the survey / close the survey, my dialogue continues and the different dialogue conversation depending on whether the user has completed or closed the survey panel.

frigid zephyr
#

my visual studio randomly just vanished from my pc and so I installed Visual Studio but its not showing correctly in VS. does anyone know how to fix this?

tender mirage
frigid zephyr
tender mirage
# frigid zephyr

I know the problem. You gotta download the purple visual studio. not the blue one.

#

When you do get the purple one tho. make sure to check on the unity addon

#

and uninstall this version

frigid zephyr
#

Im colour blind, is there an obvious difference between the two?

#

Ah I installed VSCode not VS?

tender mirage
#

oh god, yeah, their logo's as far as i can tell are identical

#

one simple way to tell the right version is to check if there's this assembly or mischiveous text on the left top corner

naive pawn
#

please do not send random .exe's here

naive pawn
#

left: visual studio
right: visual studio code

tender mirage
#

got careless.

naive pawn
#

fwiw, vscode does also work with unity. there's a bit more setup, but it's mostly a one-time thing.
it has less language/unity-specific features than vs, but if you're used to vscode you can use it just fine

#

also note that vs and vscode are not different "versions" of the same thing, they are completely separate apps.

blame microsoft for the confusing naming 😢 (it used to be worse, too)

tender mirage
#

Worse? how?!

naive pawn
#

there used to be another, "visual studio for mac" that wasn't a port of visual studio for mac, but actually just a different app with the same name and logo

#

it was deprecated/sunsetted a few years ago though

#

3 very different apps with "visual studio" in the name and similar logos

tender mirage
#

ah, makes sense considering how many apps microsoft has killed

#

now that i think about it.

sonic dome
#

Okay im back to unity after a very long time last i was using it the player input script was just added i used it and all worked fine but i didnt stick with it cuz i felt like the code approach was more controlling and better but now when im back after a long time i see people are using player input only is there a specifc reason as to that?

night mural
sonic dome
#

hmm understandable thansk

cosmic dagger
sonic dome
#

i see

#

thanks

cosmic dagger
#

Uhh, both images have it . . .

sonic dome
#

yea im blind

cosmic dagger
#

!collab

radiant voidBOT
# cosmic dagger !collab

:loudspeaker: Collaborating and Job Posting

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

sonic dome
#

is this a good way to handle jump and stuff?

    [SerializeField]
    private InputActionReference move;

    [SerializeField]
    private InputActionReference otherMove;

    private Vector3 _moveDirection;

    private Vector3 _otherMoveDirection;

    [SerializeField]
    private Rigidbody rb;

    void Start() {
        
    }

    void Update() {
        _moveDirection = move.action.ReadValue<Vector3>();
        _otherMoveDirection = otherMove.action.ReadValue<Vector3>();
    }

    void FixedUpdate() {
        rb.AddForce(_moveDirection, ForceMode.VelocityChange);

        rb.AddForce(_otherMoveDirection, ForceMode.Impulse);
    }
gentle trellis
#

I wanna use monocraft (minecraft) font for visual studio code but it ended up looking like this, any fix?

#

(it's already applied)

sand glen
#

This is visual studio community not code, which may slow your search

gentle trellis
#

so I can't use it?

sand glen
#

It should work, dont use community for quite some time so cant help

#

Just saying if you were looking for fixes for code, it wont be the same

gentle trellis
#

oh okay

sonic dome
#

how can i access the linear damping from a rigidbody in code?

#

okay nvm it seems like my ide isnt able to fetch the methods

#

thats weird i can access the update and fixed void functions pretty easily

hot wadi
sonic dome
#

i meant my ide itself coudlnt do it

#

like there was no auto complete when i was like rb.

hot wadi
#

Are u using vs code?

sonic dome
#

yes

#

okay i got it fixed now

sweet bough
#

hi, i have a problem with changing materials through scripts, the problem is i have this script (https://paste.myst.rs/kvo0da4d) that makes the material of object blocking view from camera to the player's model transparent, and if the original material is transparent it is working as intended, but if it is opaque it just doesnt show up in the game until i manually change any setting of the material (it is still changing from opaque to transparent in material's settings, but the changes are not visible in the game)

silk night
sour adder
#

I remember having the same problem with an object. I just set it to transparent with no transparency, but believe you don't want to do that. It was Unity 2021.3.

silk night
#

I can hear the profiler yelling from the corner

mint swift
#

Steam Game
I'm currently working on a steam multilayer game
I know the basics of Lobby , relays , NGO.. but like I wanna get the steam name of the player and after that just use it so on.. i searched the web for some guides they use mirror and idk what i don't wanna go into something not that good after all just need the way to start..
Any suggestions?

sour adder
mint swift
#

yeah , could I just stick to Lobby and relays and just get the name from Steamworks.NET?

slender nymph
#

you have to get the steam info from steamworks, and Steamworks.NET is one package you can use to do so. none of the other packages you mentioned have anything to do with steam (at least directly)

mint swift
# slender nymph you *have* to get the steam info from steamworks, and Steamworks.NET is one pack...

In this video I will be showing you how to get your unity project set up. How to host lobbies and how other people can join them. In the next episodes I will be going over how to display users, sync movement, create character cosmetics and much more. So make sure your subscribed to not miss out. :)

------Tutorial Links------
Mirror: https://ass...

▶ Play video
sonic dome
#

why does it not log anything?

slender nymph
#

presumably the errors are causing the code to not work

#

!input 👇 and stop hiding your errors

radiant voidBOT
# slender nymph !input 👇 and stop hiding your errors
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.

sonic dome
#

no errors here tho

slender nymph
#

is this even during play mode?

sonic dome
#

ni

#

wait

slender nymph
#

exactly

sonic dome
slender nymph
sonic dome
#

i dont see active input handling

#

where is it

slender nymph
#

you do know there's not only a search bar, but there's also several folded categories there, right?

sonic dome
rocky canyon
#

it is in there..

sonic dome
#

and even the search bar leads to player

slender nymph
#

yes, and inside the Player settings which you are looking at, you have FOUR folded groups of settings

rocky canyon
#

maybe in "Other" settings.. i wonder..

#

maybe in some of those other Menus that u havent expandded yet

sonic dome
#

okay i see

#

okay its restarting

#

thanksssssssss

grand snow
#

its interesting how many people now have this input issue but glad they still changed the default

sonic dome
#

the gravity feels really bad

#

any suggestions on how i can make it right

hot wadi
#

How are u applying it?

sonic dome
#

i made the default grav to -18 from -9.8 in project settings

#

feels right i suppose

#

what even is this

hot wadi
#

-9.8 is the real world gravitational acceleration.
It may fix your problem for now but may cause more issues if u want the game world to obey real world physics

sonic dome
#

noted

#

why m i getting these weird errors

hot wadi
#

A texture in your project does not have the imagery data to render

sonic dome
#

it was working a sec ago

#

i dint touch any textures

hot wadi
#

I think this is the editor problem

sonic dome
#

nvm it was the editor

#

i restarted

#

works fine now

#

thanks

fringe crypt
#

Damn, i got hacked by someone

#

Sorry guys if in this group got spammed

fresh panther
#

I've been trying to fix this problem for 6 hours.

rich adder
hot wadi
#

Looks like a common issue for new editor version?

fresh panther
# rich adder what did you try to fix it
  1. Install different versions of unity
  2. Search on the Internet
  3. Run the program as an administrator
  4. (What did you regret) ask the AI
  5. Deleted the library folder
    I don't remember what else I was trying to do.
fresh panther
rich adder
fresh panther
rich adder
fresh panther
rich adder
#

You tried a plain ol PC restart?

fresh panther
#

yes

fresh panther
rich adder
#

and which versions did you try

fresh panther
fresh panther
hot wadi
#

It's likely tied to Visual Studio. Even if u install different editor versions

rich adder
#

what is "all"

fresh panther
rich adder
#

hmm then idk most likely something wrong on your PC... maybe permission issues or something not launching.. Check the logs and see what they say exact

#

!logs

radiant voidBOT
# rich adder !logs
📝 Logs

Documentation

Editor logs

Windows: %LOCALAPPDATA%\Unity\Editor\Editor.log
MacOS: ~/Library/Logs/Unity/Editor.log
Linux: ~/.config/unity3d/Editor.log

Unity Hub

Windows: %UserProfile%\AppData\Roaming\UnityHub\logs
Mac: ~/Library/Application support/UnityHub/logs
Linux: ~/.config/UnityHub/logs

rich adder
#

you want to check "Editor logs"

#

if its too much stuff you can delete them, initiate another error then check logs so you get a more "clean slate"

fringe crypt
rich adder
#

I'm on mobile lol I aint downloading all that.. check it and see any indications of issues with more recent timestamps to when you launched it

rich adder
#

did you tag yourself to say "hi" to .. wat? also no offtopic

hoary tangle
#

no it said on the green leaf next to my name to say hi

#

when I clicked it, it tagged me

#

then I addded hi

#

because it told me to say

#

hi

#

so that was why i

#

did that

rich adder
#

we can do without the spam

fresh panther
hoary tangle
#

I usally like type many messages because I remember what I should say after I've typed done already

rich adder
hoary tangle
#

ok

rich adder
hoary tangle
#

How do I make a simple movement system that doesn't glitch thru thin walls?

When I made my movement system a long time ago, I just went into walls and kept glitching out when walking against them.

How do I make an actaul good one? Just W = Forward, S = Backward, D = Right, A = Left and Space = Jump.

rich adder
#

making the colliders move proper

hoary tangle
#

What do you mean by that Nav?

#

I used the bean looking cylinder ish collider

rich adder
#

making sure the character is moving respecting physics

grand snow
#
  • moving via physics instead of direct translation
naive pawn
hoary tangle
#

Yes the capsule collider

hoary tangle
rich adder
#

so did you put a rigidbody and move it with its velocity

grand snow
rich adder
hoary tangle
#

I just did playervector + vector3(1, 0,0) or something like taht

twin pivot
hoary tangle
rich adder
#

well you're skipping the physics, you're not gonna get proper collisions

grand snow
rich adder
#

colliders are physics

hoary tangle
hot wadi
rich adder
#

translating / shifting the object's position in 3D space without altering its orientation or size

rich adder
#

there ya go ^

hoary tangle
#

Thanks I will look at that

#

That seems logical

#

Okay now I know

#

How do you use forces then in Unity 6?

hot wadi
#

Someone said it with more details, but I'm just gonna list the methods u can use:

  • Use a dynamic rigidbody and AddForce()
  • Use kinematic rigidbody and set the velocity instead or MovePosition()
  • Use character controller and Move()
rich adder
#

MovePosition does not respect colliders

#

other physics bodies will respect it, and its motion but not other way around

eternal blade
#

in the tutorial FPS micro game the hints show a hand,, that is in unity 2020, i have unity 6.2 i cant seem to progress its not clear what to click on,, the animation shows clicking on the hand,, which is now the pan tool i think but that does on unstick the tutorial

rich adder
grand snow
rich adder
hoary tangle
#

I responded to the wrong person

#

Now it's right

rich adder
grand snow
naive pawn
hoary tangle
hoary tangle
#

Okay thats is good to know

rich adder
#

thats why most character controllers are kinematic, you usually wouldnt want everything hitting your player pushing it

#

moving platforms, etc. all very viable for kinematic bodies

hoary tangle
#

Or do you mean it's very viable because you can move the player on your own with code, and simulate the physics better that what the dynamic rigidbody would do by itself?

rich adder
hoary tangle
#

What is Global Volume object in the unity explorer?

rich adder
#

similar to just using translation but its "physics conscious" and other bodies respect it

rich adder
hot wadi
# hoary tangle What is the diffrence between a kinematic rigidbody and a normal rigidbody? Doe...

Well, dynamic is just like real world objects. It obeys physics and interacts with other body types by default
Kinematic is like a blank canvas that lets u enable certain physics interactions by your own rule
For example, if u throw a dynamic rbody at a kinematic body, it won't push the kinematic body unless u let it to
But if u push a kinematic body at a dynamic body, the dynamic body will automatically react to that force

hoary tangle
crimson canopy
#

https://www.youtube.com/watch?v=pYEAwiKFKeg
following this tutorial because its the easiest one ive found on offscreen indicatiors, but im stuck around the 7 minute mark where he says to use an edge collider 2d on your camera, because he is working in a 2d project
i would need the edgecollider to have a space to spawn my indicator, but im not sure what the 3d equivilent of this would be, as far as i can tell using the edge collider 2d in 3d does not seem to work very well if at all when im trying to attach it to the camera view
does anyone have any further resources on this or another way i should be doing this?

Support me On Patreon : https://www.patreon.com/the_game_guy
It'll mean alot to me 💖

In this video i will show you how to make a simple indicator that will point towards the enemies (or any other gameobject) outside the camera view so we can know where the enemies are coming from.

and there are a lots of ways to go about doing the same thin...

▶ Play video
rich adder
#

huh you probably dont need colliders for this

#

You should be able to just check if an object is outside the bounds of screen / camera

hallow acorn
#

guys how hard is it to rewrite an algorithm i took days to make using c# so it works with a compute shader? how much time did i waste?

hot wadi
#

Depends on its complexity

#

As long as u learn something. Otherwise, if u just need something that works, find a tutorial

hallow acorn
hallow acorn
crimson canopy
#

in the tutorial he casts a ray from the object to the player and when the ray crosses the collider he uses that point to spawn the indicator

rich adder
crimson canopy
rocky canyon
#

another way to do screen indicators
is by using a regular canvas and converting the worldspace -> ui-space

rich adder
rocky canyon
#

i haven't implemented the off-screen portion yet tho

rich adder
#

You can use Mathf.Lerp to get a point between two points Ie (left corner to right corner etc.) and see where the object is between that

crimson canopy