#πŸ’»β”ƒcode-beginner

1 messages Β· Page 744 of 1

radiant voidBOT
earnest lion
#

thanks

naive pawn
#

(or !vs for vs specifically)

earnest lion
#

!vs

radiant voidBOT
# earnest lion !vs
Visual Studio guide

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

β€’ Visual Studio (Installed via Unity Hub)
β€’ Visual Studio (Installed manually)

earnest lion
#

ive been trying a lot of shiz and im still not getting it so lets hope this guide will help

slender nymph
naive pawn
#

they are the same links, this one just shows only vs instructions

slender nymph
#

wtf why did the preview embed go away when i added context to the link, i didn't even wrap it in <>

earnest lion
#

thanks ill save it for after this

slender nymph
#

it contains the same instructions as the microsoft link (in fact it links to those instructions), but then also lists useful troubleshooting steps

earnest lion
#

awesomesauce

languid pagoda
#

Regardless of legality you should be doing the right thing and allowing people to decline this.

sage wyvern
#

i need help, i've been working on a 3rd person lock on system for my soulslike but i can't find any way to do it. if i use the sample scene from cinemachine it destroy my camera angle and if i search a tutorial they use a random package that i can't find

languid pagoda
balmy vortex
#

is there a way to look for the nearest object with a certain tag?

sage wyvern
languid pagoda
#

that will get all objects within a radius then you can iterate through them and filter them by tag/distance

balmy vortex
languid pagoda
balmy vortex
#

πŸ‘

languid pagoda
# sage wyvern you understand what i mean?

Yes but like honestly thats kinda a lot to discuss in a discord post but the basic gist would be

Detect when button to lock on is pressed
Get nearby enemies
Determine which one you want to lock onto , you can use the dot product to discard the ones not within the cameras view then the closest one from the remaining is probably the one you want to lock onto.
In your camera script you are going to want to to set the cameras foward vector so its always facing the target you're locked onto.

Is there a specific part you're stuck on?

sage wyvern
languid pagoda
#

like detect which enemy the one to lock onto?

languid pagoda
#

then that will return a list of items within that range

#

you can use layers to filter them out by enemy only

sage wyvern
#

alr

languid pagoda
languid pagoda
# sage wyvern alr

Vector3 dot can be used to determine if a gameobject is within the cameras view frustrum

#

not a coding question tbh

edgy cape
sage wyvern
languid pagoda
languid pagoda
#

ok what do you not understand?

sage wyvern
#

this is my current movement rn, will it work with this tho?

languid pagoda
#

yes

rocky canyon
rocky canyon
sage wyvern
trail hatch
#

I just placed a sphere and applied a script from a youtube video but it shows me an error:
You are trying to read input using the UnityEngine.Input, but you have switched...
This message is a bit long. Any help?

rocky canyon
#

debug any of the values u need to in order to understand the steps its taking

shell sorrel
trail hatch
#

That's my error...\

rocky canyon
polar acorn
languid pagoda
charred monolith
#

Is it possible to make only the Rotation kinematic? that means the Gameobject can move with physic but not the rotation

naive pawn
charred monolith
languid pagoda
charred monolith
languid pagoda
#

i have no idea if that will work on them

rocky canyon
#

another typical setup i've seen is rotating a seperate gameobject.. and then using it's direction to have the rigidbody move relative to that instead.. thats how those "sphere" car controllers work https://x.com/i/status/1107783904784715788

ur car obj(graphics) is tracking the sphere,, u rotate the car,(gfx), then the sphere goes in the direction the car is facing.. (relying on its vector) to move relative to it

How the arcade-like car controller was made; big sphere rolling around, car model just copies position. Raycast down to find ground normal for car. Sphere gets force based on car model direction. Tilt/wheel turning/etc. all lerps. #gamedev #unitytips

naive pawn
#

that's hilarious

earnest lion
#

does this look properly highlighted?

rich adder
earnest lion
#

ok great

#

but still im not getting any suggestions when im typing

rich adder
earnest lion
#

yeah i did everything just now

#

re did

#

everything is updated i even got the new visual studio community version

#

.net is intalled

#

all extesnions

rich adder
#

actually normally the path should start from Assets

hexed terrace
#

your screenshot is of visual studio code

earnest lion
#

well, i still did it

naive pawn
earnest lion
naive pawn
#

you did the steps for vs community, in vscode?

rich adder
#

yeah the color threw me off a bit, I'm so used my theme from regular colors UnityChanOops

hexed terrace
#

!vscode

radiant voidBOT
naive pawn
#

not assets

slender nymph
rich adder
earnest lion
#

oh i read that wrong

#

no

naive pawn
#

look at the actual explorer view instead of breadcrumbs probably

rich adder
#

ya Assets is always root for me

earnest lion
naive pawn
#

should be like this - top level as the project root, then assets/library/projectsettings/.git as folders inside that

naive pawn
#

breadcrumbs start inside the project, they don't include the opened folder

rocky canyon
#

When’s the best time to load core game systems (player, audio, UI, managers) in Unity? Im going for smooth transitions with no stutter whatsoever like you'd see either between or during splash β†’ menu β†’ cinematic, or splash β†’ cinematic β†’ menu. Should I load everything at boot, or progressively spawn systems during each scene load? If you spawn systems in a scene, how do you handle passing necessary references to a GameManager or core logic? How do you usually structure this for smooth startup?

rich adder
naive pawn
rich adder
#

yeah in FIle Explorer its the entire project

naive pawn
#

and actually, above Assembly-CSharp, doesn't it show the project name anyways

rich adder
slender nymph
naive pawn
# rich adder

yeah, so that would be having the entire project open in vscode

#

the workspace is for the entire project folder

earnest lion
rich adder
naive pawn
#

i thought breadcrumbs were just using syntax, never looked at them before stuff was loaded. that's cool to know

rocky canyon
naive pawn
#

i wait for the colors to load

rocky canyon
#

ohh i guess u dont get clutter from non-scripting stuff

naive pawn
#

or i leave my mouse hovering on something from unity and once it shows docs it's loaded

rich adder
hexed terrace
#

I don't even have the solution explore open

rocky canyon
#

i notice its not showing any audio folders or anything

slender nymph
rich adder
naive pawn
#

i honestly just found out about solution explorer. i don't do purely c# and it(or equivalent) just isn't part of my workflow for anything else lol

slender nymph
#

you've clearly missed something

earnest lion
#

5 was an exaggeration

naive pawn
#

have you installed .net with the .net install tool extension, waited for it to complete, and then restarted vscode

rich adder
#

if you have all the extensions and plugins, try also doing a External Tools page Regen Project files

rocky canyon
#

or nuke ur cache and sln files from earlier

languid pagoda
rocky canyon
#

game manager, audiomanager, menu canvas's cameras, ppfx, etc

naive pawn
#

@earnest lion also make sure you've opened the right folder - your project root, not your scripts folder

languid pagoda
rich adder
#

you have 7 problems.
might wanna check those

rocky canyon
#

DDOL and singleton junk

naive pawn
rich adder
#

Ohh yea maybe, I think i got mine disabled

naive pawn
#

i can't find a good reason to have them on lmao

rocky canyon
earnest lion
naive pawn
#

in vscode

rocky canyon
#

im thinking of breaking things up into more scenes this time around.. like having a scene thats just my cinemachine rigs and stuff, a scene thats just audio, etc and loading them up

#

but never done that b4.. ive always loaded everything in as soon as the savesystem reads its data

#

im having to completely remake my bootstrapper and scenemanagement stuff

languid pagoda
earnest lion
rocky canyon
#

ahh okay so you have (2) scenes loaded at once... atleast.. (gameplay stuff) and (level stuff)

earnest lion
rocky canyon
#

my last build had atleast 3 loaded in at all times.. (game stuff), (the menu system), and the (environment) just brainstorming a bit while i sit at this crossroad

earnest lion
#

its beautiful

slender nymph
rocky canyon
#

woopwoop πŸ₯³

earnest lion
naive pawn
rich adder
#

holy shit default theme has access modifiers as green πŸ˜΅β€πŸ’«

naive pawn
#

i don't think so?

earnest lion
naive pawn
#

keywords are in blue unless they're control flow which are purple, usually

rich adder
slender nymph
# earnest lion its not

it is.

Open the project from Unity's Assets > Open C# Project menu.
would have solved the issue

naive pawn
rich adder
#

lol nice site

naive pawn
#

(to be clear i did see that in the screenshot, im just commenting on what i usually see for default)

languid pagoda
rich adder
languid pagoda
naive pawn
#

