#đŸ’»â”ƒcode-beginner

1 messages · Page 558 of 1

obsidian plaza
#

ur movement shouldnt even be here

gentle herald
#

the movement shouldn't, be in the camera?

obsidian plaza
#

not the character movement

#

i mean idk i dont do 3d

gentle herald
#

Welp time to make a character

obsidian plaza
#

thought there was one..

gentle herald
#

I was trying to avoid it bc I'm too lazy to have to model a character

obsidian plaza
#

friend lets try to code pong without the ai first

earnest wind
#

why when i try to change values in anything

gentle herald
earnest wind
#

it unchecks

obsidian plaza
gentle herald
#

No, I refuse

#

I'm like it little fucking kid

obsidian plaza
#

what

gentle herald
#

I just wanna get to the fun stuff

polar acorn
gentle herald
#

Only reason for this game is bc I wanna make it vr, but first I'm making it pc

#

reason for it being vr, to force my parents to buy me a quest

obsidian plaza
#

and u can do it with ai and asking everyone in here to fix the code without learning

gentle herald
#

OFC

#

how did I not think of that before

#

Oh god am I fucked

#

Welp I'm gonna go make the character

#

any recommendations on a character maker?

obsidian plaza
#

lol

echo crater
#

Do you know why it counts 1 two times ?

obsidian plaza
#

brother google how to screenshot

echo crater
#

I don't have discord on pc

obsidian plaza
analog elbow
#

I'm in the middle of a refactor, and in so I've renamed my old classes and started rewriting them. In my IDE I can set those old classes to no longer compile but Unity seems to override that. I still need to reference them until the refactor is done but they are throwing errors now due to the new code so I can't test. Any way to set them to not compile without changing them to text files or something?

echo crater
#

In the update method, when isGrounded=true

#

With physics raycast

obsidian plaza
#

so is the code detecting midair jumps?

echo crater
#

Yes, for now, I want for it to count to 2, for double jump. I can make it work if I set maxJump to 1, but I want to be able to set maxJump to two, I just need to make the jumpCount be 1,2,3 and not 1,1,2

#

I don't know why that happens

obsidian plaza
#

its probably being set to 0 the frame after u jump

#

or

#

actually

#

when is jump performed done?

#

just perform the jump after the check

echo crater
obsidian plaza
#

yes

obsidian plaza
#

i cant remember exactly how update works rn idk

lucid quiver
echo crater
#

Yeah... It's fixed now, I just had to move the isGrounded check to the jump performed instead in the update. Thanks a lot!
Sometimes I forget that update works frame by frame, maybe if I had the check in fixedUpdate it would work, but it works like this aswell

obsidian plaza
#

awesome

obsidian plaza
#

but yea

echo crater
#

Honestly, I thinking fixedUpdate and lateUpdate wouldn't work either way, because one is frame independent and the other comes after the update, and jump_performed is it's own method, so I don't if it does it's thing before or after the update, but it seems like it does before the update

