#💻┃code-beginner

1 messages · Page 746 of 1

fast relic
#

you need the IPointerEnterHandler and exit handler interfaces

cosmic dagger
#

Did you check OnMouseEnter in the docs to ensure how it works?

shell sorrel
#

also wtf you are the same person i pointed at the IPointerXHandlers

dry tapir
#

.< i just want the camera to scroll a little when hovering on a collissionbox. why is this so damn complicated

shell sorrel
#

like 30 mins ago

fast relic
#

-# also we told you exactly what to use already

dry tapir
#

sorry guys

edgy sinew
cosmic dagger
fast relic
edgy sinew
#

Guys … Is there not an absolute mouse position in Unity new input system …

edgy sinew
#

Can he not just do
if (mouse.x < 10) type thing …

slender nymph
edgy sinew
#

It was rhetorical, I used absolute mouse position before and delta

slender nymph
cosmic dagger
edgy sinew
#

He’s using AI

#

We want to save time here clearly

fast relic
dry tapir
#

All i want is "if mouse hovering on this collider. Scroll to this side".

I know i aint that crazy for thinking this should he the simplest thing to do, right?

fast relic
cosmic dagger
edgy sinew
#

Sorry to assume - either way.

fast relic
#

we already told you what to look for

dry tapir
edgy sinew
dry tapir
#

I just created a colider of the size i wanted and added that script

true pine
edgy sinew
#

As I understand, the script (MonoBehaviour component) has to be on the same object

#

You’re able to see your mouse go over the object right?

fast relic
dry tapir
fast relic
dry tapir
#

I just feel stupid.

true pine
edgy sinew
dry tapir
#

Wait. Just asking. To use this new imput system i jave to download some add on or package?

fast relic
true pine
#

it's part of the gamedev process to feel like a worthless emptyheaded failure

fast relic
edgy sinew
#

So… Do you have a 2D Box Collider next to the HoverDetector2D
Those r gonna be stacked up in the inspector vertically

dry tapir
#

Oh okie

slender nymph
true pine
dry tapir
#

Im on 6000.2.6f2

fast relic
fast relic
slender nymph
dry tapir
#

Okay.

I probably should watch "unity for beginners" videos until i have a firm bedrock to build on.

edgy sinew
#

This is happening on the UI right?
Also why not switch to Unity 6.0 🥲

fast relic
cosmic dagger
fast relic
dry tapir
fast relic
dry tapir
#

Mone other reason im confused likek thisnis because i was used to wing it in renpy. Just improvize to hell

fast relic
edgy sinew
#

Does he not use a Rigidbody and 2D Box collider?

fast relic
dry tapir
#

Heres what i have:
Clicked to install unity installed requirements that popped up.

Thats all i have

fast relic
edgy sinew
dry tapir
#

Thats what i used to say to a friend of mine that got into renpy too lol

#

My expectations were unrealistically, to learn and use unity to make a game under 20 days

fast relic
#

you just need to approach it right

dry tapir
#

Im just a lil scared of trying, qnd not being able to deliver to my subs anything. Becauee i focused on this surprise halloween game instea dof my current in development game

fast relic
#

and not do it just for the end result, you need to take your time to learn

edgy sinew
#

Guys … check the tutorial person’s Unity version at the top of their window lol thinksmart

dry tapir
fast relic
#

learning something new is always good

dry tapir
#

XXDDDD

fast relic
#

and making mistakes is how you learn

#

ive written plenty of horrible spaghetti that barely worked

dry tapir
#

Im humbler than when i entered the aerver so i say its progress

#

X3

edgy sinew
#

Does OnMouseEnter not work with Rigidbody2D anymore?
ok real funny y’all fine i’ll just find out myself eventually lol

dry tapir
#

Question. Should i watch any unity video?

Even if my game will be 2d, a 3d video will still help me?

slender nymph
edgy sinew
#

EventSystem.current.IsPointerOverGameObject() ?

slender nymph
#

!learn

radiant voidBOT
cosmic dagger
edgy sinew
fast relic
edgy sinew
# fast relic `OnMouseEnter` is for the old input system

🚨 Wishlist Revolocity on Steam! https://store.steampowered.com/app/2762050/Revolocity/ 🚨 If you're wondering how to use OnMouse Down / OnMouse Enter or OnMouse Exit with the Unity's new input system then hopefully this Unity tutorial will help.

📁 Get access to my tutorial project files over on Patreon: https://www.patreon.com/danpos

...

▶ Play video
#

Exactly what Cookie was talking about, implementing those interfaces. It’s a 4 minute video u got this

#

Learning together! UnityChanThumbsUp

glad shore
#

whats a quaternion ✌️

fast relic
#

but all you need to know is that you can do Quaternion.Euler() to use normal xyz angles

cosmic dagger
glad shore
#

yeah, but i want to understand it

#

i want to know how it works

fast relic
#

sec

ivory bobcat
# glad shore whats a quaternion ✌️

https://unity.huh.how/quaternions#what-are-they

What are they?

Quaternions represent rotations and orientations.

Quaternions are four dimensional, but don't be frightened—unless intending to learn their mathematical implications—this doesn't affect practical usage in Unity.

To use them you don't need to understand how they work, or what their components represent.

glad shore
#

i want to learn their mathematical implications

fast relic
glad shore
#

oh god..

lean tartan
#

Hello, I'd like to buy some Unity Android Game Sources, specifically fighting game (similar to these ones : Vita Fighters, Final Fighter, etc). DM me if you got.

glad shore
fast relic
# glad shore just looking at the embed im already confused

and also quaternions and 3d rotation for how they're actually used for rotation

How to think about this 4d number system in our 3d space.
Part 2: https://youtu.be/zjMuIxRvygQ
Interactive version of these visuals: https://eater.net/quaternions
Help fund future projects: https://www.patreon.com/3blue1brown
An equally valuable form of support is to simply share some of the videos.
Special thanks to these supporters: http://3b1...

▶ Play video
#

and hey, you said you wanted to understand the maths i'm giving you the maths

glad shore
#

ima just stick with Quaternion.Euler ✌️

fast relic
#

haha understandable

#

but they are pretty interesting if you're a maths nerd

ivory bobcat
eternal needle
radiant voidBOT
# ivory bobcat !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**

glad shore
glad shore
fast relic
#

i've sent you the resources if you want to know

#

it's pretty interesting, i'd recommend you at least watch the 3b1b video

eternal needle
cosmic dagger
fast relic
#

for unity you don't need to understand the maths, but if you like maths it's definitely interesting to look at

glad shore
#

is this the best way to find the farthest room(GameObject) from the player?

if (_spawnedRooms.Count > 4)
        {
            GameObject _farthestRoomAway = _spawnedRooms[0];
            float dist = 0;
            float[] distances = new float[_spawnedRooms.Count];
            for (int i = 0; i < _spawnedRooms.Count; i++)
            {
                distances[i] = Vector2.Distance(_spawnedRooms[i].transform.position, _player.transform.position);
                if (distances[i]>dist)
                {
                    dist = distances[i];
                    _farthestRoomAway = _spawnedRooms[i];
                }
            }
            Destroy(_farthestRoomAway);
            _spawnedRooms.Remove(_spawnedRooms[0]);
        }
fast relic
#

it's fine but you can use the squared distance instead, for comparison it works pretty much identically

eternal needle
#

Just make it a float

glad shore
#
if (_spawnedRooms.Count > 4)
        {
            GameObject _farthestRoomAway = _spawnedRooms[0];
            float dist = 0;

            for (int i = 0; i < _spawnedRooms.Count; i++)
            {
                float newDist = Vector2.Distance(_spawnedRooms[i].transform.position, _player.transform.position);
                if (newDist>dist)
                {
                    dist = newDist;
                    _farthestRoomAway = _spawnedRooms[i];
                }
            }
            Destroy(_farthestRoomAway);
            _spawnedRooms.Remove(_spawnedRooms[0]);
        }

Like this?

#

atp i can just put it in the if statement

sour fulcrum
cosmic dagger
eternal needle
rugged beacon
glad shore
edgy sinew
#

Is this a dictionary no?
roomID or object, distance

#

Or per instance of each room?

rugged beacon
#

you should take account of the hallway length then, since hallways turn then the real distance isnt true anymore

glad shore
edgy sinew
#

Nice work. I’ve never even heard of a Ceiling Lip

glad shore
edgy sinew
glad shore
#

that would give me a estimated point ig

edgy sinew
#

If it can work as you like without knowing the exact vertice positions, then it’s good

#

I like to get extra info to work with up front

tacit prism
#

IT WORKS, LETSGO (the player pausing with the animation playing is it entering the target state, target state has no content inside of it right now though so it stays still)
thanks again @ivory bobcat