i haven't used vs in ages

#

i mean.. neither have you

rich adder
naive pawn
#

but i didn't use vs much lol

naive pawn
#

(monokai..? am i remembering that right?)

#

oh man do i seriously remember it all

rich adder
languid pagoda
naive pawn
#

no, but still *nix (mac)

rich adder
#

Unix gang

languid pagoda
#

I mean makes sense then

rich adder
#

VS for Mac was a shit show ngl.. it was a Xamarin app lol

languid pagoda
#

vs on windows is pretty awesome

rich adder
#

well its a native app..also been around since 90s lol

limber turtle
#

can someone tell me what this is all about? i can't tell the source of the issue from reading this and i don't know what the expression in question does

languid pagoda
#

probably being caused by some custom editor ui code tho

limber turtle
#

i don't have any of that, i got rid of the a* pathfinding project i had

slender nymph
naive pawn
# naive pawn oh man do i seriously remember it all

white - standalone symbols
orange - strings
light green - numerics
navy blue - non-control-flow keywords
purple - control flow keywords & pragmas & module systems
yellow - callables
blue - constant variables
light blue - non-constant variables & documentation annotations
green - namespaces & custom types
dark green - comments
orange red - regex

damn.
not sure how i feel about remembering that

rich adder
glad shore
#

How can i make some good interior lighting using HDRP

rich adder
#

its like mine but improved

rocky canyon
#

i just created a empty project and named it the most random thing ever...
and looking thru that plug-in theres one w/ the exact same name πŸ‘€

#

the ide wants me to use these colors.

haughty lion
#

Where is "Drag"?

rich adder
haughty lion
#

Thanks

charred monolith
#

is it bc of the speed or sum?

#

also how do i make my prefab in a created folder so my prefab actaully isnt there

slender nymph
#

the only condition you are checking is that whatever assigned to Bullet is not destroyed

rich adder
#

its doing it on ANY type of collision

slender nymph
#

it doesn't check if the thing it is currently colliding with is a bullet. it only checks that whatever is assigned to that Bullet variable still exists

charred monolith
slender nymph
#

you would typically check the colliding object for a specific tag or component

rich adder
#

why does that enemyAI have a Bullet field for anyway?

charred monolith
slender nymph
#

that doesn't explain why the enemy ai has a field for a Bullet

rich adder
charred monolith
rich adder
#

I guess you wanted to check if its hitting a bullet you would check Bullet or whatever you named your bullet script / type, you would not check a specific bullet unless you somehow recycle

slender nymph
charred monolith
rotund crater
#

I'm trying to get this Render Texture to display my player but even though my camera has it as the output texture, and the culling mask isn't hiding anything, it's just displaying an empty screen.

rotund crater
charred monolith
#

cuz like... its not the same bullet. only for 1st

rich adder
#

yes it would never be the same bullet (assuming you're shooting from player or something)

haughty lion
#

When is it better to use BoxCast and when RayCast?

#

I mean RayCast is sufficiently enough for many tasks in Unity

slender nymph
#

well one is box shaped and one is an infinitely thin line. so you use one or the other when you need either a box or an infinitely thin line

polar acorn
rich adder
charred monolith
#

is there a way to get a prefab out of a created folder? per script?

rocky canyon
#

when u end up with 4 raycasts pointing in the same direction u might as well switch to a boxcast πŸ˜‰

rich adder
#

wdym "Get a Prefab"

polar acorn
rocky canyon
#

truedat

haughty lion
#

I mean you can use Raycast literally everywhere, be it looking for disguised player or so on

rocky canyon
#

could use it for lots of things.. melee attacks just first thing pops into mind

haughty lion
#

As well that ray in raycast is visible than boxcast

rich adder
rotund crater
#

Idk if I have a fundamental misunderstanding of how render textures work or I'm missing something

haughty lion
haughty lion
rocky canyon
#

like for a melee attack, like a sword swing...

rich adder
rocky canyon
#

you could Box cast forward.. in the general shape of ur swing..

#

that way more of the enemy collider makes contact

rich adder
#

if you only need a line use a line if you need a bigger shape use box

rocky canyon
#

but that could also be a trigger.. box cast canbe shot way out tho

#

could use it as a groundcheck too

sage wyvern
#

I need help, i'm trying to make this game and i'm trying to code different things but everytime i look at the things i coded i think what have i done and if i ask help it mostly looks like they are talking chinese

rocky canyon
#

woudl take up more room than the single raycast most ppl get started with

haughty lion
rocky canyon
#

u can control how far u cast them..

rotund crater
rich adder
haughty lion
#

Like I think ye if sword swing requires a player in front of you in a certain distance

slender nymph
#

this is a code channel

warped meteor
#

oh sorry

#

where should I ask then

slender nymph
sage wyvern
#

I need help, i'm trying to make this game and i'm trying to code different things but everytime i look at the things i coded i think what have i done and if i ask help it mostly looks like they are talking chinese.
how can i code and understand what i am doing

rich adder
haughty lion
rich adder
slender nymph
# sage wyvern I need help, i'm trying to make this game and i'm trying to code different thing...

it sounds like you need to start simpler with your learning materials. or just find better ones that aren't just assuming you'll copy/paste but actually teach you why you would use something and what it does.
the pathways on the unity learn site will go over the absolute basics in a structured manner that should help you understand what you are doing as you build upon the concepts you've already learned

rocky canyon
#

i not sure why u lookin for a reason to discredit a boxcast? lol

#

either u need to use one or u dont..

#

fun fact.. theres lots of other shapes u cast too

sage wyvern
rich adder
#

your objects are not infront of the camera

rotund crater
rich adder
slender nymph
rotund crater
slender nymph
#

and the junior programmer pathway will have you working on a personal project anyway

rich adder
#

your objects must be between these two

rotund crater
rotund crater
#

we might still have a problem

rich adder
# rotund crater

the camera is parented to something else. make sure that also has proper position?

#

oh thats the hammer thing ? it should be working

#

that FOV looks sus tho

rotund crater
#

Yes its the hammer thing

#

FOV is extremely messed up idk

rich adder
#

its like really zoomed in

slender nymph
#

the fact that it's a perspective camera with 2d sprites is concerning. this should be orthographic unless you have a specific reason it's a perspective

rotund crater
#

well the default is this

#

do I change the clipping planes instead

rich adder
#

first change it to orthographic

rotund crater
#

done

haughty lion
#

guys what is the new DistanceResult class to return?

#

in Physics2D

rotund crater
#

That is better

#

Still doesnt render

rich adder
#

why is the far clipping plane 3
your distance is 10 units
you can just leave it at like 100 or something

haughty lion
slender nymph
# rotund crater

Size 1.66
something isn't adding up here, that camera is clearly more than 3.3 units tall

sage wyvern
#

@slender nymph can you send me the link of the unity learn site

slender nymph
#

!learn

radiant voidBOT
sage wyvern
rich adder
rain solar
#

if im storing loaded chunks in an oct tree, do i have to do a big expensive traversal when i want to determine which chunks can be unloaded after the player moves away?

rich adder
#

the eye with camera icon @rotund crater

polar acorn
# rotund crater

Maybe go into 3D view and see where your camera is actually pointing

#

See what's in the box

rotund crater
rich adder
polar acorn
rotund crater
#

I have MainCamrea, FollowCamera, and Camera
Camera is the one im trying to render

#

what

#

Its slightly in front

#

It's not letting me change the Z axis

polar acorn
#

Do you have code that is moving the camera

rotund crater
#

I dont but is it because it's a child of the sprite?

polar acorn
#

If it's a child of the sprite then the position in the inspector is where it is relative to the parent

#

As the parent moves, the camera will remain at that relative position from it

rotund crater
#

It was

#

I moved it out

#

and its rendering now

rain solar
#

if im storing loaded chunks in an oct tree, do i have to do a big expensive traversal when i want to determine which chunks on the edge of render radius can be unloaded after the player moves away?

rotund crater
#

thank you guys I can now look my beautiful boy in his eyes

rich adder
#

terror

rich adder
rain solar
#

im beginner

#

ill post over there πŸ™‚

rich adder
#

the question itself is not a beginner question πŸ˜… I think..

true pine
true pine
#

...what??????

#

one of my objects is breaking the editor UI and throwing these errors

#

45 at once by the looks of it

rich adder
true pine
#

so what do I do

rich adder
#

use a unity version thats not busted

true pine
#

and what version would that be

rich adder
#

afaik anyone before these newer version

#

stick to LTS if you're not sure (though I think the latest LTS also has a bug)

true pine
#

just this top one right

#

I'll assume that's it

#

seems to be taking a while

#

😭 my internet is so ass

past sentinel
#

What would be a good method to start working on a rimworld-style base builder? I'm wanting to learn more Unity 2d but i dont know where to start with the tile making half.

visual pond
#

what am i doing wrong the jump doesnt work but the debug shows

rich adder
visual pond
#

wdym?

frosty hound
#

Or your jumpForce value is 0, or not high enough to actually counter the gravity.

visual pond
#

jumpforce is at 10000

hot wadi
visual pond
#

do i copy and paste

#

here

#

public bool isplayer;
public float speed;

[SerializeField] public float jumpForce;

Rigidbody2D rb;
public Vector2 movement;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
rb = GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        //jump here then new vector2 x is 0 and y is jumpforce force mode 2d impulse basically 1 time use 
        rb.AddForce(Vector3.up * jumpForce, ForceMode2D.Impulse);
        Debug.Log("jump");
    } 

    if (isplayer)
    {
        //named movement x and y then getting input from horizontal and vertical axis
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");
    }
    //getting rigidbody component and setting linear velocity to new vector2 movement x and y times speed aka movement
    
    rb.linearVelocity = new Vector2(movement.x * speed, movement.y * speed);
}

}