languid spire
mighty compass
#
    void moveTowardsClosestBuilding(){
        if (currentObjectFocus == null){
            allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>();
            float prevDist = 0;
            float dist = 0;

            for (int i = 0; i<allObjects.Length; i++){
                dist = Vector3.Distance(transform.position, allObjects[i].transform.position);

                buildingProperties = allObjects[i].GetComponent<BuildingProperties>();

                if (buildingProperties != null){
                    if (dist <= prevDist || prevDist == 0){
                        prevDist = Vector3.Distance(transform.position, allObjects[i].transform.position);
                        currentObjectFocus = allObjects[i];
                    }
                }
            }
        }

        if (currentObjectFocus != null){
            pointToMoveTowards = currentObjectFocus.transform.position;
            directionOfTravel = pointToMoveTowards - transform.position;
            directionOfTravel.Normalize();
            // Movement
            distanceToCurrentBuildingObject = Vector3.Distance(transform.position, currentObjectFocus.transform.position);

            if (distanceToCurrentBuildingObject > 4){
                transform.Translate(directionOfTravel.x * speed * Time.deltaTime, directionOfTravel.y * speed * Time.deltaTime, directionOfTravel.z * speed * Time.deltaTime, Space.World);
            }
        }
    }

    void destroyBuilding(){
        if (currentObjectFocus != null){
            if (distanceToCurrentBuildingObject <= 4){
                buildingProperties.buildingHealth -= attackDamage;
            }
        }
    }
}
``` For some strange reason when the enemy gets within attacking distance of building, crashes and says no instance is assigned to the line where the building takes damage in destroyBuilding()
#

I am quite sure there is an instance assigned

languid spire
#

so buildingProperties is null

obsidian plaza
#

nah unity must be wrong

#

hes sure

mighty compass
#

lol

languid spire
#

debug it and find out instead of just assuming you are right

mighty compass
#

it would only be null if the building blck is destroyed in it's script before the last call of that function

#

which shouldnt happen, because the currentObjectFocus is a reference to that same object, so if it was destroyeed, the function wouldnt execute anyways

#

ill just debug it

languid spire
mighty compass
#

that part of the script only executes if the currentObjectFocus is null

#

so if the block was destroyed and it was finding a new block

obsidian plaza
#

y not debug

#

hard to have a convo

olive galleon
#

Isn't there a term name for when one script only does one thing? I can't recall it

lucid quiver
#

ya

mighty compass
#

yeah ill debug, a bit confusing to look at my code xD

languid spire
mighty compass
#

not documenting it very well at the moment because im just trying to pump out funcionality lol

mighty compass
echo crater
echo crater
#

Thanks ! Really helpful, might even print it so it's always next to me xd

languid spire
#

imprint it into your brain, it will save you hours of heartache

mighty compass
#

veteran

languid spire
mighty compass
#

lol

errant rock
obsidian plaza
errant rock
lucid quiver
lucid quiver
#

make a terrain object

north kiln
foggy osprey
#

Hey, I'm stuck on the Unity lobby service idéa where you add a scroll view to list all the lobbies. I'm wondering if somebody could possibly help me with that?

mystic lark
#

why isnt this scoreIncriment++ working do i need return value or smt its my first time working with coliders

obsidian plaza
#

r u looking in the inspector

#

and the value doesnt increase?

mystic lark
#

to add 1 when it colides

wintry quarry
mystic lark
obsidian plaza
#

so ur just watching the inspector

#

ok

wintry quarry
#

Add Debug.Log to make sure the code is actually running

mystic lark
wintry quarry
#

Show us

obsidian plaza
wintry quarry
#

You're looking at the inspector for the wrong object then

obsidian plaza
#

and show the inspector of an object its colliding with

obsidian plaza
wintry quarry
obsidian plaza
#

so the code is logging

#

but value isnt going up

mystic lark
mystic lark
wintry quarry
#

And which object is the script on

mystic lark
#

the ball

#

see i added debug and every time the ball colides it prits one

#

nut doesnt incriment

obsidian plaza
#

lol

wintry quarry
#

You're literally printing 1

obsidian plaza
#

Debug.Log(scoreIncriment) maybe

wintry quarry
#

What else would it print

mystic lark
obsidian plaza
#

r u fr

wintry quarry
#

Print the actual value of the variable

#

I understand what you're trying to do

mystic lark
#

i dint understan u sorry wait sec

wintry quarry
#

You need to debug your code, which is what I'm helping you with

mystic lark
#

it dubgs 1 but in the inpector it doesnt change

#

and it shuld be like 1 then 2 the3 exc

obsidian plaza
mystic lark
#

no

#

shuld i set it to 0?

obsidian plaza
#

nah

wintry quarry
#

Is the ball getting destroyed

#

Is the scene getting reloaded

#

Etc

mystic lark
#

no and no

obsidian plaza
#

cursed project i think

#

start over

#

get a priest

wintry quarry
#

Show us the full script

mystic lark
#

lmao

wintry quarry
#

!code

eternal falconBOT
mystic lark
#

wait

wintry quarry
#

Also set the variable to Private

#

There's no reason it should be public and you might have other scripts changing it by accident

mystic lark
obsidian plaza
#

show all ur objects as well

wintry quarry
#

You have a compile error

#

And again please don't use screenshots.

wintry quarry
mystic lark
obsidian plaza
#

comment it out then

mystic lark
mystic lark
wintry quarry
#

Yep, another script was doing it right?

#

This is why public variables are a bad idea

mystic lark
mystic lark
glossy blaze
#

whats serialze field for?

earnest wind
mystic lark
#

why wont this work i have the tag ball on the object but i dont know why it isnt taging

swift crag
swift crag
#

When a field is serialized, Unity will:

  • show it in the inspector
  • save the value in the scene (or in a prefab)
#

Serialized fields are used to configure your components. You can give different enemies a different amount of health, for example

#

Public fields get serialized automatically, but you have to explicitly tell Unity that you want to serialize a private field

#

So, fields that only have meaningful data while the game is running should not be serialized

mystic lark
swift crag
#

well, look at what Collision2D gives you

#

have you looked at the documentation for that class?

mystic lark
ripe shard
swift crag
#

One nuisance about the names...

#

rigidbody is the thing you banged into

#

otherRigidbody is your own rigidbody

#

how silly

ripe shard
#

it would be confusing no matter the name

swift crag
#

I'd have settled for ownRigidbody or something

ripe shard
#

but that presupposes ownership

swift crag
#

a collision occurs between two things, one of which is notified about the collision

#

that's enough of a "self" for me

ripe shard
#

But what if both are

mystic lark
swift crag
#

one is notified at a time :p

ripe shard
#

yes but you can’t make it not confusing

mystic lark
#

i thoutgh its a variable

#

but colider and collision isnt same

#

you know what i mean

#

anyway thanks

swift crag
#

ah, yes, people mix up the two pretty often

ripe shard
#

you still have to know which is the ‘owner’ and which is the ‘other’

swift crag
#

Collider2D is a kind of component. Collision2D is an object with some information in it

swift crag
#

I presume it doesn't pass the exact same values to both sides of a collision. That would be a nightmare. You'd have to check whether the thing you hit is rigidbody or otherRigidbody

ripe shard
swift crag
#

"the other rigidbody" explicitly sounds like it's referring to...well, the other one

ripe shard
#

there is just no way to solve that kind of situation with names

swift crag
#

and the other is obviously not ourselves

#

i think it's significantly better than the current naming

ripe shard
#

and nothing here is ‘obvious’

swift crag
#

yes, because the names suck 😛

#

otherRigidbody is a mental speedbump every time I see it

ripe shard
#

well, just telling you that other people see things differently

stuck seal
#

can give some advice? im following a tutorial but ran into a problem that googling and chatgpt isnt helping on, when my character touches a wall, he starts jittering all over the screen and flipping upside down, can you check my rigidbody/collider/controller and see if you can spot whats wrong? 🙂 thank you so much

#

AI said that I dont need a rigidbody on a character controller on the same object, but i dont see where in character controller it would deal with collisions otherwise...?

rich adder
stuck seal
#

when i turn off rigidbody it stops detecting if i hit the wall

rich adder
#

rigidbody needs a collider

stuck seal
#

so i need neither my collider NOR my rigid then since i have my character controller

#

right?

rich adder
#

you pick whiever controller you want to use

stuck seal
#

so then... why can i not detect collisions then..?

rich adder
#

detect which collision?

stuck seal
#

i have an OnCollisionEnter with my blocks around my character so that when he hits them they change color and a log is printed

#

but with JUST character controller, nothing happens

something only prints and detects a hit when i have both sphere and rigidbody on

rich adder
#

OnCollisionEnter will not work with CC but there is also a replacement

stuck seal
#

oooooooohhhhh

rich adder
#

or more reliable you use physics casts

stuck seal
#

in C# its called physics casts?

#

oh i see the doc

#

oncontrollercolliderhit!

rich adder
#

raycasts and alike

stuck seal
#

hmm, thats a bit over my head

#

so am i editing my C# code to use OnControllerColliderHit?

rich adder
#

if you want CC replacement for OnCollisionEnter

#

CC works with triggers only besides that

rich adder
stuck seal
#

so.. i wont lie.. now im even more confused then

#

im looking up all this other documentation and youre giving me physics stuff to look up, but i really just dont understand what i need to do to fix this problem

#

i think youre speaking way above my level

#

sadly

rich adder
#

As I said you can either replace your OnCollisionEnter function with the one I sent that is for CC only, OR use the Physics class to use for example a cast, to detect whatever it is you're detecting

stuck seal
#

new settings using your method suggestion

#

still nothing sadly

#

deleted rigidbody and went with CC

rich adder
stuck seal
#

all the surrounding cubes i can run into,

rich adder
#

thats wrong, thats why is not working

#

script goes on CC

#

because its a CC function

#

hence the name

stuck seal
#

the cube is the thing im going to make reset the character though

#

and each cube i hit would do something different

#

so what would i attach to the cube

#

okay cool, so now i print out everything the player touches

#

which is another thing ill prob do later

#

for footsteps or whatnot

rich adder
#

can just make the script detect the cube and from there you get whatever function from it

#

you can access whatever components you might add on Cubes

stuck seal
#

is that the more common way to do it? track what the player touches and update things as it goes?

what if i like, shot something though or hit it with an arrow

rich adder
#

each script you add is a component , cleaner to have a script handle specific features and nothing else

stuck seal
#

hmmm, well i got now to print out whatever my main character is on at every second

#

thank you 🙂

#

but still when things hit my cube it doesnt do anything aha

#

to any script i attach to the cube

rich adder
#

what do you want it to do OnCollision with Cubes?

stuck seal
#

simply i just want it to print something to the log, i just want it to be able to detect, from there i can probably figure things out

#

but the cube will just not. detect. anything.

rich adder
#

why would the cube detect anything ?

stuck seal
#

because thats the homework assignment im trying to follow....

rich adder
#

what is the assignment because sounds like you ain't following the instructions correctly then

stuck seal
#

okay, cool man

#

thanks for your help

wispy coral
#

is there a way to make rigid bodies go up stairs? if i add a character controller it flies up to space so idk how to do it

rich adder
#

you cant mix rb with cc

wispy coral
#

alrighty got it

frosty hound
real hearth
#

I've got a system to place Building objects on a planet; they're not allowed to overlap so at the moment I give them all colliders and the one I am trying to place has a ColliderChecker script which just has a bool which is true if it's colliding and false otherwise. I feel like there might be a better way though?
(Also if I want to place buildings instantly, does OnCollisionEnter fire immediately, or with some delay? E.g. placing buildings for an AI or placing them procedurally at the start of the game)
Thanks

hot lily
#

For a semi realistic shooting game (ie not CSGO kind of arcade), should I do hitscan or use actual projectiles for gunfire?

#

For instance simulating tank gun fire like War Thunder

echo ruin
ripe shard
real hearth
ripe shard
#

It’s not wrong to use scripts with OnTrigger callbacks, just more spread out and annoying to deal with. Sometimes unavoidable.

#

Trigger callbacks fire on the next physics frame.

#

In placement systems you often have to do some trickery to have all the triggers fire correctly and in a way you want them.

real hearth
#

Makes sense, thanks!

echo ruin
hot lily
#

Right

#

Fuck I've been led in circles by AI, should've just stuck with what I knew

burnt vapor
#

You should not ask it on what is best

hot lily
#

As I now realized in the hard way, yes

burnt vapor
#

If you're a beginner programmer you should not even touch AI

#

Learn by doing, ask actual people for help

ripe shard
# burnt vapor You should not ask it on what is best

hehe, you get in trouble asking people for what’s best too, just on a larger scale. Everyone should aim to be able to recognize for themselves what’s best. But that seems to be a lost art. #tutorialculture

robust condor
#

Not even senior devs know what is "best", or they wouldn't need to rewrite software and refactor all the time

naive pawn
#

the trick is there generally is not a "best"

echo ruin
#

Some AI can be good to ask for guidance. Not specifically what’s the best approach, but more “What are the pros and cons using X over Z” and then determine yourself

robust condor
#

Ask the AI "what are my options" and it will show you a pro/con list and you can evaluate yourself

pliant robin
#

whats the best way to learn all the unity syntax

#

not rlly syntax but the operations and stuff like that

echo ruin
robust condor
#

@pliant robinBy developing and keep making games

#

You only deep dive when you run into problems

pliant robin
#

yes but im about as beginner as they come

robust condor
#

Do some of the unity tutorials

naive pawn
#

learn c# syntax, and unity apis

echo ruin
# pliant robin not rlly syntax but the operations and stuff like that

Ask “What are are some simple ways to move an object in a 2D Unity game using components and scripts?”
It will give you basic, advanced, and more alternative operations. Then you put a promt like “Can you give me some simple tasks to implement movement by script in a 2D Unity game?”.

That’s an efficient way to be specific and also let the AI help you learn

pliant robin
#

thats a rlly good idea

naive pawn
#

i don't think that first one will be very consistent, or even useful, in the long term

#

genais hallucinate, that's their entire thing
use it to your advantage, asking it to generate ideas, not answers

echo ruin
naive pawn
#

but you can't control the ai being good at giving truthful answers

echo ruin
#

The tool doesn’t do the work for you, you learn how to properly implement the tool.

robust condor
#

@naive pawnI have had great success at code generation, you just have to review it, and make tests

naive pawn
#

honestly movement in games just boils down change position, change velocity, or change acceleration

echo ruin
naive pawn
naive pawn
robust condor
#

@naive pawnNo, they should ask "explain this code step by step" etc. and run it and see if it works

naive pawn
#

i don't deny that genais are tools; but they're tools that kinda masquerade as doing more than they really do
that's a pitfall for beginners

naive pawn
#

and just because code works does not mean it's good code

robust condor
#

Not really, depend what AI you use, some are good at breaking it down

echo ruin
#

Probably not. If you use it to do your homework, you wont learn anything. If you use it to help teach you, it can be an amazing tool. It’s tempting to have it be the first option

naive pawn
robust condor
#

Not always

naive pawn
#

no that's literally how LLMs work

robust condor
#

Mm not really, they pull from a knowledge base and when they cant find the knowledge they make it up, kinda lika humans do

naive pawn
naive pawn
robust condor
#

No, the knowledge base is the trained data

echo ruin
robust condor
#

Gen AI does not read documents on the fly from somewhere

hot lily
#

(which to be fair the bullets would do sth like 1000m/s, but probably lower in reality)

naive pawn
robust condor
#

I used AI to write 700 tests because I could not be bothered to do it, I just reviewed the code, so it's not hallucinating it

naive pawn
#

it is hallucinating. that's how they work

#

sometimes the hallucinations are right

#

fwiw, the general consensus throughout every support server and platform ive seen, including this one, is to not recommend genAI because of its pitfalls.

robust condor
#

It's a tool, it's about how you use it

#

I don't trust a PR by a junior dev either

#

Without reviewing

eager spindle
#

it's a "tool" that misleads people and beginners can't tell if it's hallucinating useful code

naive pawn
#

and do you think a beginner will be able to accurately review

eager spindle
#

don't recommend genAI to learners

naive pawn
#

it's only a useful tool when you know how to look past the hallucinations and how to verify answers correctly
that's not what a beginner is

hot lily
#

Never trust anything 100% is what I get from the AI

eager spindle
#

we have been on this many times already

hot lily
#

Although I am using the AI pretty much "don't trust the AI too much and you should research with it as a semi guideline"

cloud matrix
#

in my 3d movement after i let go of a key, it slides that direction for like a split second more, any way to fix it?

obsidian plaza
#

ai has helped so much for me especially in creating math equations and also for complicated c# docs

eager spindle
#

Works exactly the same as Input.GetAxis without the smoothing

naive pawn
#

bold guess..

naive pawn
#

damn

#

that couldve been a lot of things thonk

eager spindle
cloud matrix
eager spindle
#

so it gives you the equation that person has made

naive pawn
#

lmao

naive pawn
eager spindle
obsidian plaza
#

it can definitely do math

naive pawn
obsidian plaza
#

its probably the best at math over anything

naive pawn
#

not genAI

eager spindle
#

It's nice that this input smoothing comes right out the box but I dont need it

robust condor
#

@eager spindleSome AI can learn by reading actual code then apply it, I tested this throughly where the AI was not able to undertand a library API by itself before I fed it custom docs

eager spindle
#

🎊

cloud matrix
#

im mkaing a google doc of the very few scripts ive successfully made so i dont gotta struggle w this in the future

eager spindle
#

I'll just speak from personal experience, I had to implement playfab backend in a project recently

naive pawn
eager spindle
#

Playfab's story: it's a backend service providing User Auth, data storage and other things

robust condor
#

@eager spindle

eager spindle
#

It got bought over by Microsoft in 2018, and Microsoft deleted all the docs and moved it to their own page

cloud matrix
#

is ai even that reliable for scripting?

eager spindle
cloud matrix
#

i rememebr i used to use it and i had to tell it to fix its code so much

naive pawn
eager spindle
eager spindle
#

It was completely useless

naive pawn
eager spindle
robust condor
#

@eager spindleIt could have run out of context length

eager spindle
#

AI does not

robust condor
#

AI doesn't know everything it's not e god

eager spindle
#

AI doesn't know the intricacies of Input GetAxis Vs Input GetAxisRaw

naive pawn
#

GetAxisRaw removes the smoothing towards the input as well
so if they wanted that, but an immediate stop, that would work

eager spindle
naive pawn
grim leaf
#

Anyone knows how to make a child position independent from Parent Position? I have my player prefab with an extra camera for respawning (when the player dies the camera switches to one looking at the map from the sky). The problem is that i have to put the spect camera as a child of the player or i cannot add it in the serialized field of my player's code (bc it is a prefab) and doing that the camera moves with the player... I need its position to be fixed. Any ideas?

robust condor
#

Also there is less code in game dev to train on that web dev, much less

#

@eager spindleNo, you need experience

eager spindle
#

You can make a camera controller scirpt

naive pawn
eager spindle
#

Also if you make the camera a child of the player, if the player rotates then the camera will rotate too

grim leaf
eager spindle
#

Depending on your game that might not be desireable

naive pawn
eager spindle
#

Also those are all prefabs

naive pawn
#

of course

#

there was a link for this

eager spindle
#

Unity huh how?

naive pawn
#

i think so yeah

naive pawn
grim leaf
#

I need to assign the spect camera to switch between the two

naive pawn
grim leaf
naive pawn
#

that doesn't give me any useful info to solve your problem

#

you're getting more specific

#

i need a broader view

grim leaf
#

alr one sec

naive pawn
eager spindle
grim leaf
eager spindle
#

also I'll make this very convenient: you can get the main camera by using Camera.main

austere ice
#

need advice

is it possible to make a command prompt like things (not a console dev or smth like that, but a things that similar to a CLI in linux) in a platformer game?

eager spindle
#

lethal company made one

grim leaf
austere ice
eager spindle
#

as long as you know how to use TextMeshProUGUI and TMP_Input you can definitely do it

#

if you'd like to I can make a tutorial on it

#

it'll take a while before it comes out though

cloud matrix
obsidian plaza
#

its being set to 12 properly like ur code says from what i can see

lucid quiver
#

check if u have initialized them somewhere in script

cloud matrix
#

ohh i forgot to change the ones under too nvm sorry

#

also in the crouch feature is there a way to make it smoothyl come up instead of just snap back to the default scale

#

is there a variable i could use or sum

lucid quiver
#

but for small changes like this its probably easier to use a delay buffer

cloud matrix
#

ohh alr

#

thank u

lucid quiver
#

also i am assuming ur talking about the full collider being restored to default position and not just the animation

cloud matrix
#

yeah yeah

austere ice
# eager spindle if you'd like to I can make a tutorial on it

really?? I've been stuck here. I have a final semester assignment (group assignment) to make a game. My friend wants to make a 2d platformer game with a cyber security theme, the goal is to educate the players (students). He wants to combine a command prompt like thing into 2d platformer like i say earlier. But we have zero experience in unity.

tough tartan
#

been following this video and i need this for my final project https://www.youtube.com/watch?v=gPPGnpV1Y1c&list=PLGUw8UNswJEOv8c5ZcoHarbON6mIEUFBC&index=2 around 13:55 in the video and i got these errors

The second video in the Lets Make a First Person Game series!
🖐In this video we are going to setup the foundations for our interaction system.

Come Join us on the Discord!
🎼 https://discord.gg/xgKpxhEyzZ

💚 Thanks for watching!

Helpful Links
https://dotnettutorials.net/lesson/template-method-design-pattern/

▶ Play video
obsidian plaza
tough tartan
tough tartan
obsidian plaza
#

show your script

#

basically whats happening at least with the top 2 is that there are 2 namespaces that have the same definition

#

so you need to clarify to the code

#

about which one you want

tough tartan
#

player interact

obsidian plaza
#

oh wait

#

you have 2 scripts called PlayerInteract?

#

and 2 scripts called PlayerUI

tough tartan
#

player ui

tough tartan
#

oh it duplicated it when i transferred into a folder

obsidian plaza
#

yea

#

its helpful to learn to read the error messages btw..

tough tartan
#

thank u thank u

tough tartan
obsidian plaza
tough tartan
#

no

cloud matrix
#

how i play an animation when im walking

obsidian plaza
#

lol

obsidian plaza
# tough tartan no

make a new script and copy everything inside the old script over, but not copy the public class line at the top

tough tartan
#

i fixed it

obsidian plaza
#

k cool

tough tartan
#

if i have a unity file connected to the cloud is there a way for me to download it on a different device since it isnt showing up on that devices unity hub but is connected to cloud

lucid quiver
#

So I updated to the new version of unity recently and while working on a project I noticed that Cursor.lockState=CursorLockMode.Locked and Cursor.visible=false both take an initial click on the game window to get focus everytime I enter play mode, even while on Play Focused. I found this to be a "new feature" of the unity version but i was wondering if there was a way to bypass this since everytime i even pause the screen, it takes an extra mouse click after unpausing to refocus.

hearty trout
#

how to I make my player not collide with enemy during dash

lucid quiver
vocal orchid
#

Why the coroutine is stopping?

obsidian plaza
#

what

vocal orchid
lucid quiver
hearty trout
#

so like

#

if(other.gameObject.CompareTag("enemy"){

#

then that?

obsidian plaza
vocal orchid
obsidian plaza
lucid quiver
lucid quiver
hearty trout
#

then i will make it true after set amount of time so like i put under it 5 -= time.deltatime if 5 = 0 set it to true? for example

vocal orchid
lucid quiver
obsidian plaza
#

what you need to do is set it as a variable

#

or make an if check before starting again

hearty trout
#

oh

#

thats a bit of a pickel

lucid quiver
#

and turn it back when ur reseting the collider

hearty trout
#

got it so like

#

rb.gravity = 0

#

and after the timer

lucid quiver
#

yes

hearty trout
#

rb.gravity = 1

#

ty

lucid quiver
lucid quiver
lucid quiver
# hearty trout rb.gravity = 1

for Rigidody2d its gravityScale which is directly the scale but for Rigidbody (3d) its rb.useGravity =false cuz its a boolean

ivory bobcat
lucid quiver
ivory bobcat
#

You'll get unwanted behavior in the Editor as escape key removes focus on the app in the Unity Editor

#

It's not anything new.

#

This has always been a thing.

#

Use a different button for testing in the Editor

lucid quiver
#

damn it didnt cause me trouble in the past .. but maybe that was because i use it as an input from the input manager

#

this shouldnt be a problem in build tho right?

ivory bobcat
#

Yes, it'll not be a problem with the builds

lucid quiver
#

okay ty

grand snow
#

I think ESC always has unlocked the mouse in editor

lucid quiver
#

yes but even after i replaced ESC with some other key it still requires the initial click to focus the first time when u play which i dont remember being the case

#

I could be wrong tho so idk

swift crag
obsidian plaza
#

they know but its about saving time

steep rose
#

you would be "saving" a very minuscule amount of time

hearty trout
#

What the line of code to cancel ALL collisios cause rigidbody2d.detectCollisions = false aint working it just says error

hearty trout
lucid quiver
#

if ur using 2d then u have to get a referrence to the collider

#

for example

#

BoxCollider2D collider=GetComponent<BoxCollider2D>();
collider.enabled=false;

lucid quiver
hearty trout
#

oh ok

lucid quiver
#

there is another method to do it using Physics2D.IgnoreCollisions() but you would have to set up layer masks for that

hearty trout
#

ty

lucid quiver
burnt vapor
# hearty trout

Please configure your editor if you are having this issue. !ide

eternal falconBOT
lucid quiver
burnt vapor
#

If a user has to resort to checking the Unity console for missing signatures, it is a very good indication of a misconfigured editor

#

Because with a configured editor they would receive help before having to resort to compiling to trigger errors

#

It doesn't suddenly add the signature, if that's what you thought I meant

gentle herald
#

Any recommendations on good character creators for 3d games

steep rose
#

blender

serene barn
#

anyone knows a good inventory system tutorial or documentation?

lucid quiver
#

wdym character creator?

wintry quarry
swift crag
#

Yeah, inventories are up there with "ability system" and "quest system"

#

This is a valid inventory system

#
public class Inventory {
  public bool hasGun;
}
#

somebody, PLEASE! get this man a gun

lucid quiver
#

!code

eternal falconBOT
obsidian plaza
lucid quiver
#

ya just invest some time into learning blender man, it will help out in the long run

obsidian plaza
#

or just dont code in 3d cause 2d is superior

rich adder
#

this is a code channel

lucid quiver
#

just a quick question, is box cast better for ground check? i am used to just doing a raycast but I read on a thread that box cast is sometimes better

swift crag
#

A boxcast will more reliably find very spotty ground, I suppose

verbal dome
#

Raycast can go through a small hole

swift crag
#

imagine standing on a bunch of thin vertical slats

verbal dome
#

Sphere/Circlecast gives good smooth normals

#

If you need the surface direction, that is

timber tide
#

Usually in 2D I just use the collider methods and make a bunch of them for detection

#

stuff like that

lucid quiver
#

okay for the current project i just need a good enough check for a lumpy terrain so i am just gonna use boxcast

lucid quiver
swift crag
#

oh, right, this is 3D

#

I forgot that "boxcast" is a thing in both 2D and 3D

hot laurel
#

Hello, does anyone have comprehensive and detailed notes on the Asset Pipeline V2 that they could share? Most available resources seem outdated, inconsistent, or contradictory. The Unity documentation provides limited detail and is fragmented across multiple topics, making it difficult to understand the process step by step.
I’ve attempted to gather the information myself but lack access to the source code, and the stack trace offers little useful insight. Any in-depth resources would be greatly appreciated.
Anything would be good as long as it aligns with current execution of the Asset Pipeline.
For context, I’ve already reviewed Unity documentation across several versions, blog posts, and Unity Talks on YouTube about this topic.

swift crag
#

hm, is there something you're looking for in particular?

hot laurel
#

I am seeking detailed information about the Asset Pipeline, specifically what occurs step by step from the beginning of a refresh to its completion. I am currently developing tools for my game and need a deeper understanding to avoid potential issues with Unity's systems. The list of questions would be very long, so i would appericate if there is anyone who already dug in it deep and want to share his notes.

hot laurel
swift crag
#

this is just the order of operations, yes

#

there are more details on the specifics on the page..

hot laurel
swift crag
#

What sorts of questions do you have?

hot laurel
#

The list of questions would be very long, i will post it here after some time.

swift crag
#

You should come up with something concrete, yes.

hot laurel
#

I dont have simply one or few questions. Thats why i simply asked if someone have in-depth notes about this topic and would like to share with some begginer fellow. Also i like informations which are backed by some tests/ code/ stack trace, just something that proves it is right so there is no need to dig in to it again. So i expected that when i start spamming with questions i will simply receive links to docs or responses how someone feel or guess how it may work like. I would appericate if someone with in-depth knowledge of this topic DM me, so it will be possibble to avoid spamming this chat with people who are here to judge.

swift crag
#

People are going to be much less likely to help you if you ask for a very nebulous, possibly unbounded amount of information.

#

it's the same reason people are told "don't ask to ask"

hot laurel
#

indeed, thats why i asked about some in-depth notes of someone who already had to dig in to this topic.

#

so the question part would be skipped

naive pawn
#

So i expected that when i start spamming with questions i will simply receive links to docs or responses how someone feel or guess how it may work like.
you'll get links to docs or other resources when they're relevant. existing community resources are generally better than a single person's response
if you're getting opinions about how things supposedly work, that's just bad support, and this server is active enough to discourage that.

you won't know until you actually start asking. https://dontasktoask.com

rocky canyon
swift crag
#

The "in-depth notes" would be the existing documentation

rocky canyon
swift crag
#

I doubt that anyone has a secret encyclopedia they're hiding from the internet

#

Until you start giving us some context and asking pointed questions, I can't tell you much more than that

naive pawn
#

i mean "in-depth notes" can go a few different ways, right

  • it's from the author/maintainer - in which case, those notes are docs.
  • it's from a user, and the notes are public - in which case, those notes are docs, but separately hosted
  • it's from a user, and the notes are private - there's no guarantee of accuracy.
swift crag
#

I am also studying the importer system, because I am writing a number of tools that involve asset postprocessing (including some that I'm planning to publish!)

severe onyx
#

if I have a list of objects of a class how do I check of which type of inherited class any given entry is?

#

like, let's say I wanna list a bunch of "weapons" but I need to know if an individual weapon is of class axe : weapon or sword : weapon

verbal dome
#

Like using enums as weapon type identifiers, or making the child weapon class override the functionality of the weapon (or use an interface)

#

In what context do you need to know the type? What are you trying to implement?

severe onyx
#

I'm trying to pull from a pool of possible drops

#

the pool includes all classes that are dropable, but what happens on drop depends on the exact type of drop

lucid quiver
severe onyx
#

I guess I could try going for overriding a method now that I think about it

naive pawn
swift crag
#

spooky

severe onyx
#

ok this is all a bit much to process at once so Ill dig into it and see what I can make work

#

but thanks for the input

swift crag
#

is is very handy for downcasting

#

although I always get suspicious when I have to downcast

lucid quiver
#

i fell like this is too complicated for what little functionality she needed, wouldnt it just be better to add a getter method to the parent classes?

naive pawn
#

appropriately
yeah idk about that...

timber tide
#

is works fine

lucid quiver
#

i mean ... as long as she understands all the code its fine ig ..

severe onyx
#

rn Im thinking, there's an abstract method in the parent that I always gotta call when I want to make use of it - so I may as well have all children set an Enum to a value that represents their sub class so I can easily check for that later in code?

naive pawn
#

if you already have the class hierarchy, why not utilize the parent

#

polymorphism is a thing

naive pawn
#

typically, when you have a class structure like that and you want to implement behaviors that each child has slightly differently, you implement it on each child instead of having a centralized switch-case
the point of the hierarchy is to not have that centralized thing

timber tide
#

if everything is passed as something like an Item, you probably need to use Is assuming the behaviour splits somewhere in the derived classes such that Item -> Weapon has a method Attack(IEntity target)

#

But maybe something like a Use(IEntity entity) method could solve all and just not implement it in another Item type that is not Weapon

severe onyx
#

it's a drop, but there's a bunch of different types of drop (like health, an upgrade, or an unlock) that cause fundamentally different things to happen on pickup

#

I guess I should move from calling the pickup function on my Handler class to calling it on the object itself, so I can do another override

#

huh

#

that's neat

lucid quiver
severe onyx
#

yeah that was kinda my first idea

#

Ill keep experimenting a little

naive pawn
#

compare

void doAll(List<Parent> children) {
  foreach (Parent child in children) {
    if (child is A) {
      /* A logic */
    } else if (child is B) {
      /* B logic */
    } else if (child is C) {
      /* C logic */
    } else {
      Debug.Error("forgot something");
    }
  }
}
```vs```cs
class A : Parent { void doThing() { /* A logic */ } }
class B : Parent { void doThing() { /* B logic */ } }
class C : Parent { void doThing() { /* C logic */ } }

void doAll(List<Parent> children) {
  foreach (Parent child in children) {
    child.doThing();
  }
}
#

there's no risk of forgetting an implementation when you add a new object type, and each child is responsible for its own logic

severe onyx
#

I was kinda stuck on having it all happen centrally but it really doesnt need to be

naive pawn
#

you as the helper need to be more observant when someone is posing an xyquestion
you're answering their question, but not their problem
that's what i mean when i said it's not quite appropriate

severe onyx
#

I think, anyways

#

folks, I appreciate all the input

#

it can be a bit overwhelming but ultimately I should either be able to decide which suggestions help me or clarify further if Im unsure

#

that's my responsibility as the one asking

#

imho

naive pawn
#

if you're going to do the free work, then maybe put some effort into it đŸ€·
if you're too tired to do a good job, go get some rest

#

LMAO

#

yeah no

ivory bobcat
#

Take it to DMs please..

naive pawn
#

did you read the xyproblem website?

#

answering the question, when it's an xyproblem, is not very productive
there's been an entire convo about this exact topic a few days ago lmao 😂
the consensus is not gonna change

misty pecan
#

can anyone help me with problem its probably pretty easy to fix but i cant find anything online

naive pawn
#

!ask

eternal falconBOT
naive pawn
#

specifically that last point

#

noone can help you when you don't tell anyone what you need help with

misty pecan
#

i have an animation that just makes the players scale jump up and down for a jump, but having it enabled means i cant flip my character when hes walking either left or right

naive pawn
#

like the assumption that a beginner is asking about their actual problem, rather than an attempted solution?

lucid quiver
naive pawn
#

im not gonna engage in that any further

misty pecan
lucid quiver
obsidian plaza
#

trying to debug.log an error and i cant figure it out.. basically i have an array of sprite renderers but im going to their gameobject to find their image component. One of the obbjects is reporting not to have an image component, but when I look for that gameObject, it looks like it does

ivory bobcat
#

How to post !code

eternal falconBOT
obsidian plaza
#

its like 7 lines

#

and the rest of the screenshot is helpful

naive pawn
#

post them separately, it's a pain to read/copy/reference

obsidian plaza
naive pawn
#

thank you

#

have you tried debugging just box[i].name to see if it's the right object

obsidian plaza
#

they are all called box

#

lol

naive pawn
#

that doesn't guarantee that you dragged the right one in, or if it's changed at runtime

slender nymph
#

Use the context parameter for Debug.Log so you can click the log and have the relevant object highlighted

obsidian plaza
#

its logging from a manager script thats accessing the array though

ivory bobcat
#

Debug.Log($".. name stuff..", box[i]);

obsidian plaza
#

so it doesnt know what box[i] is does it

obsidian plaza
ivory bobcat
#

Selecting the message should highlight the object in the scene

obsidian plaza
#

gotcha i forget debug.log has these things

sharp abyss
#

How can I prevent the stutter effect that happens when weapons get in between limbs?I dont want them to get through.I know I can make weapons trigger but I want them to collide.

obsidian plaza
#

o yeah that already showed me something thank you

#

probably misclicked one of the 240 times

ivory bobcat
lucid quiver
lucid quiver
sharp abyss
#

I mean the thing happens when the weapon collides with other player

lucid quiver
# sharp abyss ragdoll shake

well ragdolls are notriously difficult to control but u could post the code here so people can check for any bugs

sharp abyss
#
using System.Collections.Generic;
using UnityEngine;

public class balance : MonoBehaviour
{
    public float targetRotation;
    Rigidbody2D rb;
    public float force;
    // Start is called before the first frame update
    void Start()
    {
        rb = gameObject.GetComponent<Rigidbody2D>();    
    }

    // Update is called once per frame
    void Update()
    {
        rb.MoveRotation(Mathf.LerpAngle(rb.rotation, targetRotation, force * Time.deltaTime)); 
    }
}
#

its on every limb

lucid quiver
sharp abyss
lucid quiver
#

make the colliders slightly bigger than the the limbs themselves

sharp abyss
#

I will try

#

no it didnt work

lucid quiver
sharp abyss
#

I tried also making swords heavier so it pushes the characters but didnt work

severe onyx
#

oh that's interesting

#

Im not entirely sure yet of all the needs I will have for the child classes, hence I cant say yet if this is viable for me

burnt vapor
severe onyx
#

rn Im running into the issue that unlike the class without any inheritances I cant actually fill in a List of the class on a ScriptableObject in the inspector anymore

burnt vapor
#

Note GetType return the actual weapon type and if you compare this against an inherited type, it will not return true since the types are different

#

I'd say an interface IFireable would be better here in which case it would implement the fire method, but that's my 2 cents.

#

You know, in case you have a weapon that doesn't fire for some reason

#

IWeapon might be more suited for an actor which purpose is being a weapon, but more as an indication that it can be wielded

#

That's my thought process, just wanted to share

#

Yeah, for example

severe onyx
burnt vapor
severe onyx
#

there's a manager who, like, creates pickupable objects that get filled with some reward. and I realised that instead of telling the manager what to do specifically with which type of pickupable (generate some random values on spawn, increment certain values on pickup) I can just tell the class itself that it was spawned or picked up and have all the different functionality happen in the override of the child

#

that's my solution as of now, anyways

#

still very much WIP

#

but the resulting code already looks a lot cleaner lmao

#

next thing to tackle will be how to create a pool from which to randomly choose a drop to spawn; as outlined earlier my previous solution of creating an SO that I just fill with values manually is not viable anymore, sadly

burnt vapor
#

You could use a weight system

#

It allows for rarity, but it depends on your use cases

spark sinew
#

hi y'all if I have a wireframe cube that I want to not display and display again, how should I do this ? Do I need to update all the time that I do not want to display it in the update part ?

#

(and also how do I not display it?)

lucid quiver
#

turning it off will make the object invisible

#

to do this u need to get the reference for the connected mesh rendered

#

and then do rendered.enabled=false;

#

and make it true when u want it again

spark sinew
#

ok thanks

#

also, another thing, when I get position updates once in a while to display an object, how can I make the motion smoother? are there some functions that can smooth the path of someting when you specify positions in an asynchronous way ?

#

I am using a lidar that gives position updates every about 0.15 s (but this also changes slightly), and is not very smooth

swift crag
#

There's no out-of-the-box interpolator component, but you could certainly use something like Vector3.SmoothDamp to smoothly move towards a target position

grand snow
severe onyx
#

they're not

#

I had a scriptable object that was basically just a list of drops

grand snow
#

How do you define/configure a drop?

cedar prairie
#

So i am making a little test game about going down a hill and because it has a rigid body and the floor has no friction the object gains speed. However this causes the object to have massive amounts of jitter after a certain point

grand snow
#

if drag/mass is semi realistic it should act in a similar way

cedar prairie
jade musk
#

Guys am 100% new to unity, can someone help me understand the basics?

#

I want to make 3d games

#

but I do NOT know how to do anything

grand snow
#

use animator states + transitions to do the animation changes

grand snow
#

something wrong with them? did you disable exit time, set the conditions and change the transition time? enabling the transitions to be interrupted may help too.

solar juniper
grand snow
#

you can see in the UI when it transitions and what anim is playing in edit mode so should be easy to figure out

lucid quiver
lucid quiver
#

here u have put it as "IsMoving"

#

change the case

#

it should work

#

or wait

solar juniper
#

I dont understand, they are both in upper case?

lucid quiver
#

my bad it is IsMoving

lucid quiver
solar juniper
#

all good

lucid quiver
winter wadi
#

I’m struggling with Unity Animator and transitions. I’ve set up the Movement animation with a Blend Tree for Idle and Run, but I can’t figure out how to properly set the transitions and parameters between Charge, Hang, Jump, and Wall Slide animations. I would really appreciate any help

solar juniper
winter wadi
#

newbie

lucid quiver
flint crane
#

(it is a .cs file not .txt)

lucid quiver
#

transform.localEulerAngles = Vector3.right * cameraVerticalRotation; well ur just telling it to move up and down

#

so thats what it is doing

solar juniper
lucid quiver
# flint crane ah shit

this needs to be

cameraHorizontalRotation+=inputX;
transform.localEulerAngles =Vector3.up * cameraHorizontalRotation + Vector3.right * cameraVerticalRotation;```
lucid quiver
balmy hearth
#