i wonder if theres a more efficient way of doing this though, i dont like that trying to use one input to confirm/cancel a state has to take up 11 lines

any ideas?

tacit prism
#

hah your funny words dont work if i dont understand them wizard man

truthfully though no rigidbody, learning about statemachines at the moment

edgy sinew
#

You need… a toggle right?

#

One button, switches you to the opposite state?

glad shore
#

I need a way to stop generating rooms inside of eachother (overlapping) but i dont know how, this is what i have currently but it doesnt work as intented

_currentRoom = door.transform.parent.gameObject;
        //the room that the door that was just opened is in
        bool _generate = true;
        if (_roomsAhead > 0)
        {
            Collider[] roomsInArea = Physics.OverlapBox(door.transform.position, new Vector3(5, 2, 5), Quaternion.identity);

            foreach (Collider room in roomsInArea)
            {
                if (_currentRoom == room.transform.parent)
                {
                    _generate = false;
                }
            }
        }
        if (_generate)
        {
            GameObject _room = Instantiate(_rooms[Random.Range(0, _rooms.Length - 1)], door.transform.position - door.transform.up * 5, door.transform.rotation);
            _spawnedRooms.Add(_room);
        }
tacit prism
#

still not sure what ur asking, and i really dont want to keep throwing in images, but as far as i learned i just made an input reader, and built every action off the events subscribed in the input reader to the statemachine

edgy sinew
tacit prism
ivory bobcat
#

Number of lines does not equate to performance.

tacit prism
#

its gives to readability though

glad shore
edgy sinew
#

Everyone likes their code a different way.

ivory bobcat
#

I feel that less number of lines is often less readable

edgy sinew
#

I would think Unity has something built in for this but, you can do it yourself easily too ..

glad shore
#

"easily" 😔

glad shore
edgy sinew
#

Easier in 2D but you know the height of the rooms too right or …

glad shore
edgy sinew
#

It’s gonna be real easy if each room has all that info attached

glad shore
#

thats what i was thinking but just sounds like a whole lotta extra work 😔

edgy sinew
#

spawnedRoom.width height etc

#

Like 4 months ago, I did exactly what you just did

#

Then you know what I tried to stop asking & just assume, Oh yeah that’s the way everyone does it probably & check online

#

There’s a video of Half Life Alyx game where they calculate at runtime the position and rotation of each foot & such

glad shore
#

i could make a collider trigger that covers the room then check if within that area

glad shore
edgy sinew
#

First do it for XZ, width depth… then the Y would use the “height”

glad shore
#

and some rooms will have very much different shapes

edgy sinew
#

Distance and minimum radius, yep

#

Do it spherically, make your objects fit within a certain sphere size, easy done

#

Or do rectangles, or do both, have a hybrid system with Polymorphism

glad shore
#

there is upstairs and downstairs so the sphere wont work

edgy sinew
#

You can make a new Component called “RoomData.cs” … Done, easy

#

When you create a room you attach that to it in script, or have it on the prefab originally is better.

glad shore
#

i thought of that but tried to avoid it

edgy sinew
#

That’s simply how a GameObject has other properties.

#

You can have a Dictionary or Hashset if you prefer not that way

#

Experts, chime in?

winged ridge
#

Procedural generation? Just do it on wall basis.. you can set rules, or just do it as a square then cut out the bits you don't need replacing the bits you do as it spawns

glad shore
#

wall basis?

edgy sinew
#

Every generated room can be represented more simply yeah

#

Like define 3 cubes .. that’s a curve, done, close enough

#

Then do the basic collision algorithm I sent + Y axis

#

Approximation is super valuable

#

You’d compare one list of cube defining numbers to another, rather than one cube defining numbers

#

It’s a lot easier to do it with distance and minimum radius though, so. Keep that in mind

glad shore
#

ur saying is that i should have multiple "bits" of squares to see the bounds of the room

edgy sinew
#

Basically a “do not spawn other stuff here” zone defined by that data yeah.

#

Width height, x y z

#

And depth oops.

glad shore
#

im so confused rn

#

i think i understand kinda

edgy sinew
#

This is the simple way to avoid doing extraordinary Physics stuff

#

“ Axis Aligned Bounding Box (detects collision between two rectangles) “

#

Radius & distance is simpler if you don’t mind longer hallways

#

Even simpler, multiple spheres! Oooh stonks

glad shore
#

alright so...
attach a component to each room with a list of a class that has (x,y,z,width,height) then when generating a room i just check if its within the bounds of room

edgy sinew
#

U should do multiple spheres … one list, another list, compare … So easy

#

distance = Vector3.Distance(sphere1, sphere2)
if distance < sphere1.radius + sphere2.radius // finding if 2 spheres overlap.

glad shore
#

you just confused me even more

#

ur comparing a vector 3 to a float

#

what

edgy sinew
#

Vector3.Distance gives u a float

glad shore
#

oh

#

OH

edgy sinew
#

I wrote it out more look

#

I tried to imply it mb so ya

#

Sphere is easier I would just do it that way Ngl

#

All u need is the xyz and radius, yeah attach the lists as a component

glad shore
#

plus i dont think squares would work because not all the rooms i have are only right angles

edgy sinew
#

Prefab easiest, u can expose lists to the Editor and do it by hand .. make a gizmo tool later if u want …

#

Or literally, make a bunch of spheres and write down the xyz and radius. For each “type” of room

glad shore
#

if it doesnt work or i have a problem, il come back to u

edgy sinew
glad shore
#

and should i use Physics.OverlapSphere?

edgy sinew
#

Wait You can do absolute position to absolute position too actually jk

edgy sinew
glad shore
#

then how would i check if its overlapping with the spheres

edgy sinew
#

The sphere way is easy because 2 spheres intersecting just depends on their distance and each of their radius right

glad shore
#

ahh yes, didnt think of that

edgy sinew
#

AI is stupid but it can find nice pictures and help u understand better

#

Shame it’s a 2D photo

glad shore
#
public class RoomData : MonoBehaviour
{
    public static float x, y, z, radius;
}

so i just calculate dist then if its > sum of radius then i dont generate

#

how do i make VS code stop putting these bum ah suggestions

winged ridge
glad shore
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Sphere
{
    public float x, y, z, radius;
}
public class RoomData : MonoBehaviour
{
    public List<Sphere> _spheres = new List<Sphere>();
}

all i did was write this and it was js there 🥀

edgy sinew
#

For two spheres, to be colliding, the sum of both of their respective radii must be greater than the distance between them

glad shore
edgy sinew
#

It’s the same thing with two dimensional circles. If the vector 2.distance

winged ridge
#

I still need the final one but >,> may wait a bit for that

winged ridge
glad shore
#

you gotta be like crazy good to get a certificate

#

you know to much ✌️

winged ridge
#

I got about 97% on the first link in my bio not sure if I still have the proof lol I'd have to find it

glad shore
#

bouta finish what i started

visual pond
#

anyone have any clue why those 2 are errors

glad shore
wintry quarry
shell sorrel
visual pond
#

ok imma run the error

wintry quarry
#

Your curly braces are also seemingly not matched properly

#

Maybe

shell sorrel
#

or who knows since you are not showing enough code

#

to now how the braces are matched and whats in what scope

visual pond
#

Assets\basicmovment.cs(67,9): error CS0106: The modifier 'private' is not valid for this item

#

wow

#

well uhh

wintry quarry
#

Private is only for members of the class

glad shore
shell sorrel
#

99% chance you messed up your braces and got a function defined in a function

#

show more

visual pond
#

thats void update

wintry quarry
#

We can't know that unless you share the full script

glad shore
wintry quarry
#

Show the full !code

#

!code

radiant voidBOT
visual pond
#

oh

#

alr

teal viper
#

This is not the full code either

wintry quarry
#

Not only isn't that formatted yeah it's not the full script

visual pond
#

seriously all of it?

#

ok

wintry quarry
#

Yes seriously

shell sorrel
#

you are defining dash inside of your update

#

it needs to be its own method separate from it

glad shore
#

bro im telling u what to do

#

just do that and it would work 🙏

visual pond
#

oh

#

it all works now btw

#

literally just had to take out private

#

no i just had to take out private

shell sorrel
#

no

#

it will compile when you do that but it will not do what you think its doing

visual pond
#

oh

shell sorrel
#

move the brace like suggested

ivory bobcat
#

Was it intended to be a local function 🤔

visual pond
#

im just following a toturial

rich adder
#

follow it better

ivory bobcat
#

If not, do what the others have suggested. If it was supposed to be a local function, it may be fine.

visual pond
#

ye ik

shell sorrel
#