#

this basically

rich adder
#

rb.linearVelocity = new Vector2(movement.x * speed, movement.y * speed); this should be
rb.linearVelocity = new Vector2(movement.x * speed, rb.linearVelocity.y );

#

or 2d has X directly you can change

#

rb.linearVelocityX

hot wadi
#

U are directly setting the vertical velocity

visual pond
#

wdym

hot wadi
#

It can override the jump action

visual pond
#

oh

#

i see now

#

rb.linearVelocity = new Vector2(movement.x * speed, movement.y * speed); this thing?

hot wadi
#

Yes, movement.y for specific

visual pond
#

ngl i did that because uh autocorrect of vs code

rich adder
rich adder
#

if this is sidescroll move thing , why even capture Y

past sentinel
visual pond
#

no its me basically trying to do movement on a 2d game

#

without outside help

rich adder
#

!learn has the basics then specifics you look up on docs or google

radiant voidBOT
visual pond
past sentinel
rich adder
visual pond
past sentinel
#

no not roguelike a 2d base building game

#

like rimworld

visual pond
#

oh so like terraria

rich adder
# visual pond yeah i need to that next time

although this is more of a logic thing.. if you think about linearVelocity you're overwriting any sorts of Y force you applied to rigidbody because its been overwritten in the next physics tick by whatever movement.y * speed was

visual pond
#

wwell like some

#

imma go see what the hell linear velocity and normal velocity dfference is

rich adder
visual pond
#

i mean

#

velocity.2

rich adder
#

its either linear or angular

visual pond
#

oh well the default without saying linear

rich adder
#

the default is linear

#

it used to be just called .velocity in older versions

#

but they wanted to be more explicit

past sentinel
# visual pond oh so like terraria

no not fully top down where theres largely NPCs doing the building and you layout where you want thigns built. thats my end gole but im habing issue with starting it

visual pond
#

oh

past sentinel
#

the only tutoral i found was 9 years ago and seems kinda outdated

visual pond
#

kinda outdated is a understatement

rich adder
#

most things work the same aside from few api changes in naming

#

practically and logic wise its still relevant knowledge

visual pond
rich adder
hot wadi
past sentinel
#

Ive never really like using AI

rich adder
#

smart

past sentinel
#

and something like this seems outide the scope for it

rich adder
#

don't

#

just a glorified search engine that gives false impressions of the truth most of the times.. horrible in the hands of beginners

past sentinel
#

and ive bene using unity for a few years now and i know a fair bit of C# but its mostly how to get started that im having issues with

hot wadi
#

Well u should start to becuz it’s useful. I’m not saying u let it generate code for u. Just to see what the typical workflow is

visual pond
#

you make game object

#

then uh

rich adder
#

"AI" is not a good tool

hot wadi
#

Ok u do u

past sentinel
#

ive used AI a few times a while abck for simple things. while its good at simple thing sit wont be good at this at all. thats why im asking for help here

rich adder
# hot wadi Ok u do u

Exaclty if you want to learn wrong thats on you but don't make those suggestions here because this is a coding channel and its meant to learn properly

hot wadi
#

If u can’t find resource anywhere or just outdated stuff, u can keep wasting time

rich adder
#

also against server rules / overall thought on the matter

visual pond
#

hey do yall have any clue on how to make a dash

rich adder
#

you're wasting time going back to fix shit code that "AI" spouted

past sentinel
visual pond
#

yeah but i want it to be if your moving in this direction and hit this key you dash for 5 pixels or smth

past sentinel
#

is it 2d or 3d?

visual pond
#

2d

hot wadi
#

Whatever

rich adder
visual pond
#

oh yeah why is 6000.2.6f2 always package failure

rich adder
#

it will feed you misinformation that you cannot verify yourself because you're trusting a machine to get it right , it wasn't designed to

hot wadi
#

How they do it is their choice, I’m not making decision for them

rich adder
#

do whatever you want else where

hot wadi
#

The engine only takes answer that are already given out on the Internet

rich adder
hot wadi
rich adder
#

anyway im not here to argue the validity of ai all day with you, just telling you no place for it here as advice..

past sentinel
#

well anyone know what this style of game is actually called because that might help me with searching

visual pond
#

probably somewhere close to resource management

rich adder
#

if you want to know how to dash or something like that, break down what you need to know..
Probably a Timer
probably a way to tell you're in "dashing mode"
and so on

#

you will find easier results because its generic enough to get to the solution, then you combine those and get the final mechanic

past sentinel
rich adder
#

much easier than "how to make game system like xyz" and get some very niche or specific series some dude did 7 years ago

edgy sinew
#

Hi all, what is your recommendation to temporarily ignore collisions between some 2 objects in scene?
Is simply changing the β€œExclude Layers” as needed OK?

rich adder
#

there is also Physics.IgnoreCollision or Physics.IgnoreLayerCollision

#

"old-school"

#

the one on collider is fairly new system afaik

edgy sinew
#

Oh dude. Legend mode thank you looks perfect

#

Unity back at it being convenient. I did not a expect 2-object collision ignore to be built in

rich adder
#

yeah those functions are pretty handy especially with timers and stuff.. they also have a Layer-Based matrix in the editor but its more global

edgy sinew
#

Just the idea of, at different times diff behaviors

rich adder
glad shore
#

for some reason it keeps auto playing at the first frame

rich adder
#

also not a code question

#

why do you have both animator and animation

glad shore
#

idfk how to do ts πŸ˜”
ima go watch a tut
but thx for the help

rich adder
glad shore
versed light
#

does batching break if meshes have different uvs but all the rest of the geometry is the same like verts,tris and indices

versed light
#

where unity batches like meshes to reduce draw calls

teal viper
versed light
#

instancing in this case

teal viper
#

Anyways, in your case you're dealing with separate meshes(it doesn't matter that they contain some duplicate data). So whether they would be batched or not, depends on the ability of the batcher to batch draws with different meshes. All aside from gpu instancing can do that.

versed light
#

since i want instances of the same mesh but world space uvs

teal viper
#

So, no, you can't use gpu instancing.

#

They're not the same meshes.

versed light
#

ill have to use a shader to get around it then

teal viper
#

Sharing some of the data doesn't make them the same mesh. Only if they're exactly the same asset(a reference to the same mesh asset), they are.

versed light
#

fair enough but if i calc uvs in frag shader they should be seen as same instance then right?

teal viper
#

Yes.

maiden drum
#

can anyone help me with urp?

            struct Attributes
            {
                // The positionOS variable contains the vertex positions in object
                // space.
                float4 positionOS   : POSITION;
            };

            struct Varyings
            {
                // The positions in this struct must have the SV_POSITION semantic.
                float4 positionHCS  : SV_POSITION;
            };

            // The vertex shader definition with properties defined in the Varyings
            // structure. The type of the vert function must match the type (struct)
            // that it returns.
            Varyings vert(Attributes IN)
            {
                // Declaring the output object (OUT) with the Varyings struct.
                Varyings OUT;
                // The TransformObjectToHClip function transforms vertex positions
                // from object space to homogenous clip space.
                OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
                // Returning the output.
                return OUT;
            }

            // The fragment shader definition.
            half4 frag(Varyings IN) : SV_Target
            {
                float2 uv = GetNormalizedScreenSpaceUV(IN.positionHCS.xy);
                return float4(uv.y, 0, 0, 1);
            }
            ENDHLSL