So i have the Problem that when i shoot at the player he is losing damage but i see his health and mine at the same time

robust condor
#

Has anyone calculated how many months you wasted waiting on compilations on script edits?

#

My project isn't even big yet and it takes a solid 1 minute

frosty hound
#

Buy HotReload and never have to wait again

#

At least until Unity 7 addresses it.

timber tide
#

This is why I never save my scripts

#

also kinda bogus that by default it'll recompile if you're running the game in the editor

#

like who wants that

robust condor
#

Can I not set it to compile only when I hit play button?

frosty hound
robust condor
#

If hot reload is so good, why is this feature not in Unity 6

timber tide
#

gotta remember though the editor won't update if it's dependent on that script

frosty hound
#

Not sure how that is a question. It's good because someone saw a need and addressed it with their own asset.

strong wren
robust condor
#

@strong wrenThe asset?

#

What is hard about it?

strong wren
#

Unity's version of code hot reloading. Making sure your project survives Unity's attempt to serialize all state and restore it takes some effort

robust condor
#

Oh, I might buy this asset if I can tab back into unity without having to wait 1 minute per ctrl+s

lucid quiver
#

is it bad to use the old input system of unity? like does it affect the project in anyway? I wanna shift to the new system but it seems too much work to change everything if there is not gonna be any objective change whatsoever

