#💻┃code-beginner
1 messages · Page 746 of 1
Did you check OnMouseEnter in the docs to ensure how it works?
also wtf you are the same person i pointed at the IPointerXHandlers
.< i just want the camera to scroll a little when hovering on a collissionbox. why is this so damn complicated
like 30 mins ago
it's not if you take the time to research it instead of relying on an llm
-# also we told you exactly what to use already
i guess im just going too fast.
the real issue may be i wanted to make a quick lil halloween game for my subs. I greatly underestimated the time to learn it since my deadline is the 30
sorry guys
Break it down more…
First detect if the mouse is on the left or right …
Not when using OnMouseEnter. This is their old version that uses colliders . . .
OnMouseEnter is the old version which iirc doesn't work with the new input system
Guys … Is there not an absolute mouse position in Unity new input system …
yes there is
Can he not just do
if (mouse.x < 10) type thing …
did you happen to google it?
It was rhetorical, I used absolute mouse position before and delta
this is like the worst way to detect if the mouse is over an object
True. It doesn't. They need to change the Active Input Handling setting to Both . . .
or just use the recommended way
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?
tbf all they need is to know if the mouse is on the left / right of the screen
Of course, I just mentioned how they'd fix it using their version . . .
Sorry to assume - either way.
it is simple, but you shouldn't rely on ai
we already told you what to look for
My second mistake. Onr i wont commit again.
Do you have a collider on the object that this MonoBehaviour is attached to?
I just created a colider of the size i wanted and added that script
real mfs don't use it at all
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?
implement the IPointerEnterHandler interface on the mono behaviour, add an EventSystem to your scene (create/ui/event system iirc) and give your camera a PhysicsRaycaster component (or the 2d version) if it's not a ui object
Well i started learning unity yeaterday so i was trying evrytging i could.
Again, my mistake for underestimating
yeah, and you especially shouldn't use it when just learning
I just feel stupid.
we all do
We all feel that way sometimes, more often as newbies probably
Wait. Just asking. To use this new imput system i jave to download some add on or package?
it's an easy mistake to make, mistakes are opportunities to learn
it's part of the gamedev process to feel like a worthless emptyheaded failure
if you're using unity 6 or newer, it's the default
So… Do you have a 2D Box Collider next to the HoverDetector2D
Those r gonna be stacked up in the inspector vertically
Oh okie
*6.1 or newer
what's the difference anyways, why did they move to a new version
Im on 6000.2.6f2
is it? i thought it was default in 6 aswell
then you already have it by default
unless they changed it in a random patch, it shouldn't be.
Okay.
I probably should watch "unity for beginners" videos until i have a firm bedrock to build on.
This is happening on the UI right?
Also why not switch to Unity 6.0 🥲
the new input system is a lot more modular and scalable
No, they were talking about colliders . . .
you can watch them, but you shouldn't rely on them, try to understand what they're doing and trying to teach you instead of mindlessly following their actions
Just to clarify
Heres the tutorial i was following lol. Yeah, old.
||https://youtu.be/2PPe2XKKjLA?si=TnrPGknRZ4SeIE2S||
Today we'll be making our very own FNAF clone in Unity.
Download the project and the sprites I used for it here:
https://spacegames3.itch.io/one-night-at-the-zoo
Project files can be found here:
https://github.com/InfernoGaming3/FiveNightsAtTheZoo
if you're confused or have any questions about what or why they did, you can ask here
Yea! Thats what i will be doin
Mone other reason im confused likek thisnis because i was used to wing it in renpy. Just improvize to hell
I see way too many beginners blindly following tutorials and then being unable to do anything on their own
Does he not use a Rigidbody and 2D Box collider?
im still winging it, and im constantly learning new ways of winging it
Heres what i have:
Clicked to install unity installed requirements that popped up.
Thats all i have
everybody is winging it you just gotta get good at hiding it
This is the fancy stuff I think
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
it's definitely possible
you just need to approach it right
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
and not do it just for the end result, you need to take your time to learn
Guys … check the tutorial person’s Unity version at the top of their window lol 
go for it
Not im scared and ashamed to look
learning something new is always good
XXDDDD
and making mistakes is how you learn
ive written plenty of horrible spaghetti that barely worked
Does OnMouseEnter not work with Rigidbody2D anymore?
ok real funny y’all fine i’ll just find out myself eventually lol
Question. Should i watch any unity video?
Even if my game will be 2d, a 3d video will still help me?
OnMouseEnter never had anything to do with rigidbodies, it only ever cared about the collider
Are u saying that he might just be missing a box collider … 
EventSystem.current.IsPointerOverGameObject() ?
3d and 2d are very similar, most of the code related concepts will basically be the same. You should consider going through the beginner pathways on the unity learn site to really learn what you're doing though
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Yes, the only difference is the physics engine . . .
You should watch the channels that do things right & always find “5 months ago” kinda videos… gauge the validity yourself
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
...
Exactly what Cookie was talking about, implementing those interfaces. It’s a 4 minute video u got this
Learning together! 
whats a quaternion ✌️
it's a fancy confusing 4d maths thing that lets you rotate stuff
but all you need to know is that you can do Quaternion.Euler() to use normal xyz angles
Uh oh, let's not get into that . . .
sec
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.
Quaternions are not Euler angles (XYZ). Use their helper functions and don't be frightened.
i want to learn their mathematical implications
you can check ben eater and grant sanderson's (3blue1brown) visualizing quaternions article or 3blue1brown's visualizing quaternions with stereographic projection lesson
oh god..
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.
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...
and hey, you said you wanted to understand the maths i'm giving you the maths
Wrong channel and likely the wrong server. You can try the collab forums
You dont actually need to understand quaternion math for unity. Just learn how to use the functions unity implements for you already. You never need to do the math yourself
!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**
im in algebra 2, this is above me
i already understood the functions pretty well, i just wanted to know what a quaternion was 😭
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
I also looked into it at one point and honestly its pointless to do so for unity sake. The operations i understood and saw similarities between other math topics, but there's just no value in it, if that gives you any comfort for not knowing it
Exactly my point. There's no reason to understand their mathematical implementation. Just learn how to use the methods in Unity . . .
for unity you don't need to understand the maths, but if you like maths it's definitely interesting to look at
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]);
}
it's fine but you can use the squared distance instead, for comparison it works pretty much identically
You dont need that array of distances
Just make it a float
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
Also super tiny nitpick but even when you logically have a hardcoded value, it's still better to define that hardcoded value outside the function if the function isn't reliant on that hardcoded assumption
In practice my suggestion would be to move that > 4 to some maxAdjecentRoom field or something rather then define it as 4 there
Inside of the loop, store the furthest distance and compare that against the current distance. If its greater, then set the current room as the furthest . . .
On mobile so its hard to read but yea looks fine. The part where you remove the spawnedRoom[0] looks wrong though
are your rooms connected by hallways and such? then it should be calculated with their length
the room is also a hallway, a door leads to a new generation(GameObject prefab)
you should take account of the hallway length then, since hallways turn then the real distance isnt true anymore
i think another factor is that the rooms "position" is right at the door but the actual objects within the prefab are away from the center of the room
Nice work. I’ve never even heard of a Ceiling Lip
word i made up ✌️
You could solve that by calculating those positions when you create the room
i could just take the floor position, and if i have multiple floor objects i can just find the midpoint
that would give me a estimated point ig
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
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?
Kinematic rigidbody?
hah your funny words dont work if i dont understand them wizard man
truthfully though no rigidbody, learning about statemachines at the moment
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);
}
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
I think what was being said before is like,
You can flip a bool value every time the button “started” happens
And execute whichever function you want based on the new value if it’s true or false
oh yeah, thats happening lmao
i feel its not really efficient though, at least the way its written right now, as it takes up 11 lines
i just want to compact it, despite it not being neccesary
Number of lines does not equate to performance.
its gives to readability though
dont forget about storage✌️
Everyone likes their code a different way.
I feel that less number of lines is often less readable
Wouldn’t you just loop through the existing rooms, and check if the new position is within the bounds?
I would think Unity has something built in for this but, you can do it yourself easily too ..
"easily" 😔
how would i check if its within bounds
Typical collision check algorithm .. of course
Easier in 2D but you know the height of the rooms too right or …
you see, thats where im lost.
it varies
It’s gonna be real easy if each room has all that info attached
thats what i was thinking but just sounds like a whole lotta extra work 😔
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
i could make a collider trigger that covers the room then check if within that area
how would i even attach info like that
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
there is upstairs and downstairs so the sphere wont work
GameObject and Component (MonoBehaviour) can be used almost the same way, except with a Component you can attach data or functions right
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.
i thought of that but tried to avoid it
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?
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
wall basis?
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
ur saying is that i should have multiple "bits" of squares to see the bounds of the room
Basically a “do not spawn other stuff here” zone defined by that data yeah.
Width height, x y z
And depth oops.
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 
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
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.
Vector3.Distance gives u a float
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
plus i dont think squares would work because not all the rooms i have are only right angles
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
bouta do this ✌️
if it doesnt work or i have a problem, il come back to u
Yes. Easy, and u just delete all the spheres after.
Hey ⚠️ Make sure of the world transform vs local transform stuff.
and should i use Physics.OverlapSphere?
Wait You can do absolute position to absolute position too actually jk
No that’s for colliders and stuff this is just manually attaching data to your prefabs.
then how would i check if its overlapping with the spheres
The sphere way is easy because 2 spheres intersecting just depends on their distance and each of their radius right
ahh yes, didnt think of that
AI is stupid but it can find nice pictures and help u understand better
Shame it’s a 2D photo
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
What sort of method did you try to implement for it to auto give you that
I dont know 😭 🙏
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 🥀
For two spheres, to be colliding, the sum of both of their respective radii must be greater than the distance between them
How do u even get a unity certificate 😲
It’s the same thing with two dimensional circles. If the vector 2.distance
I still need the final one but >,> may wait a bit for that
Unity offer courses, can't remember the price I didn't have to worry about that. Mine was paid for.. the website has more info on it
OMG I DID THIS IN 2020
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
i remember making my first car 🥹
bouta finish what i started
anyone have any clue why those 2 are errors
its not in a method
Start by reading the error message, but at first glance you appear to have random code floating outside of any method
read the error message but first one is because you got that line of code that is not in a function
ok imma run the error
or who knows since you are not showing enough code
to now how the braces are matched and whats in what scope
Assets\basicmovment.cs(67,9): error CS0106: The modifier 'private' is not valid for this item
wow
well uhh
If Dash is a local function then yeah private is not allowed there
Private is only for members of the class
there is 3 brackets at the end when there should only be 2
99% chance you messed up your braces and got a function defined in a function
show more
thats void update
We can't know that unless you share the full script
void update
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
This is not the full code either
Not only isn't that formatted yeah it's not the full script
Yes seriously
you are defining dash inside of your update
it needs to be its own method separate from it
oh
it all works now btw
literally just had to take out private
no i just had to take out private
oh
move the brace like suggested
Was it intended to be a local function 🤔
im just following a toturial
follow it better
If not, do what the others have suggested. If it was supposed to be a local function, it may be fine.
ye ik
and you mis placed a brace compared to the tutorial
looking at everything but the image i sent 😔
my movement code is different from his
also its not enough to just follow the tutorial you have to think about what you are doing as you do it
hold on im finishing the code and testing it before trying it
yep it not showing errors
but its not working
did u take my suggestion?
finally 😩
if you dont know how to code, unity has courses you can take.
they teach u step by step on how to use unity
i practically perma made it so X just responds to speed
i just need to know how to NOT do this
is it bad that i havnt taken any of the courses, because ive lwky been just going with the flow
They just need to get someone on that terrible site design for those pages.
As far as I am aware, Unity is aware the learn site has it's issues but they have been focusing on Unity6 and getting that ready before the Unity Learn site
Learn in any way u prefer. It doesn't have to be Unity's pathway
In what way is it not working. What is it supposed to be doing and what is it doing instead?
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
That is the common way to do it. Look for common concepts and how they work, then start experimenting on them
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 
You just expressing your feelings or wanna show code? 😉
loading up unity. and il get to showing it. but a little bit of feelings aswell.
!ban 775300007905198131 racism
@_moonbathing_ banned
Reason: racism
Duration: Permanent
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.
a powerful website for storing and sharing text and code snippets. completely free and open source.
i feel that its some really small change i need to do. to make it work. becuse it's so close to just work. 
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?
🤔 il try that.
ok this is hard
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
So you just expect the camera to shake from different spots in your code, right?
yeah. when the enemy hits you, or when a Orb hits you.
Hey btw u can eliminate that if statement if u use TryGetComponent instead of GetComponent
And GetComponent is expensive than TryGetComponent
And what is not working? I mean, running in update does not make sense for this at all. but you commented out parts, that should make it work. Only thing I guess, whats happening, is that you override previous shake with another shake and running two coroutines
Yeah.. from the debug logs that's what the debug.log theroy is,
Is it constantly firing the shake right now or what is happening?
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. 🤣
Could it be that in the code you are calling StopAllCoroutines on update?
il try that
not sure how this interacts if it gets called every frame like this
I thought in theroy it would activate when a orb hits you. but i haven't seen the debug.log message.
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>();
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.
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
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
Might want to provide some specific code examples with an explanation of what you don't like about them. And we might be able to provide some suggestions.
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?
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
Ah... that just works yea
For some reason I remembered something like serialized lists not working with gameobjects 💀
But ty this fixes that problem
there are serializable dictionary implementations online which lets u get rid of this list and need to manually add elements to the dictionary
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
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Ahh right, good to know
Thank you ❤️
i dont know if you need a dictionary in your case (in its current state you dont), but i dont know your plans with it. this is the one i used
https://assetstore.unity.com/packages/tools/utilities/serialized-dictionary-243052
Probably don't need one yet no, but I like having them a lot as a dynamic container
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
return types cant be declared constant in c#, and no i dont think theres anything similar you'd really care to do in unity
its been a long time since ive used c++ so i dont fully remember the point of it there either
Doesn't really change much, it just makes code easier to read in the long term
But alrighty good to know
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.
you could always make something readonly instead of const
That's returnable
return const is a specific thing in c++
its not the same as just returning a variable that is declared const or readonly
They're using c++?
I've only really done c++ in my programming time, started unity 3 days ago or something
Still learning whatever's possible in C# and stuff and whatever can be crossreferenced seems easier
#1390346492019212368 but realistically you might just want to find a forum/server dedicated to this tool. itll be a lot easier if there is one
C# seems closer to Java than C and well optimized for OOP
got my answer from the official discord. thanks
I did a lot of pointer in C++ but at this point I just forget them
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.
Ahhh makes sense makes sense
Hey, i want to print logs on screen to test in build, any idea?
o how to see debug log on builds?
Connect debugger/editor console to the build, get a runtime console log plugin/asset, or write your own.
Pick one.
Pro devs use the debugger.
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)
c# is basically microsoft java / java is oracle c#
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
C like langs ❤️
how to code this concept game?
how to get assets out from concept art video?
help
!learn
:teacher: Unity Learn ↗
Over 750 hours of free live and on-demand learning content for all levels of experience!
Start there ☝️
First, this "concept" is called 2D soulike beat 'em up
Second, u can't get asset out from a video.
Third, don't try to ask AI to make your game
Hi guys, i'd like to ask u, did u ever used c++ in ur games?
Unity uses C#
An odd question. If there's a reason to, some people will, the majority* won't need to.
. * certainly in a beginner channel
ok, sorry, i'm just new here
Do u have a specific problem with C++?
If not relevant to unity then ask in another server
Why doesnt the crate go flying even though the truck has a higher mass than it?
Oh the videos not loading
there it is
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
Looks like movement logic or collider. Regardless, if it's not related to programming, go to specified channel
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.
Bloodborne if it was 2D
I used to work on a C++ library to make some starter games, like stick fight and pacman
Calling what I made stick fight is a HUGE overstatement but the idea was in heart
There's a C++ server. I'd ask them, as everyone there uses that programming language . . .
Things to try
- Rigidbody "Collision Mode" can affect results
- Project Settings -> Physics > Settings > GameObject (basically every single setting can affect results.)
- Interpolation modes
- Project Settings > Time > Time Scale (now you can watch it in slo mo and see what went wrong.)
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
How can add and remove an element of an array of shaders?
The shaders materials of skinned render mesh
you can modify the list of materials on a renderer, is that what you mean?
get the material array from the renderer, modify it and then re assign the modified array to the renderer.
How?
did you look at docs for Renderer
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.
Thanks
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 ?
An action as a variable would be a unity event, but it'd be questionable as to what youre hooking this event up to. Assets cant reference in scene objects so this would have to reference other assets (like other scriptable objects)
I'm looking for a dialog system, which has choices, etc. This system works perfectly fine, i have scriptable objects for that, and I want, for example if i have a dialog with "Yes" or "No" choice, have something to happen if choice is "yes"
I tried unity event, but u right, it won't work with assets in my scene
subscribe to both choices events then you can unsub when choice is made
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
you can also make a function pass in an Action or Func
In scriptable object ?
scriptable objects are regular classes, so you can.. I'm just trying to understand what do you need in the inspector part ?
Create event system and events with scriptable objects in Unity.
✅ Get my courses with discount:
👉 Unity 6: https://www.udemy.com/course/metroidvania-rpg-2d/?couponCode=UNITY-6
👍 Save your time and learn Unity faster
👍 Save your time and learn Unity faster
🔔 Subscribe for ...
I just need to get a reference to a method, for some scriptable object that i create
i'll check the video thanks
First video result on google, I skimmed it.. seems informative.
hi
im new to unity and most tutorials i found from old system should i just watch them or try to learn new input system
learn both
which one to use in future
new
thx
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
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
Definitely yes. How much help do you need... I'm free to explain it right now
[SerializeField] private InputActionReference moveInputAsset
float horizontalInput
void Update() {
horizontalInput = moveInputAsset.action.ReadValue<Vector2>().x;
vs
horizontalInput = Input.GetAxis("Horizontal")
Do you know started performed canceled
you dont even need that in the beginning , just use Polling like old sustem
That's an easy way to do it ... You can keep track of how long the button was help, before it canceled
i did it with void Update but i saw most people doing with OnMove,OnEnable with events i stil didnt understand that mechanics
Those are PlayerInput component
i noticed i was using old input system like GetAxisRaw("Horizontal")
// start keeping track of time
else if (context.canceled)
// the button was let go
then tried re write my code
events are good. but if you're not familiar use polling is fine
unity has example for movement / jump
cool there's lots of videos on 2D
inputs don't really care if its 2d or 3d, its the same things
make sure to check the age of the video
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
sure, but old ones will work fine, its easy to convert..
also I said you can use Both inputs enabled in project for learning
you're going to have to define in code at some point what actually happens with a choice. maybe you could have the logic attached via different scriptable objects. maybe it could invoke some global event using an enum, that some in-scene manager listens to and reacts accordingly
yea but you cant reference scene objects (from SOs) which is what they want to do ( think), they have to pass event programmatically
yah im saying, dont use UnityEvent unless Inspector bs is needed
considering thats a scriptable object, they clearly want to set this up via the inspector
i thought it wont work with UnityEvent
if you make function take in a (Action/Func) you can invoke it there when choice is made
u mean create a method into the scriptable object ?
how do you pass in the function to be invoked, thats basically the whole question here that they're asking
couldn't it just be part of their custom poco ? or in the SO itself as param of function
you'd probably still need a way to id the choice though
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 ?
they would need to define every single possible action within that one poco then, and with some corresponding enum or mapping somehow. It works but still might as well just go with a separate scriptable object too at that point
Huh forget what i said, it's really not a good idea lmao
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
You could, but you also need a way to choose what type of DialogChoice to add in inspector. unity doesnt give you an option to choose a base class like that so you'd need something custom there
i think your simplest way would be having a scriptable object act as an action upon the choice being selected. Drag that into DialogChoice
Like a scriptable object ActionEvent, with a method into it, and then call that method when the choice is selected ?
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
yea i wouldnt call it action event though. Maybe something like DialogChoiceAction
maybe with singletons with null check ?
True yeah
or you could have a static ref to Player on Awake and share that between the ScriptableObjects
or per-instance reference ... maybe less efficient
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
But but i'll have to create differents actions, so i don't really see the system actually
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
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
you would need to have a base class and deriving classes for this yes
okay i understood that part
we can derive scriptable objects? okay i didn't know that, so the main class would have a virtual method ?
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
And abstract class doesnt have create menu menu?
yea you wouldnt need it on the base class
Okay thanks ! I really appreciate ur help guys
this is pretty much the same thing btw. You can equally do it with this approach, the only difference is unity has the drag and drop built in for scriptable objects for you to add logic to the dialog choice.
there are also ways for you to do this with plain c# classes
though it would definitely require some editor code
I will go with the scriptable objects for action, i think it will be really nice, thanks guys
🤔 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
Thanks!
Yeah it would be a good idea
I obviously need to have my project, one derived class and its attached scriptable object, for each action i wanna make, no?
im a little unsure what you're asking here. every new action would be its own derived class
the suggestion of DialogChoice being a scriptable object basically just removes the need to have a method in some separate scriptable object for no reason
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)
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
Yeah but with that, choices without action, but with just a next node wont work, because we cant create an asset from it
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
which errors.
so did you "See log for details"
yes
it loads scripts from a different project that i dont want
even tho i deleted the other project
what do you mean
like scripts names from the other projcet are in the logs and it causes errors
cause i deleted the other one
can you like show screenshots or something
sure
it gives me this
i just dont know how to fix it
like it loads errors from different scripts
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
so its trying to read a different programming language?
not a different but probably an error trying to detect it properly or something
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
these are the extensions i have
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
From the video:
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
the dialog choice is the asset in that example. it would just be implementations through derived classes. the next node would work fine, you still need to add logic for it to use the next node
You're a lot of fun at parties, huh?
Obviously it wasn't exactly, that's why it didn't work
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
Okay thanks !
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
Btw, the player can be easily access with the singleton directly in the SO, no?
At that point you may want to look at upgrading your version to be more up to date.. 2021 is old
i cannot, it's for a modding sdk development and it requires 2021.3.44f otherwise i would have already
i tried already and the sdk completely breaks down if i go as slightly as a few versions up
@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?
Your code should have worked out they shouldn't be able to overlap, but if they do remove the room that was generated and make it regen until it's one that wont
In general modding help isn't offered here. Best bet is to cycle through the unity docs for the stuff you require, see what's said about it
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
sure, i wouldnt really recommend a singleton here but if thats what you know then might as well keep it simple. Otherwise you just need to pass the player as a parameter when calling a method on the dialogue nodes
Hm yeah true actually i can do this as well and pass it through parameters
is there a way to convert _spawnedRooms into a list of RoomData
//_spawnedRooms.ForEach(GetComponent<RoomData>() is a error
foreach (RoomData roomData1 in _spawnedRooms.ForEach(GetComponent<RoomData>()))
{
}
its a list of GameObjects
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?
There is very little reason to have public variables of type GameObject. You should make those variables the type you actually want instead
i keep thinking these solutions but i always think there is a easier way, il go with what you said
nvm it was lwky easy to add
Unity code problems are getting solved?
i have the same problem but its a list of RoomData that i need to a list of Sphere(a class i made)
Does every RoomData have a Sphere? Or vice-versa?
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
So you can loop over the room data, and then loop over that room data's spheres
you're right, why didnt i think of that 😔
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;
}
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?
What's the point of using loops if you're going to return from the function at the very first iteration
shit
Learned by trial and error that adding a component to an empty object wouldn’t let it operate
Not sure what you mean by this.
i should just remove return true;
Once you put a script on an object, you have an instance of that script
Think through what you're checking for. Use words like "Any" and "All" to build up what you want to do, it'll help you figure out how to translate it
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
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
How are you checking an object within the radius
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
Maybe you should ask this again when you can actually provide information
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
Eh I was at work and it slowed down so I decided to give it a shot while I still remembered
god knows I won’t when I finally get home
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?
What do you want to happen if you call DoorOpen with 5 or more tries?
thats what im asking
what should i do 🤷♂️
should i just stop the door from opening?
It's your design, what do you want to happen
Nah but seriously how do i get rid of VS code auto putting ts in here 🙏
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"
"There is nothing we can do" - Napoleon
My guess? Stop adding things from those namespaces
^ lol
impossible!
It'll only auto-add them if you pick them from the dropdown or paste code from a file that has them
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 🫠
i keep tabbing to early then it corrects to something i didn't want, which is probably why it keeps adding these
is it vscode or studio?
mmhmm.. stop being so impatient! lol
vs code, i stopped using studio after 2020
🧠 smart ;D... anywho
https://stackoverflow.com/questions/61811825/how-to-stop-vs-from-automatically-adding-using-directives check this out
vs will always be better than vs code but both work well
oh wait.. thats for pasting
im just gonna have to suffer with these directives vs code giving me
vscode is pretty great.. even when theres not settings for things
by using the settings.json / etc you can pretty much control everything..
id like vs code more if the debugger ui wasnt soo shit
{
"csharp.suppressDotnetAddUsings": true
}``` should be able to just add this to ur `settings.json` file
or json { // Only show types from already imported namespaces "csharp.suggestAddImports": false }
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
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?
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
"caneras"
youre searching for "cameras" in your for loop
!ide
If your IDE is not autocompleting code or underlining errors, please configure it.
Select one:
•
Visual Studio (Installed via Unity Hub)
•
Visual Studio (Installed manually)
•
VS Code
•
JetBrains Rider
• :question: Other/None
configure your IDE and it will be able to autocomplete imports you're missing
Ok how do I configure the ide?
ok wait is it that link? I'll give it a try
yes
Ik this is kinda old now and your problem is solved but you might wind up with weird bugs in certain scenarios if you do not check if the _SpawnedRoomData and _roomData are the same and then skip that iteration(use continue) of the loop
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
lol sorry I didnt see it right away
i firmly stand behind vs code being superior to visual studio but rider being better than both
Not for Unity
VSCode barely functions with Unity through community maintained plugins that could break at basically any time
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
it is more lightweight
Visual studio taking 5 more seconds to open once per day definitely doesnt concern me
If visual studio is lagging your PC how do you run unity?
i never said its lagging my pc
you must hate discord too 😆
i do lol
ops
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
electron
what?
who knew 17 instances of chrome was a bad idea for UI
feels like a pretty straight forward sentence
i guess my love for vscode might have been born out of my hate for discord
even though they are unrelated
i guess i just appreciate lightweight programs more even though the difference to me is minimal
Ok let me rephrase. Could you please elaborate on what you mean by "resource hog" because I definitely wouldn't say it is.
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
I wouldn't have either, though it is using more RAM than I would have thought (880MB)
yall realize everytime you open a discord channel it caches a ton of info
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
strayed way off topic now
hell of a boolean 😄
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;
}
wont be a problem...
ok yeah wont be an issue.
Would ScriptableObject be a good idea to make a bunch of Equations, that a checker has to compare the user's input into?
Why not just make it a static method at that point instead?
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?
can you screenshot what you see?
are you using urp/hdrp? if not thats why its different
https://docs.unity3d.com/6000.2/Documentation/Manual/urp/InstallURPIntoAProject.html
Be warned: Will require material upgrades and old shaders may stop working if you change render pipeline
is there no workaround?
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)
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
the class instance still exists but reading the object name is triggering the exception (unity fake null)
if you can avoid that its okay. Otherwise swap to a non unity object class for this data storage
If saveFile is really null then you fucked up somewhere else such as never loading it in the first place
Would I test that just by saying "if (saveFile is null) { print(true); }"?
first share more code and the real exception text
!code
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
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
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?
!code for big code blocks
📃 Large Code Blocks
Use links to services like:
https://paste.mod.gg/, https://hastebin.skyra.pw/, https://paste.ofcode.org/, https://paste.myst.rs/
📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To format as C#, add cs to the first line:
```cs
// Your code here
```
Add a comment with a line number if there is an error message.
A tool for sharing your source code with the world!
using float for tries?
it really matters and proves you hardly understand whats happening
it does it when on the next room so its detecting the overlap in the _currentRoom
why would you use a float when it's something you only ever increment by whole numbers
i changed it
if that makes u feel better
It may make things work better 😆
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
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
debuggers let us pause, step through and examine code execution.
visit links above to learn how
hey guys, i cant save my unity project. its saying "saving prefab to immutable folder not allowed what domi do?
What folder are you trying to save it in..?
we fixed it, im just having problems with my yarn project and yarn script not running as a dailogue system
We talked about parameters but i just realize that the main class (the parent one) will have abstract method, but the parameters can change depending on what the child class is used for, so idk how to do it?
its because the current room is in _spawnedRooms so it just keeps overlapping with the room its connected to
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.
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?
That issue is nothing to do with the folder editor it is trying to inherit from a Editor class
Velocity is distance over time.. so your velocity won't be a constant value unless your direction and speed is constant. If you jump and drop there will be a small change in velocity on a certain axis, in the same way if you change direction
true, but the x and z velocity is also decreasing on the landing
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
The problem has to do with the horizontal velocity being slashed the frame the player hits the ground, not while its grounded
So you are wanting it to remain a constant?
If you are on Unity6+ follow the Unity Tanks tutorial
Got any specific video?
It's on their hub
What hub
Unity hub.. the place you access the unity projects
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
yes, game dev takes a very long time to master, as does everything
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
That question is best asked in the ai section
example
Cinemachine does have a look at feature if I remember rightly
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 :(
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
the easiest way is just to have one class sent as the parameter, which encapsulates everything that could be sent. its not the prettiest but yea it does get awkward otherwise
ill look into it. Still learing about state machines but enjoying it so far. Sankyu
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 😭?
this server doesnt help with that, sorry
ah ok
sorry about this
ty for the answer :]
Hello,
i need some
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

It's called cutscenes. And the best way to implement it in unity is using the timeline package. It's exactly what it is for.
Oh yes cutscene does’t came in my head this words 🥹 (search like a idiot for a week) thanks you will try it

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
there is no vc here
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
okay okay ty
Oh yeah sprite renderer and sprite resolver
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);```
Did you print out the result of that ReadAllText to actually verify its reading properly.
Also DeserializeObject allows you to provide the type so you dont need to cast it
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?
🤷♂️ id assume the json format is off but idk otherwise
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
Actually deserializing it it seems to be fine. But if I look in the file it's just zero values as far as the eye can see
Wait. No. Apparently there are ones in there too. It's just I have to actually do a ctrl + f search for them
Does a kinematic rigidbody offer continuous collision detection when manipulating trasnform.position?
Last I checked it doesn't offer collision detection of its own AT ALL
Or at least has no default behavior for reacting to collisions
oh, then what's the correct way to implement collisions for objects moved by a script?
Usually what you would do is manipulate its linear velocity and it will handle collision detection on its own so long as it isn't kinematic
After digging a bit in the documentation, it appears that i can enable Use Full kinematic Contacts and it'll allow collisions.
Also there's rigidbody.moveposition, since i want to move according to a function over time,(for example sine) so it's easier to manipulate the position than velocity
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?
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...
found it
I found out about through the "How Computer Works" video. He seems to do a lot of coding overall. His game videos are quite old
So how many tutorials do i need to watch
before things start click clacking in my head
42
;-;
no-one can really answer that for you
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
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
This is the best way
also code can be done in multiple ways.
Hmm
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)
Or rigid bodies right? which seems to absolutely not work for me
3d
Why do you need detect wall? If i remember well the wall block you already
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

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
Still isnt logging anything
I forget the full name let me check
OnControllerColliderHit(ControllerColliderHit hit)