as i understand it, GetNormalizedScreenSpaceUV should return the uv in screen space, however uv.y is always the same (i'm getting full red everywhere)

versed light
#

true it is now i know i need to use a shader get around it

haughty lion
#

Hi guys

#

Right now I'm facing a problem in which fireball isn't moving towards NPC, could you please tell me why?

eternal needle
#

you also should post code following the guidelines

radiant voidBOT
haughty lion
#

Yess, object is running

#

Tried to log it

#

The problem is in Vector2 movetowards, it might be there

keen dew
#

The first line of Update always sets the fireball back to its initial position

haughty lion
#

It's its position

#

Not position*

eternal needle
#

theres definitely some weirdness with this whole FireballPoint and Fireball object, considering these seem like entirely different objects from the video. debugging further will show you why its not moving
to me it seems like you're always setting the point based on an object that isnt moving

haughty lion
#

It's just a supporter to add fireball in a particular position in OnAttack

keen dew
#

Ok, but it's the same thing you're trying to move on the next line

haughty lion
#

FireballPoint is used like any joint modifier in Inspector, it is used to keep the initial advention of a fireball in + 1f (X POS) from Player's position.

Meanwhile, Fireball is the object

keen dew
#

Nothing in the code tries to move Fireball

haughty lion
#

But, partly I feel that you're right

haughty lion
keen dew
#

Yes, you apply MoveTowards to FireballPoint. Not Fireball.

haughty lion
#

Thank you

#

Could you tell me please why isn't the object disappearing?

keen dew
#

It never gets that close to the target. The distance is calculated between the centers of the objects

haughty lion
#

Is it better to calculate it with Physics2D.Distance then?

keen dew
#

Since they both seem to have colliders the object should be removed on an OnCollisionEnter2d event

haughty lion
#

Thanks

#

That looks vivid and cool! How have you made changing map? Did you make it by code or were they already initial, patterned maps?

elder canyon
#

100% Code with a single 5x1 Wall Prefab. I used DFS (Depth First Search) to create the maze. Essentially it can make mazes of any size and shape, I just constrained it to 5x5.

haughty lion
#

That's really cool bro!

elder canyon
#

Thanks!

eternal needle
elder canyon
#

Oops, I'll make sure to post them there, from now on.

haughty lion
#

Guys, how can I make the collision of two objects without OnCollisionEnter2D?

#

is it better to make it by Physics2D.Distance?

#

Just because parental-object (Player) on which the script is attached is destroying NPC while they're in collision

#

But the point that it has to occur so with fireball

#

If I don't put a fireball as a child object or attach the script into it, it doesn't work somewhy

midnight plover
hot wadi
# haughty lion

OnCollisionEnter() is called by the rigidbody that it’s attached to. I assume u want the fireball to destroy enemy on contact, but your script is only tracking collison between the β€œplayers” with β€œNPCs”, not the fireball with β€œNPCs”. U can simply attach a script with OnCollisionEnter() to the fireball, give it a kinematic rigidbody.

sour adder
#

MoveTowards won't work well the way you are using it, it makes it slow down more the closer it gets.

keen dew
#

It's fine the way it is (other than that physics objects should move by using forces/velocity instead.) You're confusing it with lerp

sour adder
#

Aha, ok.

sage mirage
#

@haughty lion You know the best thing you can instead of asking all the time for help, is to translate your code int pseudo code to understand what your code does, use AI as a tool to provide you the logic you want to create do not use AI for copy pasting without understanding what your code does thats really horrible. Just look at your code at the beginning try reasoning it and you will figure it out check inspector, maybey you forgot something there in a component maybe a value or something. Look at Unity Docs as well for things like what Physics2D.Distance does etc etc. Check a tutorial of the functionality you want to create. It's horrible I know even professionals have issues and sometimes struggle its all part of the development process.

#

Maybe ask your teacher on college if you are in Games Programming Class for example I am just saying

sour fulcrum
#

Please don't suggest people use AI

midnight plover
sour fulcrum
#

Plenty of things wrong with using it as a tool

#

it can outright lie to people

#

beginners cannot correctly identify when AI is giving them garbage

midnight plover
#

Well, and not every coder can identify, if their code is garbage too...

sour fulcrum
#

Ok, people shouldn't suggest garbage code either

naive pawn
#

it's fine to use it as a tool. but it's way too easy for a beginner to accidentally use it more than that

eternal needle
midnight plover
sour fulcrum
nimble pasture
#

I have a question related to nodes and animated shader graphs, is this a proper channel for that?

naive pawn
nimble pasture
#

thank you ! Have a nice day.

eternal needle
#

Either way its not a good idea to suggest beginners to use AI in here ever

midnight plover
#

Alrighty, we do not agree, which is fine. But if thats the channels conduct, I of course align with it and do not suggest it in here πŸ™‚

eternal needle
#

Beginners dont read this whole conversation about it. They see the suggestion, think they are immune to getting fed misinformation, and continue to use it

sour fulcrum
#

its not a rules thing it's a please don't suggest people do things that make them worse at programming

#

we kinda want the opposite here

eternal needle
high mauve
#

hey i needed some suggestion i am a computer science student in uni and i know basics of programing like operator and loops etc i want to learn c# i have some exp with c++ and c where should i start c# as its confusing due to c# and the unity c# being diffrent . help?

grand snow
#

Unity c# is not a thing, there is the unity api

#

the c# version we have is a bit older but its still normal c# so learning c# will help

high mauve
#

unity c# means the C# sscripting done with the unity engine rather than the system library used normaly in c#

grand snow
#

Perhaps learning the basics first then going into some unity learning material is best.

#

the .net library is still usable, e.g. DateTime, List

#

!learn

radiant voidBOT
high mauve
#

from where can you suggest some sources i am currently studying from C# 12 in a Nutshell The Definitive Reference by Joseph Albahari

grand snow
#

that should be fine but unity uses c# 9 so some nice newer features are not compatible

#

your IDE will inform you though if thats the case

high mauve
#

ok do you have some yt tutorials for c# and OOPs

grand snow
#

I don't but there are resources pinned in this channel

high mauve
#

ok. thankyou

#

hey can i add you as friend ?

#

@grand snow

grand snow
#

no. you should ask questions here for anyone to answer

high mauve
#

ok

#

πŸ₯Ή

eternal needle
high mauve
#

ok i tried that to and wrote code for a calc as it was listed as beginner online

hot wadi
#

Oh I miss pointers in C++

eternal needle
high mauve
#

alright i also skip that parts i want to learn advance topics such as OOPs, stack, queue, tree etc data struct

grand snow
#

those are general topics not confined to one language

high mauve
#

but may have syntx specific to C#

hot wadi
#

The concept is the same for all languages. Thou implementation is slightly different. Should they already teach u in uni?

eternal needle
#

Those really arent advanced topics either. I find that OOP is barely a topic either, its just something you do when using these languages
Yea c# may have implementations for some of these but the syntax is just going to be a matter of calling a method on an object. Not much to learn there either if you know what a stack/queue is for example

high mauve
#

i want to learn there implementations in c# also my uni didnot teached me OOPs as the prof came in the last week and speed run the subject in one week with 2 hrs continuous lect. each day

hot wadi
#

Lol

high mauve
#

@eternal needle i am having problem with the under standin of OOPs consepts such as class object encapsulation etc

hot wadi
#

Anyway, u can learn the concept in any language. I started with C++ too. When u are familiar, u can start doing C# project to get used to the syntax

eternal needle
high mauve
#

alright then i will start with the concept then small projects in c# then unity scripting right?

eternal needle
#

Lookup topics as you go. It feels like you just need to keep at it rather than having one specific trouble
Usually I suggest to go with c# outside unity first yes. If youre confident with understanding how classes work then it'd probably be fine to go right into unity.

high mauve
#

ok thankyou for the help @eternal needle @hot wadi

hot wadi
#

By the way, u don’t need to understand it right away. Polymorphism and abstraction are complicated even for experienced devs. They only start showing their use as a project grows.

balmy vortex
#

does anyone know why my orbs here move so fast when they're further away from their target and why they stop moving once they reached the first target position instead of updating it and continuing to chase after the enemy?

#

they're supposed to move at a constant rate towards the enemy but ya

hexed terrace
#

You need to log out all your various conditions and see where it stops. Perhaps toucheSomething becomes true, but the thing isn't getting destroyed. Or getNearestEnemy fails to find an enemy - etc, etc

sage mirage
sour fulcrum
#

I didn't say copy pasting, as noted in the comment you replied to

sage mirage
#

Dont know if its bad or not but AI is now part of our daily life we as devs have to use it as a tool to help us in development process

sour fulcrum
#

AI is not now party of our daily life, maybe yours. please dont assume

north kiln
#

it's not a part of my life

balmy vortex
#

what

midnight plover
sage mirage
#

I wont say anything else but last thing I am going to say if its not a part of your daily life, you do something wrong nowadays because prompt engineering is the most valuable skill today for all devs

hot wadi
#

Did not expect an AI bro around here

sage mirage
#

I don’t understand why some people disagree with me about AI tools that are genuinely helping developers improve their workflow and much more. Believe it or not, we all have to agree that using AI isn’t dangerous. It’s like the Web, we had Google before, now we have something new. Why to be afraid of technological evolution?

fickle plume
sage mirage
#

Yes but you are challenging me with emotes. Ok XD

fickle plume
#

Just negating the BS beginners do not need to hear.

swift elbow
hot wadi
#

Imagine googling blue waffle. Truly a terrifying example of tool gone wrong

fickle plume
#

Will start muting

sage mirage
#

He replied to me

fickle plume
sage mirage
strong tendon
winter flicker
#

does anyone know if it's possible to blur a UIDocument made with the ui builder?

sage mirage
#

Hey, guys! I was wondering how is it possible to create supported languages for my game. I will search it on youtube and check some tutorials but also want to hear what you have to say about it.

#

I think there will be buttons for each language

#

and lets assume the player will click one of the buttons the event will be triggered and the language must change the UI text elements of my game

#

I have heard something about JSON but not sure what it is exactly and how to use it within Unity.

tough lagoon
#

Unity has been "planning" full RTL support for text mesh pro like 8 years. Not sure if they ever actually did it.

grand snow
#

I thought tmp already had support for this

tough lagoon
#

Im not sure tbh, hopefully. But with everything being UIToolkit (which does, finally, claim RTL and world space) it probably isnt as imortant anymore.

(I also could just be wrong, we moved to unreal a while back)

lunar coral
#

hi,I've watched this tutorial on how to make a state machine and I've built my state machine, the only problem i he doesn't explain how to use it:https://youtu.be/qsIiFsddGV4?si=kOf8kgGRKiVDRUsD

Take your programming skills to the next level and learn how to build a better state machine in this brand new tutorial and break down!

This tutorial explains how we can create a reusable state machine in C# by implement abstract classes and generics! It also breaks down core pieces of any state machine with helpful visuals and explanations.

...

β–Ά Play video
rich adder
#

if you scroll to around 9 min it tells you how to create a statemachine for a specific object, eg "PlayerStateMachine" etc. You have to inherit the abstract class it made
PlayerStateMachine : StateManager <PlayerStateMachine.PlayerState>
{ public enum PlayerState { Idle, Walk, Run } } etc.

#

now your player is in "Idle"

#

etc .

lunar coral
#

Actually you're right,It's my first time working with FSM,so I should start with a simple one first, but the thing is I've understood everything, the only thing I don't know is how I could animate characters or GameObjects for each states the efficient way and this if I'm right isn't explained

hot wadi
#

Unity's animator is already a kind of state machine

#

It's recommended to animate that way. And save your custom FSM for other stuff like game states and AI

lunar coral
lunar coral
cosmic quail
naive pawn
steel lantern
#

oh dang.. I thought I was in unity talk. Sorry

dapper flare
#

what's a great way to make simple rooms for my game in unity

eternal needle
dapper flare
#

ok

rich adder
hexed terrace
#

these posts aren't allowed on here. You want !collab

#

!collab

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

dapper flare
supple crescent
#

Guys is the course Junnior Programmer un Unity Learn a good way to learn the program? I ask this since the version of the course is 2020.3

hexed terrace
#

yes, it's fine

rich adder
supple crescent
rich adder
rain solar
#

is there any iso surface extraction algorithm better than dual contouring?

hot wadi
bronze garden
#

I have literally just started a new 3d project, all ive done is make a bean and have started a movement script and im getting this error

#

Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak

grand snow
#

Not your fault then if you aren't running a job

wooden hemlock
#

Hey guys, I want to make a 2D game with a character where each body part is replaceable and you can mix it up. Let's say like an Orc where one of his arms is human, one of his legs is elven or whatever and you can randomize it. I don't need to rig it yet. What is the easiest way to do this?

I've been looking up tutorials but I'm so confused and overwhelmed now. Some people are saying some of the tutorials are outdated, I'm always missing something or something isn't working

polar acorn
nimble crystal
#

Hello everyone, I am currently working on a 2d top down zombie game. For zombie behavior im checking every frame if the ray casted from each zombie hits the player or not, if it does then i call the Chase() method. But there is 1 issue, in the game there r going to be hundreds of zombies and casting a ray from each zombie every frame might not be a good idea, then I thought I can check if the player is within a certain range I will only then cast the rays OR i can add colliders to each zombies set as triggers, if the player triggers it the ray casting will continue. Idk what method to go with or there is a better way than both of them. Any suggestion would be appreciated. Thank u!

wintry quarry
# wooden hemlock Hey guys, I want to make a 2D game with a character where each body part is repl...

You've been looking up tutorials for what? Generally you won't find a tutorial to do the exact thing you want to do, though this is kind of similar to "weapon" systems. Overall what you're describing is a complex system that will have many moving parts, and the "best"/"easiest" way to do this is going to depend heavily on how your particular game works and your particular requirements for this system

rich adder
#

raycasts are fairly cheap, you can usually run hundreds of them without a huge impact, its when you get in the thousands you should worry more

#

if you have thousands of enemies raycasts are probably least of your problems at that point, rendering and other logic can also be a factor

wooden hemlock
#

This tutorial I watched seems ok but people say its outdated + the example .psb that's been given to test with isn't using those exact sprites but some ugly stick ones and it's a bit hard to follow. (I'm a complete beginner πŸ˜„ )