frosty hound
#

It doesn't affect the project in any way, no.

strong wren
#

I hear input latency is lower on the new input system backend on mobile.

frosty hound
#

If you're hoping to handle multiple input types, or various parts in your game that require different controls (driving vs flying vs walking etc, or even for handling UI), the new system is much easier.

#

But games were made with the old system successfully

timber tide
#

old system is fine and works right out of the box.

#

can't be arsed dealing with events when I just want to pump out some game for a jam

lucid quiver
frosty hound
#

You can use both, yep

#

But you will still need to handle the state of the game with the old system, so you're not reading inputs when you don't need them (vs the current system that just lets you toggle entire maps on and off)

lucid quiver
#

its probably better to convert it anyway cuz unity keeps depricating stuff

#

how old is the old input system exactly?

frosty hound
#

It's the original system

#

The current system has been out for 5 years maybe? I forget

lucid quiver
#

hmm i will switch up just cuz it seems more convenient for the long run

ripe shard
lucid quiver
#

ya so about 5 years approx

ripe shard
#

I would have guessed it is older 🙃

rich adder
ocean loom
#

how can i make the players shooting raycast ignore the player collider, but the enemy raycast not ignore the player collider? Also im not sure why but my enemy isnt following the player. can someone help?

rich adder
#

don't forget you have to put the gameobject with the collider to that layer