and you mis placed a brace compared to the tutorial

glad shore
#

looking at everything but the image i sent 😔

visual pond
#

my movement code is different from his

shell sorrel
#

also its not enough to just follow the tutorial you have to think about what you are doing as you do it

glad shore
visual pond
#

hold on im finishing the code and testing it before trying it

#

yep it not showing errors

#

but its not working

glad shore
#

did u take my suggestion?

visual pond
#

trying

#

rn

glad shore
#

finally 😩

visual pond
#

it doesnt show errors

#

but not working

#

pretty sure i know the reason why

glad shore
#

if you dont know how to code, unity has courses you can take.

#

they teach u step by step on how to use unity

visual pond
#

i practically perma made it so X just responds to speed

#

i just need to know how to NOT do this

glad shore
#

is it bad that i havnt taken any of the courses, because ive lwky been just going with the flow

random lodge
#

They just need to get someone on that terrible site design for those pages.

winged ridge
hot wadi
polar acorn
tacit prism
# glad shore https://learn.unity.com/project/beginner-gameplay-scripting

I haven’t either

I’ve just started learning about state machine, and I don’t understand SHIT but

The more I do it the better and easier it gets. I’m still green on a decent amount, but because I’ve been playing around, and when I make mistakes I start debugging my own code, I’ve learned a LOT more than I have with courses like Microsoft’s C# or unities learn page

#

Granted I’m still going by a course, that explains state machines but

Playing around with the code is fun, and it’s teaching me a decent bit

hot wadi
#

That is the common way to do it. Look for common concepts and how they work, then start experimenting on them

rare grail
#

Im just loosing my sanity to why my camera shake won't work on enemy hitting the player. My theroy is that the trigger won't play well with a IEnumerator. or if and the return part isen't working well sadok

midnight plover
rare grail
#

loading up unity. and il get to showing it. but a little bit of feelings aswell.

north kiln
#

!ban 775300007905198131 racism

radiant voidBOT
rare grail
# midnight plover You just expressing your feelings or wanna show code? 😉

https://paste.myst.rs/lw7447hc So its a alot of parts to it. but its Workingcamerashake that works when i have tested it. that needs to work with Orb projectile, i can't add it to the part where player takes damage becuse then the code gets confused and you won't take damage. and i need to add it to the enemy part aswell. i have commented out on orb the parts i have tried, tried some ideas with If. with 0 progress.

#

i feel that its some really small change i need to do. to make it work. becuse it's so close to just work. sadok

nimble apex
#
Ray ray = Camera.main.ScreenPointToRay(Pointer.current.position.ReadValue());

Physics.Raycast(ray, out var hit, 20, LayerMask.GetMask("UI"));