nimble crystal
wintry quarry
#

If you mean the whole "attachable weapon system" including all the different attributes of the weapons or any other part of the system, that's all more complicated

#

Basically all the different body parts and weapons can just be separate SpriteRenderers

#

that will be the easiest/simplest approach here

#

you would have a base underlying skeleton for the character that doesn't change

wooden hemlock
teal elk
#

I'm working on an inventory grid system in Unity and having trouble with coordinate conversion in my GetSlotIndexFromPosition method. When I click on the grid slots, I'm getting negative grid coordinates like (-4, 1), (-3, 0) instead of the expected positive values like (0, 0), (1, 0), etc. The issue seems to be related to how I'm converting the local coordinates from RectTransformUtility.ScreenPointToLocalPointInRectangle() to grid coordinates. I struggle with math's in general, so I'm unsure what I am doing wrong here.

  {
     ///coords -= (Vector2)transform.position;
      Vector2Int gridCoords = new Vector2Int(
     Mathf.FloorToInt(coords.x / (slotCellSize + slotPadding)),
     Mathf.FloorToInt(coords.y / (slotCellSize + slotPadding))
      );
      int index = gridCoords.x + gridCoords.y * gridSize.x;
      print(gridCoords);
      return 0;

  }

  public void OnPointerClick(PointerEventData eventData)
  {
    RectTransformUtility.ScreenPointToLocalPointInRectangle(
          transform as RectTransform,
          eventData.position,
          eventData.pressEventCamera,
          out Vector2 localPoint
      );
      GetSlotIndexFromPosition(localPoint);
  }```
brave robin
#

And are rows and/or columns a fixed count, or completely flexible?

teal elk
brave robin
# teal elk Yes, I'm using a GridLayoutGroup component to arrange my inventory slots. I have...

So this may not be what you want to do, but what I did avoided having to do any math when an inventory slot was clicked on. When the inventory was refreshed I iterated over all the children in the layout group to grab the slots, and add them to a list. The inventory button in its onclick would run a method on a script to tell the inventory that it was clicked, with a reference to itself. The inventory would get notified, and knows that if the 7th slot is clicked, and the column count is 5, then it must be the 2nd column and 2nd row slot, for example

teal elk
brave robin
#

Ohhh, so items have different shapes. Yeah, sorry, my method won't help you there

#

Though if you are getting negative values it might be because canvas coordinates start at -(x/2) and go to x/2, rather than 0 to x

#

So if canvas width is 1920, the far left is -960 and not 0

teal elk
glad shore
#

how can i make a material not stretch when scaled on a object

rich adder
#

if you are trying to build a map or something with Unitys primitives , it would be easier to use probuilder as it already does the non-stretching by default cause you're not messing with scale but with extrusion

grand snow
#

the old scale a cube method doesnt go far

glad shore
languid pagoda
#

how should I handle user created UI? I can implement whatever in the scripting language but I dont really know of an option that fits my needs. Only know of two solutions. 1) Use built in UI, users can go in unity and create a ui and use my supplied mod tools to build it to an asset bundle then load it at runtime via the scripting language(assembly script through webassembly) only issue is this does not work with unities event system smoothly. I am fairly certain it wouldn't even be possible to have the event system fire off a method in the scripting language. So my second thought was use CEF instead, but it tanks fps with all of the overhead it has.

Are there any other options?

umbral hound
languid pagoda
umbral hound
#

oh okay

#

so omit that

languid pagoda
#

no

umbral hound
#

Okay...

umbral hound
languid pagoda
#

get the absolute value of movementVector.x and movementVector.y this will convert it to a positive number in the event it is negative

#

then

umbral hound
#

Oh okay

languid pagoda
#

for example
if (magnitude > 0f && (absoluteX > 0.25f || absoluteY > 0.25f))

#

use that insteads of the line I sent

#

0.25f can probably be much lower

#

id assign it to a variable you can tweak in the inspector

umbral hound
#

Okay this doesn't work

public void Update(float magnitude, float speed)
{
    Vector2 movementVector = PlayerInput.Instance.Input.Player.Move.ReadValue<Vector2>();
    Vector3 vector;
    if (magnitude > 0f && (Mathf.Abs(movementVector.x) > 0.25f || Mathf.Abs(movementVector.y) > 0.25f))
    {
        vector = DOHeadBob(magnitude + speed);
    }
    else
    {
        vector = Vector3.Lerp(m_CameraContainer.localPosition, m_OriginalCameraPosition, 0.2f);
    }
    m_CameraContainer.localPosition = vector;
    m_CurrentCameraPosition = m_CameraContainer.localPosition;
}
#

It still fluctuates current camera position

languid pagoda
#

when stopped?

umbral hound
#

yes

languid pagoda
#

than that means magnitudes is greater than zero and the absolute value of movementVector.x or movement vector.y is greater than 0.25

polar acorn
cerulean bear
#

is this how you make an enum most efficient

public enum BackgroundType
{
    Coastal_City = 0<<1,
    Port = 1<<2,
    Night_City = 2<<3,
}
umbral hound
#

It could be in my player movement, I only normalized my vector2 magnitude if it is greater than 1

cerulean bear
polar acorn
languid pagoda
polar acorn
#

Hint: 2 in binary is 0000 0010

languid pagoda
#

IM just curious what you mean by making enums more efficient like?

cerulean bear
#
00001000``` which is 8
polar acorn
languid pagoda
#