ocean loom
#

because im pretty sure i tried something like that and it wasnt working

rich adder
solar juniper
#

@lucid quiver after 4 Hours i have solved the issue with the Animator.
CC: @winter wadi

Solution: The GameObject that has the Animator Component, make sure this Animator Component "Avatar" field is set with an Animation Avatar.

lucid quiver
solar juniper
#

Thank you so much for helping tho

lucid quiver
ocean loom
lucid quiver
grand snow
#

avatars are for skinned meshes only#

ocean loom
grand snow
#

there is a setting for raycasts to hit things they begin inside of I think đŸ€”

ocean loom
lucid quiver
grand snow
#

if its a capsule collider you can move the start to be the radius + some small value?

ocean loom
#

is that the problem?

lucid quiver
#

all the positions need to be vec3

grand snow
#

Nah that just makes it easier to do what I suggested:

Vector3 dir = (end - start).normalized;
start += (radius + 0.01f) * dir;
#

or fix layer masking if they are seperate

ocean loom
#

guys im really new to this, i have no idea what any of this means 😭

#

RaycastHit2D ray = Physics2D.Raycast(transform.position, Player.transform.position - transform.position, PlayerLayer);

#

this is what i have

ocean loom
#

mask8

lucid quiver
lucid quiver
ocean loom
#