if (hit.collider != null)
{
    hit.collider.gameObject.GetComponent<IWorldUIObject>().InvokeRaycastEvt();
}```
if i raycast UI layer, will it count on overlay UIs?
rare grail
#

🤔 il try that.

nimble apex
#

ok this is hard

rare grail
#

yeah. its on the VG part of this assigment for a reason 💀

#

they want a factory or builder and a enemy pool. (i just did a manger). aswell.

#

Im at G level and im proud of that after just having most experience in HTML/java before this. but i got that hunger of just. I can do this better

midnight plover
rare grail
#

yeah. when the enemy hits you, or when a Orb hits you.

nimble crystal
midnight plover
rare grail
midnight plover
#

Is it constantly firing the shake right now or what is happening?

rare grail
#

well i have gotten the shake to work in wierder ways. its silly but just for a experiement i added it earlier in the orb code. and it made the wizard enemys shake. 🤣

sudden pagoda
#

Could it be that in the code you are calling StopAllCoroutines on update?

rare grail
#

il try that

sudden pagoda
#

not sure how this interacts if it gets called every frame like this

rare grail
#

so that update part isen't klicking with the orb part.

#

Im closer to a result. its now just screaming after object refrence.

#

even after i added player = player.GetComponent<Player>();

sudden pagoda
#

In the meantime, could I ask for some support here? Preferably in vc?

#

I started working in Unity a few days ago from a C++ and Unreal background, and while the C# scripting has been pretty easy to get used to, I'm kinda struggling to figure out how to manage object references in a maintainable way.

rare grail
#

i just needed to add the player prefab in. and now its working with damage. its still screaming for Null refrence. but if i add a if player is null. it stops working. this code is legit cursed

sudden pagoda
#

The logic is all kinda simple but I've been in a loop of deleting objects because the structure doesn't feel right for the past few days and I'm trying to break out of it

teal viper
sudden pagoda
#

Sure sure, that'd work

#

Basically, I'm working on a small game where you have a player, that can target a select few rows. And every row will spawn a random amount of enemies over a time duration, with increasingly faster intervals over time. For this I want to set up a number of enemy spawners, that are managed by a manager that can set up the way their waves work.

#

But the player also needs to have access to part of the individual row data, in order to know the direction it needs to turn in and which enemies it's actually targetting

#

Ideally I'd just like to have a separate piece of data that holds the row data. So it holds a list of objects called rows that both the player and the row manager would be able to access data of

#

I tried setting up my own data structure so that I could serialize map data structures within the editor, but that kinda ended up being a hassle and doesn't feel entirely right. I could probably make a seperate object and attach the map there, then pass the reference to that object to the both of them but that also doesn't feel perfect

#

At this point it's not really a matter of "can I write the code" because the code doesn't really have much going for it. I'm just overcomplicating the hell out of it 💀

#

Don't really have any code examples, sorry for that that would've probably been easier

#

But it feels more like a conceptual problem than a coding problem if you get me

#

Oh 1 thing that is actually a coding thing

#

The data structure I made feels a bit awkward to use? Whenever I attach it directly to a script I can fill the list in through the inspector like normal, but if I add it in code I have to add a reference to something. I know it's because it's a mono behaviour but what would be a better way to set this up?

rugged beacon
#

if the row number is just 0 1 2 3
you can just make it a serialized array or list and get the corresponding index

sudden pagoda
#

Ah... that just works yea

#

For some reason I remembered something like serialized lists not working with gameobjects 💀

#

But ty this fixes that problem

eternal needle
# sudden pagoda

there are serializable dictionary implementations online which lets u get rid of this list and need to manually add elements to the dictionary

astral sentinel
#

Is brackeys tutorails good for learning unity?

eternal needle
# astral sentinel Is brackeys tutorails good for learning unity?

no, along with any similar style youtuber. you can get a basic idea for what exists, like learning about new components you've never heard of, but they are awful when it comes to learning exact details.
there is the !learn site and documentation to learn from

#

!learn

radiant voidBOT
eternal needle
sudden pagoda
#

Thank youu

#

Do you know if there's any way to return things const btw? Or is that not really a thing people do with unity

eternal needle
#

its been a long time since ive used c++ so i dont fully remember the point of it there either

sudden pagoda
#

But alrighty good to know

subtle hinge
#

Hey i need some help with Alteruna. I need to sync the players hands, so they can draw their own cards and see the other players cards. How do i do this? Ive tried to use RPC (line 67) but it hasn't helped, probably cause i set it up wrong.

polar dust
#

That's returnable

eternal needle
#

its not the same as just returning a variable that is declared const or readonly

polar dust
#

They're using c++?

sudden pagoda
#

Still learning whatever's possible in C# and stuff and whatever can be crossreferenced seems easier

eternal needle
hot wadi
#

C# seems closer to Java than C and well optimized for OOP

subtle hinge
hot wadi
#

I did a lot of pointer in C++ but at this point I just forget them

teal viper
# sudden pagoda Doesn't really change much, it just makes code easier to read in the long term

It tells the compiler that the returned object can't be modified. If you try to modify it later, there would be a compile error.
In C#, while not a compiler enforcement, you could return a value type object instead of a reference type. This would serve the same purpose - preventing unwanted modification of the returned object, however it's not entirely the same, as you return a copy basically.

#

In C# you'd control the mutabulity more via the type itself(by exposing getter/setters with various accessors), rather than marking the object constant in functions.

sudden pagoda
inland thistle
#

Hey, i want to print logs on screen to test in build, any idea?

#

o how to see debug log on builds?

teal viper
#

Pro devs use the debugger.

grand snow
#

yea enabling script debugging should be more useful but yea you can view dev build logs in editor by connecting to a build on the same network/usb (android)

naive pawn
#

it's part of a larger "c family" in terms of syntax, but it's definitely its own family detached from c# in terms of ecosystem/patterns - probably the IL family, kinda mirrors the JVM family, if im not mistaken

grand snow
#

C like langs ❤️

tidal lily
#

how to code this concept game?
how to get assets out from concept art video?
help

radiant voidBOT
hexed terrace
#

Start there ☝️

hot wadi
sick jungle
#

Hi guys, i'd like to ask u, did u ever used c++ in ur games?

sick jungle
#

ik about that

#

i just wanted to ask u, did u ever used c++

#

in ur games

hexed terrace
#

An odd question. If there's a reason to, some people will, the majority* won't need to.
. * certainly in a beginner channel

hot wadi
grand snow
supple crescent
#

Oh the videos not loading

#

there it is

midnight plover
# supple crescent

its a coding channel #⚛️┃physics might be better if you are not doing anything fancy in code. But you can of cozurse show the code that moves the car to be sure, its correctly set up

hot wadi
# supple crescent

Looks like movement logic or collider. Regardless, if it's not related to programming, go to specified channel

hexed terrace
#

It's from a tutorial, it works in the tutorial.. you've missed something. Go back over the tutorial and see what you didn't do/ did wrong.

slow blaze
#

Calling what I made stick fight is a HUGE overstatement but the idea was in heart

cosmic dagger
edgy sinew
#

If you want to give more details we can get this solved. I'd start with the Time Scale, maybe you can see what's wrong instantly and send a new video?

#

You're gonna want to watch it happen from a better camera angle too. Side view perhaps or 3/4

#

Also please ditch the Mesh Collider they tend to yield funky results. That's basically a cube so just do a Box Collider they're reliable

vocal orchid
#

How can add and remove an element of an array of shaders?

#

The shaders materials of skinned render mesh

grand snow
vocal orchid
#

Yeah

#

I mean it

grand snow
# vocal orchid I mean it

get the material array from the renderer, modify it and then re assign the modified array to the renderer.

rich adder
#

did you look at docs for Renderer

grand snow
# vocal orchid How?
Material[] materials = renderer.materials;
materials[0] = someMat;
renderer.materials = materials;

If you need to add or remove a material then make a new array of the correct size and assign this back instead.

vocal orchid
#

Thanks

half notch
#

Hey ! Is it possible to have a scriptable object, with an action as a variable, and have everything possible? like start a quest, or give a specific item ?

eternal needle
half notch
#

I tried unity event, but u right, it won't work with assets in my scene

rich adder
#

subscribe to both choices events then you can unsub when choice is made

half notch
#

Yeah but each node has a different event, and i want to pass it in the inspector the event in the scriptable object, to make some cool things

rich adder
#

you can also make a function pass in an Action or Func

half notch
#

In scriptable object ?

rich adder
hexed terrace
half notch
half notch
hexed terrace
#

First video result on google, I skimmed it.. seems informative.

umbral pond
#

hi

rich adder
umbral pond
#

im new to unity and most tutorials i found from old system should i just watch them or try to learn new input system

umbral pond
#

which one to use in future

rich adder
#

new

umbral pond
#

thx

rich adder
#

but you should at least learn the basics of old one so you can convert / watch older tutorials

#

arguably actually easier to use new system cause it has so many ways to use it and customize

umbral pond
#

im trying learn basic movement scripting for now older one seemed bit easier to me

#

ill check it out but focus on new input system

edgy sinew
umbral pond
#

im trying to learn variable jump height

#

on new input system

rich adder
edgy sinew
#

Do you know started performed canceled

rich adder
#

you dont even need that in the beginning , just use Polling like old sustem

edgy sinew
#

That's an easy way to do it ... You can keep track of how long the button was help, before it canceled

umbral pond
#

i did it with void Update but i saw most people doing with OnMove,OnEnable with events i stil didnt understand that mechanics

umbral pond
#

i noticed i was using old input system like GetAxisRaw("Horizontal")

edgy sinew
#
    // start keeping track of time
else if (context.canceled)
    // the button was let go
umbral pond
#

then tried re write my code

rich adder
#

events are good. but if you're not familiar use polling is fine

#

unity has example for movement / jump

umbral pond
#

thanks a lot guys

#

oh btw

#

im working on 2D rn

edgy sinew
#

cool there's lots of videos on 2D

rich adder
#

inputs don't really care if its 2d or 3d, its the same things

edgy sinew
#

make sure to check the age of the video

umbral pond
#

alright

#

ill read that link and watch videos with unity 6 ig

#

thanks for help

half notch
# hexed terrace First video result on google, I skimmed it.. seems informative.

The video is not what i'm looking for, I really want to have something like this :

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

[CreateAssetMenu(fileName = "NewDialogNode", menuName = "Dialog/Node")]
public class DialogNode : ScriptableObject
{
    public string tableId = "Dialogues";
    public string key; 

    public bool hasChoices;
    public List<DialogChoice> choices;

    public DialogNode nextNodeIfNoChoice; 
}

[System.Serializable]
public class DialogChoice
{
    public string key;                     
    public DialogNode nextNode;           
    public UnityEvent onChoiceSelected;    
}

But i can't use UnityEvent, because it won't be a reference to something in my scene

rich adder
edgy sinew
#

I think UnityEvent exists for Inspector drag & drop no?

#

regular Action are faster

eternal needle
rich adder
edgy sinew
eternal needle
#

considering thats a scriptable object, they clearly want to set this up via the inspector

edgy sinew
rich adder
#

if you make function take in a (Action/Func) you can invoke it there when choice is made

half notch
#

u mean create a method into the scriptable object ?

eternal needle
rich adder
#

you'd probably still need a way to id the choice though

half notch
#

Can't I just create a virtual method in the dialog choice, and if I want a specific thing, just create a class with the output that i want with dialog choice as superclass ?

eternal needle
half notch
#

Huh forget what i said, it's really not a good idea lmao

rich adder
#

true, I'm trying to visualize the layout a bit.. I'm on the train, once I get to a pc can do a quick diagram

eternal needle
#

i think your simplest way would be having a scriptable object act as an action upon the choice being selected. Drag that into DialogChoice

half notch
#

Like a scriptable object ActionEvent, with a method into it, and then call that method when the choice is selected ?

eternal needle
#

the only tricky part I see here (which exists in every suggestion above) is if you need to pass variables to this 2nd scriptable object. For example if a choice adds 5 gold to your player, you need a reference to the player

eternal needle
half notch
#

maybe with singletons with null check ?

edgy sinew
#

or you could have a static ref to Player on Awake and share that between the ScriptableObjects

#

or per-instance reference ... maybe less efficient

rich adder
#

you could pass the Player as and object if your function can take an interface or baseclass maybe, but I guess the inspector complicates this a bit

half notch
#

But but i'll have to create differents actions, so i don't really see the system actually

eternal needle
# half notch maybe with singletons with null check ?

the player was just an example. if you want this to work in any case, you need to imagine what other things you may need to reference as a result of a choice. Like what if a choice makes the npc talking lose gold instead? Suddenly you need a reference to that instead

half notch
#

Did u mean that i'll have only one scriptable object script called "DialogChoiceAction"? if yes i don't really know how to do two different actions

eternal needle
#

you would need to have a base class and deriving classes for this yes

edgy sinew
#

Polymorphism essentially?

#

base class, inherited classes, one per unique behaviour?

half notch
#

we can derive scriptable objects? okay i didn't know that, so the main class would have a virtual method ?

eternal needle
#

you could make it abstract unless you want the base class to specifically do something

#

but yea either virtual or abstract. then you can override it

half notch
eternal needle
#

yea you wouldnt need it on the base class

half notch
#

Okay thanks ! I really appreciate ur help guys

eternal needle
#

though it would definitely require some editor code

half notch
#

I will go with the scriptable objects for action, i think it will be really nice, thanks guys

eternal needle
#

🤔 maybe it'd make sense if DialogChoice itself was a scriptable object instead of this new SO

#

yea goodluck, i dont wanna add more confusion. there is a ton of ways to do this

half notch
eternal needle
half notch
#

I don't really understand, the DialogChoiceAction SO will be inherited for each action i wanna make, right ? That's what I thought, so basically i need to have one SO and one script (which inherits from DialogChoiceAction) to each type of action, like for example "start a quest" can have a string (reference ID to the quest) into the script, and the method will just fires that quest with the id i put in the inspector, no ?

(sorry if it's hard to understand, i'm french so the translation is a bit hard)

eternal needle
# half notch I don't really understand, the DialogChoiceAction SO will be inherited for each ...

for the suggestion of making DialogChoice a scriptable object, I was just imagining something like this. Then yes everytime you need a new action, you make a new class inheriting from DialogChoice. I realized afterwards that DialogChoiceAction isn't needed because it's only purpose would be to hold one method which can just exist in DialogChoice. The derived class can still add a string as needed for this quest

public abstract class DialogChoice : ScriptableObject
{
    public string key;                     
    public DialogNode nextNode;    
    public abstract void DoAction();
}
#

or you could make it virtual in this case if you want some default logic to happen with nextNode

half notch
wanton osprey
#

Hey so when i open a new project and make a new script and open it with vs code

#

it keeps giving me errors from a different project

#

and i want that not to happen cause it causes compiler errors with the new project

rich adder
wanton osprey
#

it keeps giving me this

rich adder
wanton osprey
#

yes

#

it loads scripts from a different project that i dont want

#

even tho i deleted the other project

rich adder
wanton osprey
#

cause i deleted the other one

rich adder
#

can you like show screenshots or something

wanton osprey
#

sure

#

it gives me this

#

i just dont know how to fix it

#

like it loads errors from different scripts

rich adder
#

those aren't different scripts of yours, but some type of error with the Language server / Extension that tries to read/detect the language or something

wanton osprey
#

so its trying to read a different programming language?

rich adder
#

you'd have to give more details on your setup, which version of VSC is this ? which extensions do you have
are you getting ANY errors in Unity Editor console

wanton osprey
#

these are the extensions i have

coral delta
#

im going to forward a message from a different chat into here because it has a video explaining my problem, but I followed a tutorial for a basic player & camera movement system, and for some reason after following along with the tutorial exactly his camera is moving but mine is not. the player moves just fine and my code is copied straight from his, but the camera is completely stationary on mine and i cannot figure out why

polar acorn
#

From yours:

#
"I did it exactly like the tutorial so why does theirs work and mine doesn't" counter:
Number of times it wasn't exactly like the tutorial: 195
Number of times it was exactly like the tutorial: 5
Number of times the code literally did not exist: 1
2022-07-19 to 2025-10-10
eternal needle
coral delta
#

Obviously it wasn't exactly, that's why it didn't work

polar acorn
# coral delta You're a lot of fun at parties, huh?

Most people see The Counter and have a laugh at their own expense for having missed the obvious differences. Point is, many people have said they followed a tutorial exactly and then send proof to the contrary

#

I guess it doesn't work to well on people with too many insecurities

lime sigil
#

heyo
i'm having trouble with unity 2021.3
i have dependencies that require "unity.collections" and "unity.properties"
problem is, i cannot find the package for properties
i found that it has been turned into a module yet i still cannot find what the new using statement is supposed to be

as the collections package itself is missing unity.properties as well
what would the solution be in this case, i haven't found anything online apart a vague notice about it being a module

half notch
winged ridge
lime sigil
glad shore
#

@edgy sinew what should i do if the rooms overlap
should i generate a different variant of a room until it no longer overlaps?
stop it from generating completely?
remove the room its overlapping with?

winged ridge
winged ridge
lime sigil
# winged ridge In general modding help isn't offered here. Best bet is to cycle through the uni...

it's not for modding help
it's the unity editor itself having problems, i'm developing a tool for unity 2021.3.44f, not the sdk
problem is because of the sdk compatibility, i cannot move up versions for the unity editor

the problem is with the packagemanager and using statements changes that are nowhere to be found
i can't get the unity.properties package nor does UnityEditor.Properties exist which is the suggested fix

eternal needle
half notch
glad shore
#

its a list of GameObjects

polar acorn
#

Ah, wait, you have a list of game objects and want a list of room data, not a single object with multiple room data

#

Where are you getting _spawnedRooms from?

glad shore
polar acorn
# glad shore

There is very little reason to have public variables of type GameObject. You should make those variables the type you actually want instead

glad shore
#

nvm it was lwky easy to add

tacit prism
#

Ah yes, I love tabbing into this chat and not knowing wtf is going on

polar acorn
tacit prism
#

I mean understanding them lol

#

By both lacking context and how green I am

glad shore
polar acorn
glad shore
#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Sphere
{
    public float radius;
    public Vector3 pos;
}
public class RoomData : MonoBehaviour
{
    public List<Sphere> _spheres = new List<Sphere>();
}
#

each room data has a list of spheres which im using to see if rooms are overlapping or not

polar acorn
glad shore
glad shore
# polar acorn So you can loop over the room data, and then loop over that room data's spheres

like this?

bool CheckRoomOverlap(RoomData _roomData)
    {
        foreach (Sphere _sphere in _roomData._spheres)
        {
            foreach (RoomData _spawnedRoomData in _spawnedRooms)
            {
                foreach (Sphere _spawnedRoomSphere in _spawnedRoomData._spheres)
                {
                    float _dist = Vector3.Distance(_sphere.pos, _spawnedRoomSphere.pos);
                    if (_dist > _sphere.radius + _spawnedRoomSphere.radius)
                    {
                        return false;
                    }
                    return true;
                }
            }
        }
        return true;
    }
tacit prism
#

Actually had a issue yesterday

Learned by trial and error that adding a component to an empty object wouldn’t let it operate, tried making an empty target object that I could easily slot into enemy prefabs (contains both the target script and is the object the camera focuses on when locked on, amongst other things I may add)

Any way to make a game object that can be affected but not obstructive to the enemy model, like would a blank material work?

polar acorn
polar acorn
glad shore
#

i should just remove return true;

polar acorn
#

Once you put a script on an object, you have an instance of that script

polar acorn
tacit prism
# polar acorn > Learned by trial and error that adding a component to an empty object wouldn’t...

I have a component that basically reports within a radius of the player if an object is a “target” and then I put that target component on the enemy’s

I put it on an empty object, the same my cinemachine camera for tracking enemies is, however unless I put it on the actual sphere it wouldn’t register it as a target. After testing, I realized empty game objects would not count as a target in the script, only ones with “physicality” so to say

#

Wonder why

glad shore
# polar acorn Think through what you're checking for. Use words like "Any" and "All" to build ...

i think i figured it out

bool CheckRoomOverlap(RoomData _roomData)
    {
        foreach (Sphere _sphere in _roomData._spheres)
        {
            foreach (RoomData _spawnedRoomData in _spawnedRooms)
            {
                foreach (Sphere _spawnedRoomSphere in _spawnedRoomData._spheres)
                {
                    float _dist = Vector3.Distance(_sphere.pos, _spawnedRoomSphere.pos);
                    if (_dist < _sphere.radius + _spawnedRoomSphere.radius)
                    {
                        return true;
                    }
                }
            }
        }
        return false;
    }

it would return false if every single one is far enough away, and it returns true if even 1 is overlapping

polar acorn
tacit prism
#

Wish I could send the code but I’m at work

It’s essentially a is target sphere collider with collision turned off obviously

I set up it to register Target target, and items with that target script would be registered as a target

Then it outputs that to my player targeting script that handles the camera movements, players lock-on movement, etc

polar acorn
#

Maybe you should ask this again when you can actually provide information

tacit prism
#

Really wish I was home to access my VS, but I might just try to make a reassslllllyy tiny game object and put it in it

tacit prism
#

god knows I won’t when I finally get home

glad shore
#
public void DoorOpen(GameObject door,float _tries = 0)
    {
        _currentRoom = door.transform.parent.gameObject;
        //the room that the door that was just opened is in
        RoomData _room = Instantiate(_rooms[Random.Range(0, _rooms.Length - 1)], door.transform.position - door.transform.up * 5, door.transform.rotation).GetComponent<RoomData>();
        bool _overlapping = CheckRoomOverlap(_room);
        if (_overlapping)
        {
            if (_tries < 5)
            {
                _tries += 1;
                Destroy(_room);
                DoorOpen(door, _tries);
                return;
            }
            //What do i put here?
        }
        GameObject[] _smallPrefabSpawnLoc = GameObject.FindGameObjectsWithTag("smallPrefab");
        foreach (GameObject _spawnLoc in _smallPrefabSpawnLoc)
        {
            Instantiate(_smallPrefabs[Random.Range(0, _smallPrefabs.Length - 1)], _spawnLoc.transform.position, _spawnLoc.transform.rotation);
        }
        _spawnedRooms.Add(_room);
        NextRoom();
    }

what do i do if it just overlaps no matter the variant of the room? should i just stop generation?

polar acorn
glad shore
#

what should i do 🤷‍♂️

#

should i just stop the door from opening?

polar acorn
#

It's your design, what do you want to happen

glad shore
#

Nah but seriously how do i get rid of VS code auto putting ts in here 🙏

grand snow
#

vs does it too, type or click the wrong type? BAM using statement

#

should be an option though

#

something like "auto add namespace using statement"

glad shore
polar acorn
#

My guess? Stop adding things from those namespaces

rocky canyon
#

^ lol

grand snow
#

impossible!

polar acorn
#

It'll only auto-add them if you pick them from the dropdown or paste code from a file that has them

rocky canyon
#

it does get some things wrong from time to time..
but mostly its auto-adding it for something it thought u were gonna add to the code..
maybe a misclicked autocorrect or something u deleted shortly after having in the code

#

the other day mine added some kind of System. namespace for Image

#

having one of them days i guess 🫠

glad shore
rocky canyon
#

is it vscode or studio?

rocky canyon
glad shore
#

vs code, i stopped using studio after 2020

rocky canyon
grand snow
#

vs will always be better than vs code but both work well

rocky canyon
#

oh wait.. thats for pasting

glad shore
#

im just gonna have to suffer with these directives vs code giving me

rocky canyon
#

vscode is pretty great.. even when theres not settings for things
by using the settings.json / etc you can pretty much control everything..

grand snow
#

id like vs code more if the debugger ui wasnt soo shit

rocky canyon
#

or json { // Only show types from already imported namespaces "csharp.suggestAddImports": false }

solar hill
#

had 3 seperate bugs that just fixed themselves, or rather i changed or did something that i thought was unrelated to said issues and now they are gone

formal swan
#

Hi, Im have a problem here. I have been given an error that the type or namespace List<> cannot be found (It said I might be missing a directive or an assembly reference, which I don't rly understand. What is the problem within this script?

solar hill
#

i gotta say its not nearly as satisfying and is just making me paranoid because in hindsight if they can fix themselves they can also break themselves just as fast

solar hill
#

youre searching for "cameras" in your for loop

radiant voidBOT
polar acorn
#

configure your IDE and it will be able to autocomplete imports you're missing

formal swan
#

Ok how do I configure the ide?

solar hill
#

the bot message has all the info you need

#

press on the hyperlinks

formal swan
#

ok wait is it that link? I'll give it a try

solar hill
#

yes

languid pagoda
polar acorn
# formal swan Ok how do I configure the ide?

Hm, if only a bot message came up after I entered that command containing several links that would explain how to do what you want it to do. But, alas, no such bot exists apparently

solar hill
#

also ~~switch to vs code ~~

#

wow what who said that

formal swan
solar hill
#

i firmly stand behind vs code being superior to visual studio but rider being better than both

polar acorn
#

Not for Unity

grand snow
#

good joke

#

visual studio walked so vs code could run

polar acorn
#

VSCode barely functions with Unity through community maintained plugins that could break at basically any time

solar hill
#

good enuf

#

idk i just like how lightweight it is or at least it feels like its more lightweight than visual studio

#

but it could just be placebo

hexed terrace
#

it is more lightweight

eternal needle
#

Visual studio taking 5 more seconds to open once per day definitely doesnt concern me

languid pagoda
solar hill
#

i never said its lagging my pc

grand snow
#

you must hate discord too 😆

solar hill
#

i do lol

grand snow
#

ops

solar hill
#

i stopped using discord for calls when gaming

#

discord even on a good rig is just a resource hog

#

im not an expert but it doesnt feel like its built the best

grand snow
#

electron

solar hill
#

something something electron

#

yeah

languid pagoda
grand snow
#

who knew 17 instances of chrome was a bad idea for UI

solar hill
solar hill
#

even though they are unrelated

#

i guess i just appreciate lightweight programs more even though the difference to me is minimal

languid pagoda
solar hill
#

like i said, im not an expert but you can tell when using discord compared to other fucking interfaces or whatever, its just too much

hexed terrace
#

I wouldn't have either, though it is using more RAM than I would have thought (880MB)

solar hill
#

yeah i just checked

#

its using close to 800

languid pagoda
#

yall realize everytime you open a discord channel it caches a ton of info

glad shore
# languid pagoda Ik this is kinda old now and your problem is solved but you might wind up with w...
bool CheckRoomOverlap(RoomData _roomData)
    {
        foreach (Sphere _sphere in _roomData._spheres)
        {
            foreach (RoomData _spawnedRoomData in _spawnedRooms)
            {
                foreach (Sphere _spawnedRoomSphere in _spawnedRoomData._spheres)
                {
                    float _dist = Vector3.Distance(_sphere.pos + _roomData.transform.position, _spawnedRoomSphere.pos + _spawnedRoomData.transform.position);
                    if (_dist < _sphere.radius + _spawnedRoomSphere.radius)
                    {
                        if (_spawnedRoomData != _currentRoom)
                            return true;
                    }
                }
            }
        }
        return false;
    }

This is what i have, it works for me

hexed terrace
#

strayed way off topic now

rocky canyon
languid pagoda
# glad shore ``` bool CheckRoomOverlap(RoomData _roomData) { foreach (Sphere _sph...

Its going to cause bugs if _roomData is ever stored inside of _spawnedRooms when you loop through _spawnedRooms you are going to be comparing the instance of the exact same two rooms and then you''re going to return true because you're going to be comparing the distance of the same two spheres you need to add

if(_spawnedRoomData == _roomData)
{
     continue;
}
languid pagoda
slow blaze
#

Would ScriptableObject be a good idea to make a bunch of Equations, that a checker has to compare the user's input into?

languid pagoda
mossy prairie
#

Hey i was just making some code then when i wanted to change my lightning in my 3d game i couldnt change the lightnings brightness so i googled it and it should look like in the first picture but mine looks like the same but without emission anybody knows why?

solar hill
#

can you screenshot what you see?

mossy prairie
grand snow
mossy prairie
#

but how can i change it to be like in urp

grand snow
mossy prairie
#

is there no workaround?

grand snow
#

No, changing render pipeline is a major modification hence it requiring many changes

#

but using the old standard renderer isnt great anymore (will never get updates again and is outdated)

eager stratus
#

The idea is supposed to be that, when the application closes, a scriptable object is intended to be called to save data in the script like so

    {
        print(saveFile.name);
        //saveFile.SaveData(cellOccupancy, playerPosition, playerBlocks);
    }```

The problem is this results in a NullReferenceException because I guess the reference to the scriptable object has been deleted already by virtue of the application closing. What I want to know is how to keep the reference around for just long enough to save everything THEN close the application
grand snow
#

If saveFile is really null then you fucked up somewhere else such as never loading it in the first place

eager stratus
grand snow
#

!code

radiant voidBOT
grand snow
#

I should point out that using a scriptable object for something you want to save to disk later seems pointless and probably a bad idea

glad shore
#

im kind of lost.... the rooms arent generating, its something about the overlapCheck but i cant figure out why its not working
should i send the script here or somewhere else?

radiant voidBOT
glad shore
grand snow
#

using float for tries?

glad shore
#

like it matters ✌️

#

i dont know why rooms arent spawning 😔

grand snow
#

it really matters and proves you hardly understand whats happening

glad shore
#

it does it when on the next room so its detecting the overlap in the _currentRoom

polar acorn
glad shore
#

if that makes u feel better

grand snow
#

It may make things work better 😆

glad shore
grand snow
#

In NextRoom() you try to find _farthestRoomAway but remove _spawnedRooms[0]) from the list right after...

#

so thats probably a mistake

#

also only using GameObject is making things harder, if you have a component then use that instead

glad shore
#

you're right

#

But what is the problem thats making it not generate✌️

grand snow
#

Id replace this cruddy line and then you can make sure things have positions to spawn at
GameObject[] _smallPrefabSpawnLoc = GameObject.FindGameObjectsWithTag("SmallPrefab");

#

Use a debugger to see whats happening

glad shore
#

i havnt used a bebugger before...

#

idk wym

grand snow
#

visit links above to learn how

idle robin
#

hey guys, i cant save my unity project. its saying "saving prefab to immutable folder not allowed what domi do?

teal viper
idle robin
#

we fixed it, im just having problems with my yarn project and yarn script not running as a dailogue system

half notch
glad shore
still ingot
#

Can anyone explain to me why I am getting this error? I'm following a short tutorial on basics for custom editors.

#

I already have the Editor folder within the Script folder. I even created an assembly reference and have rebuilt my visual studio script, but I still get the same error.

quiet elm
#

any idea why my velocity is dropping every time I hit the ground? Would this have to do with the collision on the ground removing some velocity?

winged ridge
winged ridge
quiet elm
winged ridge
#

It does seem to go back to it's standard before the jump though

#

If you look at the X value before the jump it's average is 5.9, you land it goes down then back up to the 5.9

quiet elm
#

The problem has to do with the horizontal velocity being slashed the frame the player hits the ground, not while its grounded

winged ridge
#

So you are wanting it to remain a constant?

visual pond
#

Guys whats something i can do in unity thats easy

#

2d wise

winged ridge
#

If you are on Unity6+ follow the Unity Tanks tutorial

visual pond
#

Got any specific video?

winged ridge
visual pond
#

What hub

winged ridge
#

Unity hub.. the place you access the unity projects

visual pond
#

Oh jeez this is gonna take like 8 days for me to finish

#

Here we go ig

winged ridge
#

Game development isn't something you do in a day, it can take a long time to learn and longer to perfect. But it's a good start recommended by many. Personally not tried it yet, do keep meaning to

sly vortex
#

yes, game dev takes a very long time to master, as does everything

tacit prism
#

back to question from earlier, i want to assign my target component (image 3) to an empty object (image 1) in order for my targeter (image 2) to detect it, which will let my cinemachine camera focus on it and detect the enemy all from one easily assignable object. HOWEVER whenever i assign it to the empty object, it does not work, and doesnt detect the TargetCheck in the list (image 4, inspector, Targets list near the top)

is there a reason why my empty object wont work? is it because its assigned to a prefab? because thats not how it should work id assume

winged ridge
#

That question is best asked in the ai section

sly vortex
#

ok

#

Can you provide a #? I can't find

winged ridge
tacit prism
#

i already have everything set up so far, i just wonder why i cant throw the target component onto a empty game object i can attach to my enemy pre-fabs whenever i want

#

its not that hard to just put the target component on every enemy, but id rather organize it into a single piece i can use multiple times :(

winged ridge
#

There's a few ways to tackle the issue, to be fair accessing the cinemachine camera component and changing it's look at target variable (you'd have to verify it's name) is likely the quicker way

eternal needle
tacit prism
true ore
#

Good Evening
Guys, I'm making a mod for a Unity Game (No, I'm not a Human) I decompiled the game using asset ripper, and now i'm a little confused because I never used Unity before
when I open scene the objects are invisible
can someone help me 😭?

sour fulcrum
true ore
#

ty for the answer :]

floral garden
#

Hello, UnityChanSleepy i need someUnityChanHelp about how to make animation but not classic like using animator but how to play animation like at start of a game. Character walking alone and start dialogue for the intro
I was thinking using my character and sending input in to move or call a function as auto walk like using pawn in unreal but i don’t think it the best way to. Playing an video ? Or is there better way ? I am using ink for dialogue

teal viper
floral garden
#

Oh yes cutscene does’t came in my head this words 🥹 (search like a idiot for a week) thanks you will try it

queen adder
#

hey can any1 please hop in a vc to help me animate my sprite, i already have the frames but dont know how to implement them

I am very new to unity and programming as a whole

sour fulcrum
#

there is no vc here

queen adder
#

oh 🥀

#

ayyyy i got ittt

floral garden
#

There are a channel for this but not sure. Still there are 2 ways to animate sprite one is using the sprite renderer and the other is sprite library

#

But both use the animator

queen adder
#

okay okay ty

floral garden
#

Oh yeah sprite renderer and sprite resolver

eager stratus
#

Trying to use the NewtonSoft Json serializer and deserializer and, while I'm having trouble properly serializing the data too, I'm having even more trouble deserializing it. I went to the file location to confirm it's actually there and that it has stuff in it (even if it's only default values when it shouldn't be), so why am I consistently getting null from this?

            Debug.Log(saveFile is null);```
eternal needle
eager stratus
# eternal needle Did you print out the result of that ReadAllText to actually verify its reading ...

I just did it because it was the only thing I could think of at the time, but for some reason that ended up being the problem. Changing it to
SaveFile saveFile = JsonConvert.DeserializeObject<SaveFile>(File.ReadAllText(Application.persistentDataPath + "/" + name + ".json"));
seems to have fixed it for the time being.

Also the int value of the class

{
    public LevelManager.Tag[,,] cellOccupancy { get; private set; }
    //public Vector3 position { get; private set; }
    public int blockCount { get; private set; }

    public SaveFile(LevelManager.Tag[,,] cellOccupancy, Vector3 position, int blockCount)
    {
        this.cellOccupancy = cellOccupancy;
        //this.position = position;
        this.blockCount = blockCount;
    }
}```

is recording the proper amount. It's the 3d array that isn't storing values correctly. What's up with that?
eternal needle
#

I haven't needed to do such a thing myself but I dont believe newtonsoft would have an issue with a 3d array

#

Maybe it expects a jagged array instead

eager stratus
#

Wait. No. Apparently there are ones in there too. It's just I have to actually do a ctrl + f search for them

maiden drum
#

Does a kinematic rigidbody offer continuous collision detection when manipulating trasnform.position?

eager stratus
#

Or at least has no default behavior for reacting to collisions

maiden drum
#

oh, then what's the correct way to implement collisions for objects moved by a script?

eager stratus
maiden drum
stuck palm
#

I know there are attributes you can add to a value to give it a slider in the inspector, but is there an attribute to make like a two sided slider? kind of like the one that the light source uses?

open apex
#

Hi, a really nice guy sent me a tutorial series from youtube about c# + unity fundamentals. It were the best tutorial I had ever encountered and experienced people from this server would mostly suggest me the same playlist. I wanna go over the series again however, I cannot seem to find. Do you guys have any tutorial suggestions?

#

Welcome to this introduction to game development. We'll be starting from the beginning, so no prior knowledge of programming or the Unity game engine is required.

Unity can be downloaded here: http://unity3d.com/get-unity

Watch episode 01: https://youtu.be/9iCnjdXEfMA

If you'd like to support these videos, you can make a recurring monthly don...

▶ Play video
#

found it

hot wadi
upper fable
#

So how many tutorials do i need to watch

#

before things start click clacking in my head

keen dew
#

42

upper fable
#

;-;

naive pawn
#

but also - tutorials aren't what makes stuff click

#

thinking is what makes stuff click

#

tutorials tell you how to do stuff, but you gotta do the understanding yourself

#

sometimes good tutorials will guide you towards the understanding, but you gotta do it yourself

upper fable
#

Yeah, i get it. Though sometimes even all the tutorials dont have exactly what i want so i have to mix them and figure out stuff for myself

#

However ive been stuck right now how to make my player controller detect collisions with a wall for the past 2 hours of my life

floral garden
#

This is the best way UnityChanThumbsUp also code can be done in multiple ways.

#

Hmm atwhatcost I remember done it but character controller use only oncollisionhit

#

There are 2 ways to detect it, use raycast or create a sphere collider (in raycast)

upper fable
#

Or rigid bodies right? which seems to absolutely not work for me

floral garden
#

Nop

#

Only cc or rigidbody

#

Not both together

upper fable
#

Thats what i meant

#

i think.. notlikethis

floral garden
#

Your game is in 2d or 3d?

upper fable
#

3d

floral garden
#

Why do you need detect wall? If i remember well the wall block you already

upper fable
#

Well im just using the wall as an object to figure out if it even works

#

what im trying to do

#

then ill attach it to my npc and when the npc and player collide

#

boom jumpscare

#

hypothetically

floral garden
#

Oh

#

Im not expert but if it only that you can just create a component, if hit player, ui-> jump scares or in player hit, if hit this wall-> jumpscare

upper fable
floral garden
#

You can’t use oncollisionenter

#

It only rigibody

#

Use oncollisionhit

upper fable
#

Still isnt logging anything

floral garden
#

I forget the full name let me check

#

OnControllerColliderHit(ControllerColliderHit hit)

upper fable
#

Its beautiful

floral garden
upper fable
#

Finally i can continue the Brackeys tutorial

floral garden
#

Good luck

upper fable
#

You too, may mita be with you

violet thorn
#

I just now searched if anyone else noticed this, gotta agree who in their right mind thought that some plain white background docs with barely anything readable 99% of the time is better than this

sour fulcrum
#

probably something something unification

violet thorn
#

this is some bad "upgrade" overall

tender mirage
#

does anyone know how i can check if all tiles in a tileset are equal to null?

int StartX = 0;
int EndX = 3;


for (int x = StartX; x < EndX; x += 1)
{




    if (Tilem.GetTile(new Vector3Int(x, 0)) == null)
    {

    }

    TileBase TileExist = Tilem.GetTile(new Vector3Int(x, 0, 0));

   

    
    if (TileExist == null)
    {
        Destroy(gameObject);
    }
    
}
keen dew
#

You want to destroy the gameobject only if all the tiles in that range are null?

tender mirage
#

do i need to use bounds?

keen dew
#
int StartX = 0;
int EndX = 3;
bool isAllNull = true;

for (int x = StartX; x < EndX; x += 1)
{
    if (Tilem.GetTile(new Vector3Int(x, 0)) != null)
    {
        isAllNull = false;
        break;
    }
}

if (isAllNull)
{
    Destroy(gameObject);
}
grand snow
#

not the var name id pick but logic is sound

tender mirage
#

i really, have been using too much foreach loops and ignored regular for loops. it's my first time using it.

#

thanks alot

grand snow
#

both can achieve the same goal but here you just needed another var to track if all things checked met some condition

tender mirage
#

it's like foreach is a more readable variant

#

that's there for quick work and readability

grand snow
#

foreach lets is easily itterate Enumerable objects only

#

otherwise for loops work for everything else when we want to loop and increment some value

keen dew
#

I'm pretty sure they get optimized into the same thing in simple cases

grand snow
#

maybe for a list/arrays but something else it wont because of how enumerations are implemented

keen dew
#

Yeah but you wouldn't use a for loop for those because you'd have to manually handle the iterator

naive pawn
#

i wouldn't say for/foreach are the same - i feel like that's misleading and could lead to confusion (specifically in the context of beginners)
consider like, List<T> vs Dictionary<int, T> where the dict has consecutive keys
a for vs foreach on those can give similar results but with foreach on the Dict it's mechanically quite different

cosmic dagger
#

Use for loops when you need to control the index, iterate backward, skip, or update the collection

Use foreach for forward iteration, especially over the entire collection, and if you don't need to update the collection . . .

grand snow
#

and for IEnumerable objects that can only be itterated via foreach

cosmic dagger
#

Yeah, you're stuck with that . . .

naive pawn
#

well, not necessarily. you could control the enumerator yourself

#

which you can do with a for or a while

cosmic dagger
#

I mainly use read-only collections for parameters, but the type depends on whether I need to access the index or Count . . .

cosmic dagger
naive pawn
#

true, just saying it's possible

#

it's not super uncommon in c++ competitive programming lol, fwiw

cosmic dagger
#

Personally, I'm used to using for loops for everything. I should change them to foreach (since they were fixed a long time ago) . . .

floral garden
#

Is there better way to make save or a SO is fine ?

naive pawn
#

that's not what SOs are for

cosmic quail
#

you need to save onto json or something

floral garden
#

Oh i thought using SO to store data

naive pawn
#

it's for storing static game data, mostly. not saves

floral garden
#

Okk sadok

#

Go search to save in json then

brazen warren
#

need help nwith my new vr game

naive pawn
#

!ask

radiant voidBOT
# naive pawn !ask

:thinking: Asking Questions

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

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

languid pagoda
#

Anyone know if there is some issues with memory corrouption when using a native plugin across two different assemblies in unity?

grand snow
#

that will depend on the native plugin itself but no there should not be an automatic issue

languid pagoda
#

sigh I hate dealing with native plugins lmao

grand snow
#

can you say what its doing or whats wrong?

#

if the native plugin allocated something then yea you need it to free it later

rich adder
languid pagoda
# grand snow if the native plugin allocated something then yea you need it to free it later

Its not that I am passing a string from Pawnx64 scripting language, and no matter what I do I cannot seem to get it from the long* addr format it returns it to into a string c# can print to the console its either printing an empty string or it is throwing a null reference exception but when I debug nothing is null.

        public unsafe string ReadString(IntPtr amx, int length)
        {
            var str_base = AMX.amx_mem_translate(amx, cellPtr, length);

            if (str_base == null)
                return null;

            ReadOnlySpan<long> cells = new ReadOnlySpan<long>(str_base.ToPointer(), length);

            byte[] text = AMX.ByteBuffer.Rent((int)length);

            for (int i = 0; i < length; i++)
            {
                text[i] = (byte)cells[i];
            }
            var str = System.Text.Encoding.UTF8.GetString(text);

            return str;
        }
#

i''ve tried like 80 different ways to do it and I am getting the same two results null ref exception or empty string

grand snow
#

you are sure that the incoming string is char* or wchar* ? Also this is not beginner stuff so move to #1390355039272439868

quick heart
#

Does unity use JavaScript?

naive pawn
#

it used to, i think? it does not anymore

grand snow
#

many many years ago it supported boo and js

frank moon
#

hello, i'm pretty new to unity ! How do you recommand to learn c# to do my projects by myself...
Thanks !

edgy sinew
#

Unity Learn, everyone recommends.

frank moon
#

And last question, for visual scripting, is it optmized ?

edgy sinew
#

The real answer is, it depends what you want to make.

#

I'd avoid visual scripting beyond a Flappy Bird level of complexity 😅

edgy sinew
#

If you have a specific type of game you wish to make, we can lead you down the path to make it

#

Otherwise, it depends and different genres require different knowledge

frank moon
edgy sinew
#

Okay, like Len's Island? Or, like _ ?

#

First person or third person perspective? 3D right?

frank moon
#

like Valheim, etc..., 3D and third person

edgy sinew
#

Okay sounds good. Let me give you a roadmap for how to achieve that in Unity

#

(I'm building a third person shooter lol)

frank moon
edgy sinew
#

So here's the rundown of how a 3rd person game like that works

frank moon
#

ok

#

i don't see anything

edgy sinew
#

Dont see me typing? Hold on it's a lot.

frank moon
#

oh ok sorry

edgy sinew
#
  1. State Pattern - this is crucial, Idle / Run / Jog / Crouch / Jump (states of motion), for upper body (equipped items) separate states (item equipped, no item equipped, currently picking up new item, throwing away item, etc)
    2 . Events - for things that happen less often or "broadcasting" / sharing information between multiple parts of the game. For example the Player knows its own HP but so does the UI or maybe other enemies. The new input system works on Events actually (started, canceled, performed)
  2. Object Pooling - pretty easy actually, Unity has built in interface for it. This prevents Instantiate/Destroy from lagging your program out - instead 50 or 100 "of the object" are created on Awake, and then quickly re-activated or de-activated as needed. It's like having all the Lego pieces ready at the start
  3. Polymorphism - hierarchical State machines work on this. For example you can loot a grenade or loot a chunk of rock, the "loot" action is the same even if the sub types are different. You'll get it when you look into interfaces / abstract keyword / override & virtual.
  4. Scriptable Objects - they are a MonoBehaviour essentially but not attached to any object. Great for having multiple instances of "item stats" or "crafting requirements" etc kind of thing.
#

I think those 5 are a good place to start, at the least you can get movement, interaction with nearby items, maybe more done.

#

Cinemachine is great, make sure to get to know how it works. Framerate independence can be achieved with Time.deltaTime
If your game will be heavy on Physics interactions I can send some videos on that too or explain how I do it in my game

cosmic dagger
#

I'd say that SOs are C# classes that you can store like prefabs (assets). They're mainly for immutable data (that does not change) . . .

edgy sinew
#

@frank moon Any of this starting to make sense? I can send some videos that show these techniques in action

edgy sinew
frank moon
#

first of all, thanks a lot !

edgy sinew
#

I've seen them used for "shared state" too

frank moon
#

i'll serach myself and ask for help again if i need it ! thanks a lot !!

edgy sinew
#

Sounds good, we'll be here when you have questions UnityChanThumbsUp

cosmic dagger
#

Shared state is the simplest and typically, the first reason people use them. Then you have data configuration for defaults. After that, it can get very granular, like an SO with a single method used to store functionality for a behavior and the flyweight pattern . . .

edgy sinew
frank moon
#

ok

edgy sinew
#

Player Controller https://www.youtube.com/watch?v=jSauntZrQro
Player Controller https://www.youtube.com/watch?v=NsSk58un8E0
Camera Obstacle Avoidance (Cinemachine has De obstruction built in too)
https://www.youtube.com/watch?v=QrDgrCO22aU
Enemy Robots with State
https://www.youtube.com/watch?v=YdERlPfwUb0
Escape Animator "web" hell
https://www.youtube.com/watch?v=nBkiSJ5z-hE (main idea is you can change Animator State in code with CrossFadeInFixedTime or other methods. PlayablesAPI is more advanced and can do no Animator States and can just play AnimationClips)

#

@frank moon here's some videos I've used and learned from blushie
Don't worry if things go over your head, it's valuable to know what's possible in Unity before getting into an ambitious project.

frank moon
#

ok thanks

hallow acorn
#

hey i made a marching cube mesh "terrain" generator and it works (kinda) and i wanted to add some variation to it by implementing a seed to my mathf.PerlinNoise. how would i do that?

hallow acorn
edgy sinew
#

⭐ hi all, so I've added a custom position / rotation offset to equipped items. But I'm having such a dreadful time configuring 🥲

Any advice or method to try? I wondered if maybe having an invisible/empty child GameObject could be easier and just get the values from that.

[SerializeField] public Vector3 positionOffset;```
rocky canyon
#

is there a question hidden in there somewhere? ;D

edgy sinew
rocky canyon
#

not enough context

edgy sinew
#

I should just set the position/rotation of the object in Editor and save those values 🥺