oh the answer to the question is literally dont use bit shifting in enums

polar acorn
polar acorn
cerulean bear
#

so instead 16 ig, also is this better than to avoid confusion

public enum BackgroundType
{
    Coastal_City = 1,
    Port = 2,
    Night_City = 4,
}```
grave bluff
#

Isn’t enums just integers represented by word constants

polar acorn
grave bluff
polar acorn
#

So, since 1 in binary is... 1, it's easiest to start there and shift it however many you need

cerulean bear
#

ohh so like 0<<1, 1<<1, 2<<1, 3<<1 just direct counting

polar acorn
#

It's [number] << [amount to shift by]

#

So 3 << 1 would be 0000 0110

cerulean bear
#

oh ok

languid pagoda
#

Just because im curious why does night city have to be 4 instead of 3?

cerulean bear
#

i was trying to go 1 2 4 8

polar acorn
#

So, you can't use bit masking to combine values

#

Because that would make Night City be the same number as Coastal City AND Port

cerulean bear
#

do I need to go like [Flags] at the beginning and then BackgroundType: short and then do all the stuff

languid pagoda
#

yes but im tryhing to find out what his reasoning is to not just use an enum like this

public enum BackgroundType
{
    Coastal_City,
    Port,
    Night_City,
}
#

oh

#

you're using flags

polar acorn
#

(also some internal compiler thingies to make it take up less memory)

cerulean bear
#

so this right


[System.Flags]
public enum BackgroundType: short
{
    Coastal_City = 1<<0,
    Port = 1<<1,
    Night_City = 1<<2,
}```
polar acorn
#

That would work. The : short is there as a memory optimization if you've got 16 or fewer values

cerulean bear
#

oh ok ty

polar acorn
#

The default bit size of an int is 32. Shorts are 16 bit, chars are 8

#

(I don't actually know if you can make char enums in C#, I haven't checked)

slender nymph
#

just note that unity doesn't like to serialize enums that aren't backed by int32

polar acorn
slender nymph
#

oh actually it should serialize the enum as long as it is 32 bits or shorter. so don't make an enum backed by a long and it should be fine

cerulean bear
polar acorn
#

You can ignore them for now and wait for a patch

cerulean bear
#

should i restart it I have almost no progress yet

polar acorn
#

It's with the new updates they pushed out to fix the vulnerability. It was a rush job and there's still problems with it

#

So just ignore it and wait for more updates

cerulean bear
#

alr ty

random lodge
#

Glad I didn't update then

true pine
#

how do I fix this?
the material is projected on a quad but idk how to adjust it's rotation to point outward from the surface it's on

rugged beacon
#

ignore x or z rotation but consider using decal for this case instead

true pine
#

how do decals work exactly

rugged beacon
#

its a sticker to the surface, you can look how to use it on some tutorial

polar acorn
true pine
true pine
#

gotcha

glad shore
#

how do i stop animation from looping

polar acorn
#

Uncheck the loop box on it

glad shore
polar acorn
#

Why the thumbs down. That's literally what you do

polar acorn
#

You disable looping on a specific animation

glad shore
#

gng where

grand snow
#

double click DoorOpen in the Motion field to go to the animation itself

glad shore
#

Motion field?

#

OHH

polar acorn
#

Not the Animator. Not a state in the Animator. But an Animation file.

glad shore
tacit prism
#

my MainCameraTransform is resulting null despite using it in my test state for movement

if you need more information ill gladly give it

fast relic
tacit prism
#

uh i uh uhm

#

gives me "forgot to put thermal paste" vibes rn.

fast relic
#

lmao

#

everyone has dumb moments sometimes

cerulean bear
#

How to do ragdoll physics with HingeJoint2D mine just stays in one piece

rich adder
stray wave
#

Guys I’m a Roblox developer I’d say late intermediate with lua wanting to learn unity, who would y’all recommend I watch to learn?

radiant voidBOT
stray wave
#

appreciate ya

umbral hound
#

The others go to 0 once I stop moving

tacit prism
#

trying to find a way to establish a single input for targetting and un-targetting enemies, and im trying to do it inside my inputreader, but i feel as though this certainly wont work. Will i have to work this out later inside the targetting state

#

i know for certain this wont work so im kinda just wondering where i should go with this to make it work

polar acorn
#

Not sure what's the point of the two if statements. If the first one is true, it'll end immediately. If the first one is false, so will the second

#

Ah, I think I see what you're getting at. Remember that a full function will always run to completion, it doesn't "pause" when you return.

You'll need to store a Boolean value and check that before doing one of the two actions, then flip the boolean

ivory bobcat
tacit prism
#

Thank yall very much

random lodge
#

paste the reply as a comment for later lol

frigid sequoia
#

So why is that I am catching hovering over "Gear" and "UIGearSlots" but not "DropTableItems"? These two are basically the same layout. Am I missing something?

ivory bobcat
#

Given said code, I'm assuming you're asking why the second case in the switch statement isn't occurring.

#

Else it's likely an XY problem where the information (code) provided probably isn't directly the problem.

frigid sequoia
#

Apparantly another raycast target sprite was above it, weird, cause it was way smaller than the target box, but it's solved now

sour fulcrum
#

absolutely nothing sus here

naive pawn
gaunt cipher
#

hey guys why is playerprefs bad?

hexed terrace
#

They're not "bad" bad.. they have a purpose, and that purpose is not saving a game state. They're easily edited and only support like 4? types.

#

Use them for saving game settings, not game state/ progress

hallow relic
#

name = input('ENTER YOUR NAME: ')
age = int(input('ENTER YOUR AGE: '))

if age > 13:
print('YOU ARE ELIGIBLE')
else:
print('YOU ARE TOO SMART TO JOIN')

print(f"HI {name}, YOU ARE {age} YEAR OLD. MOST WELCOME TO JOIN!")

hallow relic
silk night
lavish magnet
#