oh.

lucid quiver
# ocean loom yah

try this

bool hit=Physics2D.Raycast(transform.position, Player.transform.position - transform.position, PortableLayer);
#

hit should be true if it hits

ocean loom
lucid quiver
#

Okay so how do i manually set the magnitude of gravity in 3d? is there even a way or do i have to implement my own physics system for that?

grand snow
#

isnt it something you can change in the physics settings?

#

the speed anyway

lucid quiver
naive pawn
grand snow
#

the "gravity constant" should be set as -9.81 y in physics 3d settings

lucid quiver
naive pawn
solar juniper
lucid quiver
solar juniper
#

yes

lucid quiver
#

okay then that is needed

#

i thought it was 2d

solar juniper
#

had to make it to Humanoid

solar juniper
#

ty

cosmic dagger
solar juniper
#

yeah, at first i tought it was a coding problem

lucid quiver
sterile radish
#

hi im making a mini golf type game and i want to add bouncers, does anyone know how i can give these bouncers behaviours similar to that of pinball bouncers?

lucid quiver
naive pawn
#

or do you mean just the scale?

lucid quiver
polar acorn
naive pawn
lucid quiver
naive pawn
#

yeah i don't think there's an equivalent to that, you could disable gravity and do it yourself

polar acorn
#

For a 3D rigidbody, you'll need to add force manually