Finally i can continue the Brackeys tutorial
Good luck
You too, may mita be with you
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
probably something something unification
this is some bad "upgrade" overall
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);
}
}
You want to destroy the gameobject only if all the tiles in that range are null?
Yeah, that's what i'm looking for.
do i need to use bounds?
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);
}
not the var name id pick but logic is sound
i really, have been using too much foreach loops and ignored regular for loops. it's my first time using it.
thanks alot
both can achieve the same goal but here you just needed another var to track if all things checked met some condition
is see. although i can imagine for loops being alot more relevant in the long run?
i've been trying to learn it now and it seems more complex but also more important.
it's like foreach is a more readable variant
that's there for quick work and readability
foreach lets is easily itterate Enumerable objects only
otherwise for loops work for everything else when we want to loop and increment some value
I'm pretty sure they get optimized into the same thing in simple cases
maybe for a list/arrays but something else it wont because of how enumerations are implemented
Yeah but you wouldn't use a for loop for those because you'd have to manually handle the iterator
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
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 . . .
and for IEnumerable objects that can only be itterated via foreach
Yeah, you're stuck with that . . .
well, not necessarily. you could control the enumerator yourself
which you can do with a for or a while
I mainly use read-only collections for parameters, but the type depends on whether I need to access the index or Count . . .
Yes, but that's not common. Most people are unaware of or unlikely to do this . . .
true, just saying it's possible
it's not super uncommon in c++ competitive programming lol, fwiw
Personally, I'm used to using for loops for everything. I should change them to foreach (since they were fixed a long time ago) . . .
Is there better way to make save or a SO is fine ?
that's not what SOs are for
you can't save data with scriptable objects
you need to save onto json or something
Oh i thought using SO to store data
it's for storing static game data, mostly. not saves
need help nwith my new vr game
!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
Anyone know if there is some issues with memory corrouption when using a native plugin across two different assemblies in unity?
that will depend on the native plugin itself but no there should not be an automatic issue
sigh I hate dealing with native plugins lmao
can you say what its doing or whats wrong?
if the native plugin allocated something then yea you need it to free it later
yeah it is what it is, they also got a few Mermaid graphs that no longer work..
it only makes sense because they wanted a "unified" consistent thing.
The only "positive" that the packages docs has compared to the engine/native docs is at least you can link headers / anchor links
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
you are sure that the incoming string is char* or wchar* ? Also this is not beginner stuff so move to #1390355039272439868
Does unity use JavaScript?
it used to, i think? it does not anymore
many many years ago it supported boo and js
hello, i'm pretty new to unity ! How do you recommand to learn c# to do my projects by myself...
Thanks !
Unity Learn, everyone recommends.
And last question, for visual scripting, is it optmized ?
The real answer is, it depends what you want to make.
I'd avoid visual scripting beyond a Flappy Bird level of complexity 😅
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
i want to make a survival/building game for now...
Okay, like Len's Island? Or, like _ ?
First person or third person perspective? 3D right?
like Valheim, etc..., 3D and third person
Okay sounds good. Let me give you a roadmap for how to achieve that in Unity
(I'm building a third person shooter lol)
oh great ! good luck for your project !
thanks
So here's the rundown of how a 3rd person game like that works
Dont see me typing? Hold on it's a lot.
oh ok sorry
- 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) - 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
- 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.
- 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
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) . . .
@frank moon Any of this starting to make sense? I can send some videos that show these techniques in action
Yeah so like item stats. Or any kind of "parameter data" that can be used
first of all, thanks a lot !
I've seen them used for "shared state" too
i'll serach myself and ask for help again if i need it ! thanks a lot !!
Sounds good, we'll be here when you have questions 
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 . . .
If you're going the YouTube route, make sure it's not in older Unity like 2019, 2022, etc.
And be wary many channels just "get the feature done quick" with no regard to optimization or "the best method to accomplish"
ok
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 
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.
ok thanks
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?
#⛰️┃terrain-3d this channel might be better
thanks
thanks ill look into it
⭐ 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;```
is there a question hidden in there somewhere? ;D
can you help? that's the question 
not enough context
I should just set the position/rotation of the object in Editor and save those values 🥺