My character shoots a barrel, best way to make the barrel break apart on impact or chip away as each shot hits, doesnt have to break where hsot hits

silk night
#

There is also some nice destruction systems on the asset store, coding that from scratch is a challenge that exceeds what we can teach you here

lavish magnet
silk night
lavish magnet
lavish magnet
#

Thanks g

tender mirage
#

Hey there. i'm trying to destroy a single unit tile, but i can't get it to work.

using UnityEngine;
using UnityEngine.Tilemaps;

public class TileScript : MonoBehaviour
{
    private Tilemap Tilem;

    private void Start()
    {
        Tilem = GetComponent<Tilemap>();
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        float PosX = collision.transform.position.x;
        float PosY = collision.transform.position.y;
        float PosZ = collision.transform.position.z;

        int IntPosX = Mathf.FloorToInt(PosX);
        int IntPosY = Mathf.FloorToInt(PosY);
        int IntPosZ = Mathf.FloorToInt(PosZ);

        Vector3Int Position = new Vector3Int(IntPosX, IntPosY, IntPosZ);

        if (collision.gameObject.CompareTag("Ball"))
        {
            

            //Destroy appropriate tile at position
            Tilem.SetTile(Position, null);


        }


    }
}
sullen epoch
tender mirage
# sullen epoch Your Collider gets world position, but i don't think tile-maps use world positio...

... You're absolutely correct.

trying out cellToWorld. gotta use it correctly


        float PosX = collision.transform.position.x;
        float PosY = collision.transform.position.y;
        float PosZ = collision.transform.position.z;

        int IntPosX = Mathf.FloorToInt(PosX);
        int IntPosY = Mathf.FloorToInt(PosY);
        int IntPosZ = Mathf.FloorToInt(PosZ);

        Vector3Int Position = new Vector3Int(IntPosX, IntPosY, IntPosZ);

        Vector3Int CellPosition = Tilem.CellToWorld(Position.ConvertTo("Vector3");

        if (collision.gameObject.CompareTag("Ball"))
        {
            print("Position" + Position);

            //Destroy appropriate tile at position
            Tilem.SetTile(Position, null);


        }
hallow relic
hallow relic
silk night
twin pivot
tender mirage
#

Wait until somebody starts posting assembly here.

#

πŸ˜‚

sullen epoch
#
AnimationClip target = angle switch
        {
            >= 337.5f or < 22.5f => walkRight,
            >= 22.5f and < 67.5f => walkUpRight,
            >= 67.5f and < 112.5f => walkUp,
            >= 112.5f and < 157.5f => walkUpLeft,
            >= 157.5f and < 202.5f => walkLeft,
            >= 202.5f and < 247.5f => walkDownLeft,
            >= 247.5f and < 292.5f => walkDown,
            >= 292.5f and < 337.5f => walkDownRight,
            _ => idleClip
        };```

i'm studying this switch case because I've never seen one so simplified before. what i want to know is if all switch cases can be simplified like this, or if it only works because its working with a single return and input value
silk night
rocky canyon
#

if u had much more logic you'd resort to the classic switch statement

#

i think its relatively new..

sullen epoch
#

thanks! i found some documentation on it but i'm not sure how would it handle multiple return types?
with it being assigned to an AnimatioClip Variable

rocky canyon
#

anytime i see simple keywords or conjunctions like that I have to go check if it works in unity (what version of c# it is) an all that lol

#

i believe u can use var to do multiple return types

#

but dont get me lying edit: i was lying.. has to be a single return type

sullen epoch
#

yeah, seems like that's when standard switch case is needed

#

i suppose you could use var to return multiple data types at once, but each case would still need a return for all of the data types

rocky canyon
#

nah i dont think the var thing i mentioned would work.. i believe ud get a compile error im just not sure exactly what it would be

#

you could however us a struct w/ multiple types..

silk night
rocky canyon
#

and have the switch just assign the things it needs

grand snow
#

That switch expression is because all branches return the same type yes

#

Though for selecting an animation id not go with such a hard coded approach myself

sullen epoch
#

i'm open to suggestions, i prefer not use use Unity's animation controller when animation blending isnt needed

rocky canyon
#
    public struct DesiredColor
    {
        public Color color;
        public string hex;
    }

    DesiredColor GetDesiredColor(string mood)
    {
        DesiredColor data = new();
        switch (mood)
        {
            case "Happy":
                data.color = Color.yellow; // only assign color
                break;

            case "Angry":
                data.hex = "#FF0000";      // only assign hex
                break;
        }
        return data;
    }

having a struct u could technically "return" different types just by reading the struct afterwards...
(you'd technically be returning the same type of container.. but u could chose what parts of it were assigned)

grand snow
rocky canyon
#

very true, my 8direction sprite system worked like that..
i used a blendtree with my thresholds being 0 - 7 (ints) and a blendtree to shift thru them

sullen epoch
#

so use a basic array to store my animations, presumably clockwise order and use an index based off the angle?
so angle = Mathf.Floor((angle / 45 ) % )?

#

or somthing similar

sacred cradle
#

i had a question if i put a collider on a game object but the player horse is kinematic can i do the physics collision through coding? so it behaves like a normal collision

midnight plover
#

oh wait, the horse is non kinematic, so it should use physics

sacred cradle
#

its kinematic

#

and yes its moved by transform.position

midnight plover
#

I am not sure you can fire the physics check outside of the already present physics loop. if you bypass it with transform.position (which is wrong in the first place), then you bypass it. The only thing you could do is predict if its going to collide I guess

#

is there any reason, you are not using Rigidbody.MovePosition?

sacred cradle
#

well i tried to use it yesterday i did spend 2 hours for it but the whole project is based on transform.position and when i use rb.moveposition the control becames weird

midnight plover
#

Sounds to me, like you gotta make a decision here. Use physics or not. If you want to, you need to comply with the physics system and therefore move the rigidbodies correctly. Otherwise you are always just teleporting and ignoring physics leading to glitching through walls or what not.

sacred cradle
#

hmm i think i can detect collision in script but idk how will i code it so it works like a collision

sacred cradle
midnight plover
#

you gonna end up rewriting a physics system, if you want to manually detect "collision".

sacred cradle
#

fights with wall collider

midnight plover
#

So you are trying to moveposition it behind the wall and at some point it will go through? are you using the moveposition at the right place?

sacred cradle
#

hmm when i decrease the horse speed it works fine but when i increase the speed it fights with wall collider and slowly pullthrough it

midnight plover
#

Are you using moveposition in update?

sacred cradle
#

fixedupdate

midnight plover
#

Hm, than that should not happen. What type of collider is the wall?

sacred cradle
#

mesh collider and its a fence

#

but when i create a simple box collider just for testing it pullthroughs it too

#

but when i decrease speed it works at least

hot wadi
#

If the movement gets weird, it’s probably your control logic

sacred cradle
sacred cradle
hot wadi
hot wadi
sullen epoch
#

question, inside your Rigidbody is collision detection mode set to discrete or continuous?

naive pawn
naive pawn
naive pawn
naive pawn
#

the sensible/valid options here are:
no rb, move with transform.position - no collision detection
kinematic rb, move with Move/MovePosition - potential collision detection with other dynamic rbs, but won't obey collisions automatically
dynamic rb, move with AddForce or linearVelocity - detects and obeys collision

sacred cradle
#

thanks for the help i will try it and will let you know?

sullen epoch
#

can i ask why you opted to go kenetic?

naive pawn
#

(note - kinetic and kinematic aren't the same)

sullen epoch
#

i completely misread πŸ˜…

#

i always thought it was called kinetic

hot wadi
#

I use dynamic but without gravity in one of my games. I move it by transform.Translate() and it seems fine for now

naive pawn
midnight plover
#

Just read a thread which sums it up quite good. MovePosition can be used to move things out of the way while you are moving. Its not meant to be used for movement restrictions like a wall, because you can move through it at some point as you just experienced with higher speeds.

naive pawn
#

MovePosition can be used to move things out of the way while you are moving.
for kinematic rbs, yeah
i feel like it could have some weird effects with dynamic rbs and depenetration thonk

#

it's a pretty common mistake to use MovePosition with dynamic rbs

tacit prism
# ivory bobcat If you're trying to flip the behavior with every execution maybe use a bool as a...

I think i understand what your putting here, and hopefully i mish mashed it right

basically if the target event is already targetting, it will turn target into the cancel event
otherwise, it will turn target into the target event

so that even if its null for the cancel event it will still change to the target event?

and then invoke

I havent gotten to the point where i can debug this but thanks for the help anyhow! gotta go to work now thisisfinae

i doubt this is an efficient way of doing it, but that’s what refactoring is for anyhow, plus im just practicing with statemachines at the moment so its fine if it doesn’t work perfectly

elder canyon
#

If I'm gonna have multiple characters that I can possess and control. Like a dog, human and a drone. Do I need PlayerInput component for all of them?

tacit prism
#

Oh speaking on this ^

If I have several levels, I can seperate the levels into scenes correct? And then just drop the prefab player into the level? I haven’t worked on saving shit yet, so I don’t know anything about what carries over if you use a prefab outside of attached objects but it sounds about right

grand snow
#

The beginner friendly way is some singleton to aid in retaining this data accross many scenes

tacit prism
#

I thought so, thanks :)

grand snow
#

If you have everything in some class then you can just re assign the reference on the new player object after the scene has loaded.
Otherwise yea a singleton is easier for beginner programmers

tacit prism
#

Will have to look into them, but after my study on state machines

naive pawn
still ingot
#

Hi I have been getting this error for a while and it says I am missing a reference for TextMeshProGUI but I already have references for it?

grand snow
#

does the code compile in the editor? or is the same error happening there too

still ingot
grand snow
#

then its probably an issue with the visual studio sln generation. you can try regenerating it in preference > external tools (there is a button)

#

unity handles compilation so if its okay there its good

supple crescent
#

Is this video a good way to start learning C# for unity?
https://www.youtube.com/watch?v=0QUgvfuKvWU

Check out the new Foundational C# Certification by freeCodeCamp: https://aka.ms/csharp-certification

Classic Throwback Series with Bob Tabor | Originally published in 2019
Install the latest version of Visual Studio at https://visualstudio.microsoft.com/?WT_mc_id=dotnet-58793-cxa and follow along at home too.

C# is a powerful and widely used p...

β–Ά Play video
eternal needle
neon verge
#

guys is this a good way to move my player left right up and down

private void Update()
    {
        moveAmount = moveAction.ReadValue<Vector2>();
        Vector2 normalizedInput = moveAmount != Vector2.zero ? moveAmount.normalized : Vector2.zero;
        currentVel = Vector2.SmoothDamp(currentVel, normalizedInput, ref velocityRef, accelTime);
        Vector3 movement = new Vector3(currentVel.x, currentVel.y, 0f) * moveSpeed * Time.deltaTime;
        transform.position += movement;
    }```
odd remnant
#

I'm making a first-person game that allows players to click and hold to pick up and move rag-doll physics objects. Can someone validate my thinking here:

  • The FirstPersonController will convert inputs into game actions (tracking whether the player is actively holding an object).
  • But who should be responsible for updating the object's transform values in space? The FirstPersonController? Or the object itself? (By checking to see if it's being held, and updating its position accordingly)