naive pawn
#

in fixedupdate, addforce Physics.gravity * scale

polar acorn
#

If you want less gravity, add for up. If you want more, add force down

#

or disable gravity and add it yourself entirely

lucid quiver
#

ya i got it

#

ty

grand snow
#

well adjust based on the fixed time scale cus i presume gravity is m/s

naive pawn
#

depending on the force mode, time is already factored in

#

for gravity you'd use force, which does factor time

sterile radish
#

sorry wrong reply

sterile radish
lucid quiver
#

u can just do addforce

#

oncollisionenter2d

#

and make ForceMode.Impulse

sterile radish
#

but what direction would i add the force?

lucid quiver
grand snow
#

something like this? (great drawing i know)

sterile radish
#

drawing coincedence lol

#

but basically the white circle (the golf ball) collides with the purple ball (the bouncer) and it gets bounced back by some force and into some direction

grand snow
#

You can get the dir from ball to bumper and push it the opposite way

lucid quiver
grand snow
#

im simplifying it but yea if you really want to be accurate you want the actual normal of where it hit

#

dont see much difference though đŸ€”

lucid quiver
#

if u want to be able to control where the ball goes then yes u need to be physics specific

lucid quiver
grand snow
#

then you can get the dir when it hits and do some random 2d rot like +/- 5 deg?