neon verge
wintry quarry
#

tracking whether the player is actively holding an object
This should be in the same script as the grabbing/holding logic

#

Usually FirstPersonController sounds like a script that would just be handling player movement

#

seems like responsibility creep to have it handle other things too like grab/hold stuff

#

Also if it's a Ragdoll physics object, you should almost certainly not be doing this by modifying the Transform directly

odd remnant
# wintry quarry Could be FirstPersonController or you could make a separate script specifically ...

Yeah, I've been wondering about that. Because there's a two-directional relationship here. The object is grabbable (because it has the GrabbableObject script on it). And it can only be grabbed by a single player - which means the object itself needs to know if it's being grabbed.

Similarly, the player can only grab objects if they aren't currently grabbing any other object. So the player needs to know that they're actively grabbing an object.

odd remnant
wintry quarry
#

And it can only be grabbed by a single player - which means the object itself needs to know if it's being grabbed.
This can be handled by a very simple/lightweight script either on the object or some centralized "grab manager" that handles registering objects to players.

I want players to be able to pick up an object by selecting a point on it, and the object "hangs" from that point.
Typically done using a Kinematic Rigidbody and a HingeJoint

odd remnant
#

Perfect. I'll look into these.

#

I have a "GrabbleObject" script on the object itself. But it sounds like a GrabManager might adhere to my architectural principles so far.

wintry quarry
# odd remnant Perfect. I'll look into these.

i.e. you make an invisible kinematic rigidbdy at the "hold point", attach the grabbed object to the invisible object via the HingeJoint. And to move the kinematic RB you use Rigidbody.MovePosition in FixedUpdate

#

but yeah having scripts on both objects (the grabbee and the grabber) is a pretty common pattern. Like "Grabber" and "Grabbable"

odd remnant
#

Pedantically - would the script that manages the grabbing be called "Grabber" or GrabManager? Is there a general deliniation between a Manager and non-Manager script?

hot wadi
#

Typically manager is DontDestroyOnLoad. But it's just a name

odd remnant
#

Ok, thanks!

wintry quarry
# odd remnant Pedantically - would the script that manages the grabbing be called "Grabber" or...

Grabber I was imagining as something on the player object that handles grabbing grabbables and moving them around. Assuming there's multiple players, each one would have a Grabber, so there would be multiple Grabbers in the scene.

GrabManager I was imagining as a singleton in the scene handling keeping track of which objects are being grabbed currently by which players that Grabbers could use to make sure they're not grabbing an object that another Grabber has grabbed.

odd remnant
wintry quarry
#

yes, Grabbable would be a script on the objects you can grab. Grabber would look for these objects when trying to grab things.

odd remnant
#

Interesting. I'll think about the Grab Manager. I'd assumed that the Grabber could simply check whether the GrabbleObject was grabbed or not, and that would be sufficient.

#

I'm not sure I understand the need for a GrabManager - though if I were to guess, it's a bit easier (or more performant?) to reference a single Manager, rather than checking multiple objects in a scene?

wintry quarry
#

if the GrabbableObject keeps track of the Grabber that is currently grabbing it

tender mirage
#

hey there, i'm trying to erase specific tiles from the tilemap that have touched a specific tile



    private void Update()
    {


        if (Mouse.current.rightButton.wasPressedThisFrame)
        {


            //Randomize tile
            int RandomTile = Random.Range(0, Tiles.Length);

            Tilem.SetTile(Tilem.WorldToCell(Position), Tiles[RandomTile]);
        }


        if (Keyboard.current.rightArrowKey.wasPressedThisFrame)
        {
            Position.x += 1;
        }
        if (Keyboard.current.leftArrowKey.wasPressedThisFrame)
        {
            Position.x -= 1;
        }
        if (Keyboard.current.upArrowKey.wasPressedThisFrame)
        {
            Position.y += 0.25f;
        }
        if (Keyboard.current.downArrowKey.wasPressedThisFrame)
        {
            Position.y -= 0.25f;
        }
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {


        if (collision.gameObject.CompareTag("Ball"))
        {
            Tilem.SetTile(Tilem.WorldToCell(collision.transform.position + Vector3.right), null);
            Tilem.SetTile(Tilem.WorldToCell(collision.transform.position + Vector3.left), null);
            Tilem.SetTile(Tilem.WorldToCell(collision.transform.position + Vector3.up), null);
            Tilem.SetTile(Tilem.WorldToCell(collision.transform.position + Vector3.down), null);
            
        }

    }

But the tiles aren't deleting vertically as the world to cell position doesn't align with my rectangle shaped tiles

wintry quarry
tender mirage
#

Basically when a ball hits these colored tiles, they're suppose to be destroyed

wintry quarry
tender mirage
#

it's on the tilemap

#

game object.

wintry quarry
#

i.e. have you checked what position is being calculated by Tilem.WorldToCell(collision.transform.position + Vector3.left) etc?

#

it also looks like you're trying to set the tile on all the cells around the ball but not where the ball actually is

#

I think it would also be more accurate to use collision.GetContact(0).point instead of the position of the ball

#

And if you want to calculate the tile that the ball actually hit you normally would offset that position using the collision normal by half of a tile width as well

tender mirage
#

i see. It gets abit overwhelming getting to know the whole tilesystem for the first time. i just learnt about the tilemap basics today.

wintry quarry
#

so something like:

Vector2 hitPoint = collision.GetContact(0).point;
Vector2 normal = collision.GetContact(0).normal;
Vector2 hitTilePosition = hitPoint - normal * Tilem.cellCize.x // or y for up/down;

Vector3Int hitTileCoordinate = TileM.WorldToCell(hitTilePosition);```
tender mirage
#

Curious. i normally use contacts[0].normal.

Is GetContact the same? it looks functionally similiar

wintry quarry
#

if you do collision.contacts it allocates a brand new array every time which will need to be garbage collected

floral garden
#

hi i have a question