lucid quiver
#

i wouldnt do this but u can do it for simplicitie's sake

sterile radish
lucid quiver
#

how do u even calculate if it +5 or -5? is it random?

grand snow
lucid quiver
#

ya but the reflection is random

#

what u ideally want is a raycast reflection

grand snow
#

idea is there random or not

mighty compass
#

Guys i really need help organizing my project

shell sorrel
mighty compass
#

I have created enemy object, player object, tree object, and I'm having troubles choosing where to put logic. This is eventually going to be a client -> server game, and right now a low of objects are checking for the raycasts of the player, which I think is the correct thing to do, but Im just not sure how I could send player input to the game objects, or server to be processed.

#

Like if there are multiple players, how would I put the logic in my project to be checking for their raycasts on all objects within the game

#

would I create an array of the players and their raycasts or something? or a list?

#

Also is this the correct thread to ask that question in?

sage peak
#

Hey guys, Can someone help me with a code? I spent all day trying to fix it and I just remembered that this server is a thing

#
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class TextNumberThirst : MonoBehaviour
{
    public TextMeshProUGUI counterText;  // Reference to the TMP Text UI element
    public int counter = 100;  // Initial Hunger value

    // This method will allow other scripts to add points to the counter
    public void AddToCounter(int pointsToAdd)
    {
        counter += pointsToAdd;
        UpdateCounterText();  // Update the text display when the counter changes

        // Check if the counter exceeds 100
        if (counter > 100)
        {
            SwitchToScene(5); // Switch to Scene 5 when hunger exceeds 100
        }

        // Check if the counter is lower than or equal to -1
        if (counter <= -1)
        {
            SwitchToScene(6); // Switch to Scene 6 when hunger drops below 0
        }
    }

    void Start()
    {
        // Start the countdown process to decrease hunger over time
        StartCoroutine(Countdown());
    }

    IEnumerator Countdown()
    {
        // The countdown process that decreases hunger over time
        while (counter > -1)
        {
            counter -= 1;
            UpdateCounterText();
            yield return new WaitForSeconds(0.06f);
        }

        // Switch to Scene 6 if the counter drops below 0
        if (counter <= -1)
        {
            SwitchToScene(6);
        }
    }

    // Method to update the TMP Text display with the current counter value
    void UpdateCounterText()
    {
        counterText.text = counter.ToString();
    }

    // Method to switch scenes by index
    void SwitchToScene(int sceneIndex)
    {
        SceneManager.LoadScene(sceneIndex);
    }
}

Heres the script, for some reason the TMP doesnt change to -1, and it still switches to Scene 6

#

Yes I used gpt

rich adder
eternal falconBOT
lucid quiver
#

if u want to reflect it

#

the direction of relfection is reflectedVec

sterile radish
sage peak
grand snow
#

while (counter > -1) means it stops before -1 so at 0.

naive pawn
sage peak
naive pawn
grand snow
#

oh shit yea how did i miss that 😐

rich adder
grand snow
#

i blame bad ai code for my mistake

sage peak
naive pawn
#

"when counter drops below 0"
compares against -1
truly, remarkable quality code

sage peak
grand snow
#

rando scene changes happening in the add/remove hunger functions is pretty bad too

sage peak
#

The thing is, I have another code that's litteraly the same, and it works perfectly

naive pawn
sage peak
#

I think it's some other code blocking this one, but where is it.... đŸ€·đŸ€·đŸ€·

grand snow
#

add breakpoints to the scene changes to see why it happens (use a debugger)

sage peak
nocturne kayak
#

Hey, is there any way to debug draw a plane?

grand snow
rich adder
shell sorrel
shell sorrel
#

is no plane, but you could use a thin cube, or i would just use DrawMesh and create the mesh in code

rocky canyon
#

with 4 lines

shell sorrel
#

a plane is just 2 triangles

rocky canyon
rich adder
shell sorrel
#

handles are more complicated but also can be nice if you want it to be interactive

grand snow
#

Actually cant you use DrawCube with one axis at size 0?

still umbra
#

Can someone help me fix my rigidbody controller, I am on Unity 6 and whenever I release WASD it takes at least a second until my player stops moving. My movedirection is being printed in the bottom left and it seems like its the problem as its taking a long time to update only if I had held any directional key for a little bit already.

grand snow
#

check the axis settings as it wont reset to 0 instantly unless you change it

rocky canyon
#

are u getting Inputs in FixedUpdate?

rich adder
#

You can probably use Raw

rocky canyon
#

ya, use Raw input see if it helps

still umbra
#

Thanks ill try it right now

rocky canyon
#

ur movement runs in fixed.. i wouldn't imagine the delay between fixed updates are long enough for it to be that noticeable (updating the speed)

acoustic belfry
#

hi, for a weird reason when i click near the player, the bullets are shot with a lower speed, how i can fix this?

{
    Vector3 mouseposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
    Vector3 shootDirection = (mouseposition - transform.position).normalized;

    GameObject riflebullet = Instantiate(rifle_bullet, transform.position, Quaternion.identity);
    riflebullet.GetComponent<Rigidbody2D>().linearVelocity = new Vector2(shootDirection.x, shootDirection.y) * rifle_bulletspeed;

}```
rocky canyon
#

u can make physics a bit more snappier by lowering the fixed timestep.. but try the raw first

still umbra
#

yeah changing it to raw fixed it thanks

rocky canyon
#

then i read the code.. and now idk

rich adder
#

put the mousePosition.z at 0

acoustic belfry
# rich adder put the mousePosition.z at 0

like this?

 {
     Vector3 mouseposition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
     mouseposition.z = 0;
     Vector3 shootDirection = (mouseposition - transform.position).normalized;

     GameObject riflebullet = Instantiate(rifle_bullet, transform.position, Quaternion.identity);
     riflebullet.GetComponent<Rigidbody2D>().linearVelocity = new Vector2(shootDirection.x, shootDirection.y) * rifle_bulletspeed;

 }```
rich adder
acoustic belfry
#

holy cannolli you're a genius

#

that brain emoji was deserved

acoustic belfry