#archived-code-advanced
1 messages · Page 55 of 1
it sounds like you want a repeating background
and i'm trying to understand why it isn't duplicated. i understand you also want to achieve a wrapped world
which i know how to achieve
i understand what that means
It is not a repeating background
you want the player to essentially move along the surface of a torus / cylinder
which is fine, that makes sense to me
is that correct?
no
okay well, my feedback to you is you need to improve your communication skills
so what are you trying to achieve?
dont' talk about your existing implementation. what is the idea?
it is normal to have a lot of inertia around something that "Works" that you've "Already Written" and you "Just" need a solution to your "Problem Right Now"
try to answer my questions
I have explained what I am doing, I have a player at the edge of the world as represented in the Game View in that image. The game view not only needs to show the scene in that positon, but the scene on the other side of the scene or map.
I have, and each time it is not what I am doing
And I know that, been writing games for 38 years
The game view not only needs to show the scene in that positon, but the scene on the other side of the scene or map.
okay, and the "other side of the scene"... you're saying it wouldn't be accurate to describe this as a world that wraps, like a torus does? like a civilization 2 map
@iron torrent, I do not know what you mean by you can every so slightly see a lag or gap. I am not seeing it.
I mean the two Cameras have a gap, where the Unity background shows through
and you're sticking to it due to inertia
you can't use cinemachine the way you want
says who
right now, you're convinced you've achieved something better by not duplicating
but you are still duplicating
you're duplicating cameras
and you're going to still duplicate a lot of other stuff
you just don't know it yet
I am duplicating nothing
and you're not answering the question
how many cameras do you have?
well
listen if you don't inhabit reality
why are we helping you
4, all 4 show different things
nobody can tell what is going on
not unity support, not us
and you're not helping us understanding
you're saying it's not a torus
it really, really really looksl ike you're trying to wrap the game map like civilization 2 wraps its world map
simple yes or no question: is that true?
are you trying to wrap your game world like civilization 2 does?
@iron torrent if you want to thrive at this, you're going to have to write 100x faster
it will probably be really interesting, whatever the mechanic is here
it probably isn't a torus
The gap is where ? Is your world suppose to fit perfectly with your Camera ?
i understand they show different things... but what is the idea
alright well i think that was exhausted
it's been a bad few days huh
Hello! For reasons, I’m thinking about storing a pointer to a MonoBehavior in one of my scripts. Not a reference, but an unsafe pointer.
Since that’s pretty unusual, I’m having trouble find out if that’s a safe thing to do in Unity. Does anyone know if Unity has commented on the safety of doing that before?
That is really strange, and if you remove CineMachine it works ?
yes it does
that’s a safe thing to do in Unity
it isn't. what are you trying to achieve?
Trying to store a reference to a MonoBehaviour in an unmanaged struct.
But obviously that won’t work. Pointer would be the next go to
what is the big picture goal
using an unmanaged struct would come with a lot of architectural advantages for me here. Too long to explain.
I’m looking for places where Unity has actually commented on this. Do you know of any?
Or, do you know why it’s not safe? Does Unity move GO data around at runtime?
it really depends what your goals are. it sounds like you are making a lot of assumptions about how things work
that are wrong
That’s why I’m asking
it's been a really bad few days in the chat huh
you're obviously a normally adjusted guy
like why not say what the goal is in a sentence
why make that difficult
I’m not here to argue or anything. Just looking for info on this specific question
there isn't anything sensitive about this goal
by now you could have said what it is
Is there a technical reason why storing a pointer to a GO Component would fail in some cases?
It does not seem like a Cinemachine issue frankly. Is the camera in perspective or orthogonal mode ?
fail in what cases?
Orthographic
just imagine it from my perspective
i'm a normal well adjusted guy. i'm asking you like, a basic question
anyone who would want to help you would need to know the answer to this basic question
What is the position/size of the rectangle ? Do they fit perfectly ? Or you have a leeway ?
there isn't like
Can you think of any reason why storing a pointer to a GO Component, and then trying to dereference it later (maybe frames later) would fail? Have Unity commented on this anywhere?
an approach where you use deflection
you know what i mean?
you can't just ignore what i'm asking
i suppose if you want to do something that makes no sense, go ahead and try
Rectangle, each area is the size of one screen. And is a place holder to represent the world space in the scene.
it sounds like you don't know what you're doing
because almost 100% of your words are describing something flawed
How come?
i gave you the benefit of the doubt. it would help a lot to know what you are trying to do. it will help me understand your level of sophistication
otherwise you're just an anonymous person on the internet, it's hard to know
I’m not sure what more information you’d have to have about my use case.
😢
I’d be glad to answer specific questions, if I can.
i'm asking what you are trying to do, big picture
for example, "i am writing an editor script that replaces one script with another, keeping all the serialized values"
Like, what my project is?
Oh - I’m sorry, I can’t legally share that.
Knowing what you're actually trying to do is important.
it is so bad today
Is it ok to ask a specific technical question here, without the big picture info?
I really doubt the issue is Cinemachine in itself, but I do not understand why it would work without it either. I think you should try to come up with an alternate solution.
i guess not, no. good luck out there
not for you
Ok. Thank you anyway.
Example: attempting to share the non thread safe data over a thread isn't going to fly - synchronous issues.
Oh - good point. No - this is in a single threaded context.
i think you should use uNrEaL eNgInE
that will help you the most
everything is unsafe there
you can modify all the code
to do everything you need to do
That’s an entirely different engine.
that is what it sounds like you need
Well playing guessing games isn't fun. Good luck. 
i told you my NDA joke right?
"Not Doing Anything"
lol no i don't think so
a Unity.Object belongs to a category of smart pointers
it doesn't do what you think it does
Well it also works in a non URP project as well, and right now there is no other work around. The model for the background can't be duplicated in this case as it is one solid model. The only solution is to remove Cinemachine altogether, then I lose all the benefits it brings that I would need to code myself.
If there is another solution I am all ears. That provides smooth movement.
Which also reminds me, the Brain can have the Mode set to Fixed Update and the Blend to FixedUpdate, but the player movement is Janky as shit.
The effort in responses may be dependent on the effort in question.
You can also update manually. (The Brain) At least, I think ?
To be honest, I don't know how that works and haven't found anything that helps
The gap is only when your player is moving ?
yes
there are no smart pointer converters either for C# like there are in C++
That is useful information! Ty.
Oh, It’s not a meta verse thing
I’m not sure that’s going to go anywhere for at least a while
I really do not know. Personally, I would not use Cinemachine for SideScroller. You do not gain much.
listen dude, you wanna thrive at this too. you gotta figure out how to say what the thing is
right now it sounds like you are trying to do something... really stupid
like profoundly phenomenally stupid
it sounds like you need to use Unreal
because that's where people's stupid ideas thrive
you can change all the code there
do whatever you need
and it's a good way to never ship
maybe you're incentivized to never ship. hardly any unreal things ship
they're janky and bad and support all sorts of bad ideas
i gave you the benefit of the doubt
Well I would normally agree, not in this case though
I’m sure it does. I get that. But in my experience, a professional coder doesn’t need to have every detail in order to answer a technical question. It’s professional to not assume the people around you are idiots, unless they are doing something that affects you. And even then, it’s professional to not automatically assume people are idiots.
What functionality you want from Cinemachine ?
But there’s no risk for you to assume those things here, so I get why you’re doing it
There are times where I am going to use it to blend to another Camera, as well as various other things that are far, far, easier to do with Cinemachine
well you have every ability to clear all doubt from my mind
This is why I raised it with Unity, and all I am getting is it is by design. I don't see how it is by design if it works without Cinemachine
a professional coder doesn’t need to have every detail in order to answer a technical question.
spoken like a true "IC"
i don't think you're stupid
i'm just saying you should say what it is
there is nothing sensitive about it
legal this, legal that
trust me. there's nothing sensitive about what you are trying to do
It is by design, most likely, because it does not support what you are trying to do. It is not made for sequential(side by side) environment in a 2D Sidescroller. It was not designed for this.
but yeah, seriously, look at Unreal
i think whatever it is you are trying to do, it would make sense to do there
So I have to use another Game Engine to do it?
@upbeat garden like your people probably want that jank
No, an other library. Cinemachine is not Unity.
we have two people in this chat right now who should be using Unreal lol
I don’t believe it will be useful to continue this conversation right now.
I don't know what you are on, but you need to chillout
i'm only saying what people who are trying to help you are thinking
Thank you again
for what it's worth - if you scroll up and look at the first two words in reply to your question, it was answered immediately I think
yes... i think this was unintentionally poorly asked
Sorry if I missed it
i'm sorry. you are very difficult to help. unintentionally
it sounds like there's a cool game mechanic lurking in there
i was hoping to support that but it's too confused
Sorry, @undone coral was that last message to me?
Not difficult to help, just will ignore people who throw comment after comment after comment with no real help
anyway i am done
I'll answer the original question. If you pin it with a GCHandle, it'll probably be fine. If you try to access this pointer from native code, you're going to have a bad time. If you're trying to use callbacks, P/Invoke on ios/proxy objects on android is the way. Can't tell you more without more info
Hi, how can I get access to the class of which my CustomEditor is a type of? Here, it's GridController
Reflection
i think the user has to just try and go for it. i know exactly when it will crash
Really appreciate it. Makes sense. That’s what I was looking for. Won’t do it.
it just is a confused and nonsensical ask
If you know exactly when it will crash, then why didn’t you say it?
because an NDA forbids me from discussing it
Why? Are you with UT?
I think this might be more efficient, ty
it'll crash if the object gets GC'd and you try to use it. Otherwise no different from passing pointers to managed stuff into native land as long as you're just holding it and not trying to do something tricky
you just need to make sure it doesn't become invalid on you, hence the use of pinning/GCHandle
That’s what I suspected
That follows normal GC logic. I wasn’t sure if Unity was doing some more hands-on, fancy mem management with GO data.
You meant to get the actual object. I thought you were saying how I can know what type of object my CustomEditor was being used on. Without necessary being inside it. (Already knowing what the type is)
Yeah sorry but thanks
it's possible they are moving the underlying data around, but your pointer would be to the managed MonoBehaviour and not the C++ end
Unity does fancy things with Object. One being that they delete them where it is not suppose to be possible in C#. They use an override of the == null to achieve that.
There is a part of the memory that is native, while an other is managed.
Unity will free the native part and invalidate the other.
Roger that. Thanks for that info! It’s difficult to find simple details about this stuff online. Especially since what I was asking about is very inadvisable. 😂
Really appreciate that knowledge
I'm going nuts 🥜
I'm trying to do something so simple. I'm trying to have a "frosted background" look for behind my popups.
My setup is as followed right now:
I have a camera that renders all my UI (excluding my popup)
I have a copy of my main camera only this time it renders to a texture instead
I have a canvas set to screenspace camera (with my main UI camera linked)
I have a "blur popup" canvas with screenspace camera (with my frosted camera linked). In side this canvas is the popup and a rawimage with my RT in the backgound
With this setup the result is I simply don't see the frosted canvas at all and the RT displays the content of my frosted canvas instead of the main UI
But this isn't working at all for some reason and I've tried every combination of depth, sorting layer and settings I can think of.
I don’t know if you folks get a lot of new coders in here asking dangerous questions - I bet my question sounded like that. I get it. But there was a reasonable reason over here for at least investigating this…juuust enough to double check that it was stupid. :p Thank you to those of you who took the time to just share what you know on the subject.
To be honest, whatever is the idea. If you are looking for optimization of this level, you are not using the correct engine as Unity as a High Overhead.
You’re probably right. I come from custom C++ ECS engines, then Unreal, then Unity. When they announced DOTS, I was very excited, and poured years into it. But recently, I’ve had to accept that DOTS won’t have anything close to feature parity with the rest of Unity for - maybe - 5+ more years. At least. But with Burst and Jobs still available in MonoBehavior land, I’m interested in finding ways to take advantage of them if I can. But…after so many years of valuing performance over convenience, I’m done letting the perfect be the enemy of the good.
But overoptimizing is a hard habit to break. :p At least inside one’s head.
lol, aint that the truth
Btw, now that he’s gone, what’s up with that doctorpangloss guy? Is he/she always like that?
We do not talk about individual. This is for support, not bitching people.
Roger that! You’re absolutely right. My apologies.
--redacted--
Since you're saying that you can't "legally talk about it" and that you're being so aloof, and that this potential application (pointers in unmanaged structs) is a potential security risk, I would assume that you are doing something malicious within your code. So I won't be of any further help on this particular issue, unless you can explain your specific use-case here.
I absolutely will not be doing this. And thank you for writing back.
I’ve been working too long in unmanaged land. Losing track of basic c# knowledge
Unity's GC doesn't do compaction afaik, and if it did pinning it would prevent it from being moved. Is that an AI answer?
I think so because this has nothing to do with Unity, only C#
There, I cited my sources 🙂
And that is why you should not use 'AI 'and then quote them, because they usually get the answer wrong
Hmm, if Unity’s GC doesn’t do compaction, then would it wrong to think that a pointer to non-pinned data would only be a crash risk if the GO was destroyed?
@upbeat path if you have a better answer, let's hear it -- but it made sense to me so i posted it. If you disagree with the source, then why?
It sounds like it still a terrible idea for other reasons (like the way Unity handles Destroying Objects)
There is no such thing as 'Unity's GC'
I understand that. I was just using the language form the comment above
@upbeat path how so? I mean, without splitting hairs -- where's the GC?
GC is a function of C# .Net nothing to do with Unity
Okay so, terminology aside -- Unity's GC is the same GC as C#
Yeah - although it’s always possible they could modify it somehow
Though I have no evidence that they have
Quote from the #📖┃code-of-conduct, btw
Do not [...] Ask or answer questions using unverified AI-generated responses.
this is software, exact, precise usage of terminology is of the utmost importance
Anyway, is it true that there’s no GC compaction happening with Unity?
There is no Unity GC
please be more specific, I did look at #📖┃code-of-conduct before posting to be sure and did verify I wasn't against conduct. I don't see the quote you posted. Did you paraphrase it?
If so, I'll correct my post.
thanks, i'll update
That depends on the backend you are building to, if you use IL2CPP, then no compaction, if you use mono, then yes compaction can occur
Ah - good point.
Hey guys, I have a small to medium project that I'm trying to convert to unity's new DOTS packages, Should I start with a new project and port the code over, or is it possible to convert my game objects to entitites somehow?
my advice, new project and port, slowly
Its not too large of a project so I should be able to do it in a day or two, thanks 🙂
test, test and test again as you go along
Even for a small project, the mindset for DOTS is so different that it’s a good idea to at least start a new, Parallel project.
Does anyone have a recommendation for a grid-based pathfinding algorithm for groups of fish going from point A to point B in a large group (but not overlapping eachother)?
look up boids / flocking
Well It took a while, but it turns out it had NOTHING to do with the if statement for some really odd reason. I was tinkering around with it for a long time, and I finally found the issue.
When I was moving the gameObject, to move it backwards I would just do the reverse of moving forwards to the next transform, simple enough. The problem stemmed from the fact that it isn't exactly a perfect line when you go backwards, Unity kinda guestimates with floats, and thats okay. The problem was that it was doing this per frame in the update function, and it was guestimating way too much and wouldn't be close enough to the transforms for the if statement to trigger.
Man that took a while, thank you for trying to help though!
Do you have a specific code issue or are you looking for someone to design an entire set of systems for you
All of that stuff is going to take weeks+ to implement
Why are you in #archived-code-advanced if you're just starting?
It's not really an advanced problem
it's a bunch of small problems
which you should tackle one at a time
Glad that you figured it out. Just a note that unity doesn't guesstimate floats. Floats simply are guesstimated. By their design they are not, and it would be impossible for any number representation to be, 100% accurate.
It's always a good idea to use Mathf.Epsilon to allow for some variance.
still trying to figure out what this meant. Internet Coder?
individual contributor
Is there is a way to add gui elements to the list element inside a component?
I have a component (Weapon Controller on the screenshot) with custom inspector. It has button and some logic to create instances inside a list from editor.
And now I want the same functionality inside a list element.
Basically I need to create a button inside this Element 0 object.
I can't add it the same way because I added custom gui by working with "target" inside "OnInspectorGUI()" function.
Example of what I'm trying to do.
public class WeaponBehaviourInspector : Editor
{
public override void OnInspectorGUI()
{
var controller = target as WeaponBehaviour; // can't cast non-Monobehaviour to target
...
}
{
Is there a way to add custom gui to this object inside a list inside a component or I should try another approach?
question: what is the standard method for making a 3d flying AI enemy? Specifically one that can fly over gaps and can seamlessly ascend/descend while chasing the player?
I tried Nav Mesh, though I don't know if I did it right. The enemy only ascends when it reaches a wall and will either just snap itself to the wall's height, or remain at the same height and just be blocked from progressing
@midnight violet I went back to the old system of using render textures to render it overtop of the UI. I got the cameras distance from the canvas by frustum calculations so it repositions to work with all aspect ratios.
A bit unclear how you tried to use NavMesh for 3D navigation
You can do 2D navigation + height type of stuff pretty easily, but other than that it's still a 2D navigation solution
I asked another server and that was the only direction they gave me, wasn't sure if there was just something about NavMesh that I didn't know or what
What kind of space are you trying to navigate while flying? Do you have obstacles in the air?
various 3d environments, from enclosed hallways to more open fields - and likely various props either dangling from the ceiling or protruding from the floor (ex: lights and pillars)
how would i create a spaceship script, inspired by No Man's Sky. Where when I press and hold on the space button. The Spaceship Will float 5 units into the air from wherever it was landed. then Using W will throttle up, but not using a get axis. And using A and D will tilt the spaceship while turning it.
Are Raycasts inconsistent in general? I'm trying to implement a custom edge grab/hang/climb solution using root motion etc, but the character.... I can't get him to grab the ledge in a consistent position, particularly on the Y axis, even though I hard-code it to the ledge's position (+/- a Vector3 position offset to avoid clipping into the edge). For reference I'm making a SSB game. It's like he grabs the ledge when/wherever he wants. It's driving me crazy...
Maybe try a boxcast?
Raycasts are pretty consistent though
It could also be related to how you're going about it. Like maybe it's not firing when you think it is?
I'm using a Raycast which fires every frame via Update() with my other collision detection stuff (it's a custom physics solution based entirely on Raycasting). I even tried switching to FixedUpdate which doesn't change much. I even considered using delegates/events but idek the first thing about how to set it up to fire properly.
I have a preset transform.position, plus different PosOffsets for different characters, but I can't get any of the characters to grab the same, pixel-perfect Y position consistently.
Don't crosspost.
Phew, I thought that was directed at me at first lol
Are you basically checking if a point is positioned a certain way relative to another point?
I never understood the difference between World and Local, if that's what you mean.
Local brings my character back to (0,0,0).
For example, let's say the ledge is on the right side of a platform. If you then pick a point on the player, e.g. their head, you can get the vector from their head to the ledge
Then you can check if they are to the bottom right of the ledge and within X distance of it
(you might have additional criteria though)
What I want to do is when my character is anywhere within the vicinity of the edge when airborne, just grab it and stick to the same position. Because I have Edge getup options, and they use Root Motion, and understandably, I can't have times where he clears the ledge, others he's too high/low)
NavMesh is probably not going to cut it if the obstacles vary and require avoidance/navigation in various axis. There are 3D navigation solutions like Mercuna if you need to do this.
perhaps collider triggers would be more useful?
I'm gonna try your idea of a BoxCast. IF the power can stop being so spotty for five damn minutes. Bloody endless crap weather :/
@analog bane BTW thanks, sorry for not saying
And.... nope. Physics.BoxCast doesn't work. I can now grab the cliff from anywhere as long as I'm airborne...
Then I think something is going on with the implementation. Can you share what you have?
If it works for you and the render overhead is no problem, sure, why not
Yeah the render over the top is the best because I get to choose its layer as its a ui image, in my case I want it over the ui but under the origin point
is there anyway to save a prefab between gameplay (like as json format or otherwise?)
in my game i give the option to create a custom character, created by instantiating objects parented to the player base model during runtime, a reference of which is saved and used as the player model for the game
can i save this player-created gameobject between plays and load it somehow?
Yes, but you have to build that system entirely yourself
rather than thinking of it as saving a single blob of an object, think of it as saving the raw information needed to reconstruct it. You'll need to write the decomposition and the reconstruction depending on what the important properties are, saved as values rather than references to objects
I'm looking to implement some sort of floating origin.
Suppose I have a giant map, separated in 5km grids. Exactly 5km so no fractional part on the floats dealing with the position.
Does it work to just constantly re-parent objects to the center of these grids once they cross the threshold?
Or how is this usually done?
You need to move the entire world (tile) to the world origin. Parenting doesn’t help. All transforms are calculated in world space. It also doesn’t matter if your tiles are exactly 5000 units. Practically no value can be stored accurately as a float.
Context: I want to combine multiple meshes into 1 mesh using Mesh.CombineMeshes(). Each mesh is a part of a bigger mesh that I want to combine into 1 big mesh. Armature will also be combined, but separately
Issue: Mesh.CombineMeshes() removes 114 vertices, both when import setting Weld Vertices on each mesh part is set to true and false. Is this odd behaviour from Mesh.CombineMeshes and should I use a different approach or is this a bug?
is anyone here familiar with Zenject?
hey guys how do you make a button not be able to be activated when space bar is pushed
because i have a simple pause menu set up where to activate the pause function you can either click f or click the pause button
but if i activate the pause menu by clicking the button, and then i click f to unpause, the pause button is still somewhat "selected" even after i've unpaused, leading to the spacebar ingame to keep activating the pause function as it clicks the pause button
and i can see this with the fading feature where you hover over a button and it goes a bit darker
if i pause using the pause button, the button goes and stays a bit grey, and then when i unpause using something that doesn't require a mouseclick (clicking f), and then i go back ingame, the pause button is still grey.
yourButton.interactable?
yes but that will make the button unable to be used at all
i need it to not be interactable just to spacebar
wait never mind dude i fixed it
i set navigation to none
I think the problem lies with the Update method. It's all I can think of.
hey guys how would i make a code that quickly increases and decreases the size of a text? because i want my player score at the top of the screen to quickly bounce in size whenever the score is increased but how would i code it? i can't just do
text.fontSize += 4
text.fontSize += -4 because that won't be a smooth movement
Dont know if there's something that can animate text like that, but if there is someone else will probably chime in, I'd just use Mathf.Lerp in an update function to smooth transition
I would like to ask how can I enable a gameobject when my mouse is onto the object. This is a UI in my game and I want the outline show out when player mouse move to it.
there is a package from unity called json scene serialization but it's tricky to use for your purpose
what are you trying to combine? it sounds like your source asset is glitchy
I am combining different parts of a robot, so I can make procedural enemies. I made a whole set of parts in Blender that I want to combine in Unity.
hmm
why do they need to be mesh combined
I fixed the issue of the different vertices by removing Mesh Optimization
okay
But the bone weights are probably set incorrectly
So I am still getting an exploded mesh as a result
The bones are correct and the mesh is correct
i'm not sure why you need these combined
i don't think you can use meshcombine to correctly combine skinned meshes and get a valid skinned mesh, and expect everything to just work. there are a lot of considerations
this is more involved than you imagine
Thank you for explaining that, but that does not help me. As I said, the mesh itself is correct. When reviewing the mesh in the mesh field on a SkinnedMeshRenderer I get the correct result, but in the scene it is messed up by, what I assume to be, incorrect bone weight assignment.
does anyone know a documentation for car physics by any chance? something along the lines of https://catlikecoding.com/unity/tutorials/movement/complex-gravity/
I got a car working with it, but I need something more custom as the wheelcollider is very flawed, even in the way the values are interpreted
Then I do not know any documentation. Just beware that you are going on a long journey.
From looking at how long it took other people to make something like that, I can defenitely see that its a long journey. Thanks for the help tho :)
Hello, I'm working on a skill tree system and i'm completely stuck... The tree consists of multiple nodes with a Skill Script attached to it and each node can have multiple connected nodes (picture 1). Every connected node is also stored in a list in the skill script.
The activation for a node works fine, I just call this:
public void ActivateSkill()
{
if (!isActive)
{
if (isUnlocked)
{
isActive = true;
foreach (var connection in nodeConnections)
{
connection.activeConnections++;
}
}
UnlockConnections();
}
}
I increase the activeConnections for every connected node to keep track to how many active nodes the skill is attached.
Now what keeps my brain melting is the deactivation... I want to be able to deactivate a node but only if there is no active node ahead of the deactivated node so there wont be gaps in the tree. I tried so many things but i just don't get the logic right... Is this even possible to track with the information I have?
Hey guys, I'm upgrading an existing project to use Unity DOTS. Currently I am using the unity.entities, unity.entities.graphics, and unity.physics packages
I created a sub scene which I names MainSubscene and added a 3D cube gameobject to it. This 3D cube has components RigidBody and a script called PlayerMovementController added to it. However when I click play nothing happens. I would expect the rigidbody to make the player fall at least (the player is hovering in the air)
(Is Kinematic is not checked and Use Gravity is checked) I feel as if my subscene isnt running, any ideas?
Disable disconnection when the current nodes nodeConnections.Any(x => x.activeConnections > 0)?
Don't you have access to the target node in whatever datatype your connection is from?
Usually they are structered like this
public class Edge {
Node Source;
Node Target;
}
With this you can then disable deactivations of a node like:
public bool CanDeactivate => !this.ChildrenConnections.Any(x => x.IsActive);
I also don't quite get why you need to keep track of the number of connections
If you already track the active number of nodes
the activation of a node can be checked by running
public bool CanActivate => !IsActive && this.ParentConnections.Any(x=> x.IsActive);
I have only access to the node itself and the connection nodes directly attached to it. So I don't know how many connections the connected nodes have.
Thats fine right?
My examples only use parents or children
And you can derive whether or not a neighbouring node (if you want to insist on having a single array) is a child or a neighbour by checking if the current node is a target or a source of the connection
I am assuming your skill tree is directional by the way
the path could go like the red one or the green one
Aha, so its undirectional!
ye so I can't just decide which node is a parent and which node is a child right?
Nope, there's no relation between the two
I can't think of a smart method to do it right now, but what I know can work
Is that you traverse the entire graph, and imagine that the node has been removed
If the number of nodes reachable is -1 the graph size that was prebvioulsy accesable
you know that you didnt create two disjoint sets of nodes
that's why i was storing the activeConnections.. So I could check if a connection from the next connection has any active nodes so that I know that it's connected to anther node but writing that alone is confusing me again 😄
will do! Thanks
This is all the information I was going to give to you -> you are looking if all of the nodes still form a connected component after removing that one node
If you still need help later on, be sure to post another thing
Thank you! I will give it a shot and come back to you guys
More information on Graph Theory would be https://en.wikipedia.org/wiki/Connectivity_(graph_theory)
(Or any other source on Google on Graph Theory/Connected Component)
bump
error CS0246: The type or namespace name 'MongoDB' could not be found (are you missing a using directive or an assembly reference?)
Im getting this error after installing the MongoDB packages through VisualStudio. What beats me, is that VS dosent find any errors, but Unity refuses to compile anything..
is this related to something called "Burst" that gets "not responsive"?
You can't install packages in Unity through VS
Use the unity package manager
Making Unity work with . NET standards and nuget etc are an eventual goal for Unity but not there yet
Hey guys, quick question when using unity ECS unity.entities and unity.entitites.graphics is it required to use URP?
maybe a #archived-dots question
thats not a channel I can type in
you're at the beginning of a very long journey
could be. This isnt the first time Ive used mongoDB though, and last time I feel certain I never installed anything through the unity package manager, and that worked.
installed "realm sdk" now though, looks like it might be a bit more flexible in use
are you saying
- you are trying to make a UI
- that lets players click on circles arrange the way you show
- these circles are representing some kind of skill in your game
- the picture you drew isn't a tree, but you said tree
- a skill can only be activated if it is adjacent to another skill.
- a skill can only be deactivated if, as another user said, you do not create two disjointed groups of adjacent skills. that doesn't deal with the issue you are showing with a connected group of skills (where a skill can reach itself by visiting other skills exactly once)
- assign an activate time "T" whenever you activate a skill
- you can only deactivate a skill if
- all of the other active skills it is adjacent to have a lower activation time T_x than T, OR
- a depth first search of the activated skill reaches itself
What I am trying to achieve is a undirected skill tree, like in PoE or Wolcen (nots as big of course but the same functionality). I am completely self taught so there might be stuff that I've never heard off.. Like graphs and dfs for example 😄 But now that I know this is the proper way to go im gonna dig into that. I'll just gonna add a reset button for the whole tree for now till i figured everything out ig. Thanks for all the advice!
kind of an aside but you're looking for the word graph, a tree is a type of graph with some very specific properties: it does not have loops and each node has exactly one parent
in PoE it's actually not a tree at all, even though it's often called that
(might help your search of various algorithms if that distinction is clear from the start)
yes that's what I'm trying to achieve! I just wasn't aware of graphs because whether it's directed or not its always called skill tree everywhere 😄 But thanks for clarifying!
Cars and suspension are actually extremely simple on the surface.
Essentially, you never have an actual solid collider on your wheels, despite the name "wheel collider".
At each wheel well, you'll simply raycast downwards. The length of the raycast is the length of your imaginary spring.
From here, we can determine how much the spring is "compressed" by the distance that it actually hit.
Next, we need to add force upwards on each wheel well, proportional to the amount the spring is compressed. Highly compressed spring? More force upwards. Less compressed spring? Less force upwards.
next you need to add a counter-force to your spring, proportional to the speed of the spring (difference in compression from last simulation tick and current simulation tick), otherwise your car will bounce up and down infinitely like one of those 80's low riders. All we're doing here is adding friction to our imaginary spring to slow it down.
after that, you should have a basic suspension working.
You'll also notice that your car is sliding around like it's on ice, so you'll need to implement a basic sideways friction.
Basically find the current sideways velocity at the wheel, and apply a counter-force proportional to it. If you do this right, when your front wheels turn, your car should also turn. This also allows sliding/drifting if the car is going fast enough. Hint: After getting the velocity at each wheel, you should temporarily convert it to local space, cancel out everything except the sideways component, then convert back to world space.
The "wheel" in this sense is just an empty gameobject positioned at the center of the wheel well. Your raycast can be shot from it. I'm sure you're smart enough to figure out how to position the visual wheel mesh based on the raycast.
Hi everyone im pretty experienced but i don't know everything lol, ide like some help to go in a direction if possible, i would like to spear cast and cut into any object and only remove what's within the spear cast and not the actual object its self i think i need to do something with Voxel Generation
i basically want to program a cookie cutter script for mining rocks, like space engineers
just not sure wear i should start, what things should i look into ?
Check out ray marching, Sebastian Lague has a good video covering the basic principles of it
Then move to Marching Cubes
I have a SerializedField that's null when called in Build but not null in Editor, what's wrong?
thank you
@echo owlRaycast itself returns the triangle you hit
which you can then access directly on the mesh
not sure about sphere casting or anything
how are you accessing in the editor and build? If you're using any null coalescing operators, the editor's fake null for unassigned serializable fields might be tricking you
Not sure what you mean, but here's the field.
calling Debug.Log on it prints Null
(only in build, it prints gameobject.. in play mode)
no operator no nothing
are there any must watch videos or must read articles about URP / SRP been wading through the docs and finding it difficult to get deferred rendering working
wait theres probs a better place to ask this
#archived-urp, yes, this has nothing to do with coding, nor is it advanced
my bad ^_^
Only workaround I found so far is using Resource.Load..
it sounds like you have a bug
Do you use Asset Bundle/Addressable ?
Is the Object loaded from the resources folder ?
this was beautifully explained thank you
dear senior unity, are you guys use DOTS much in your project?
i want to use dots in my pathfinding, but no reference type is allowed in job system....
It was initially just a SerializedField but it was always null IN BUILD even though it was totally fine in Play Mode, I'm considering updating Unity or something, doesn't make sense to me.
Is it a material or shader? Because these will be stripped from builds if they aren't present in any scene or prefab, unless you include them in the "always loaded" list of your project settings
Neither, it's a GameObject
Oh wait sorry, had the same issue with GameObject
But also having it with GetComponentInChildren right now
The issue is very similar, null when it should not be (only in build, not playmode), and in this case I can't just Resource.Load as a bad workaround
(and they were all contained in the scene, so nothing external)
that's one of the reasons I don't like Resource.Load as a workaround
Does anyone have a suggestion on how I should go about fixing this?
I spent hours on this and I'm running out of things to try out
Printing the SerializedField will return null in Build but GameObject in Play Mode
Same thing with GetComponent
Usually, issue of the type of "This Object is null only in build" comes from missing asset in the build. I would consider using AssetBundle/Addressable to have a better control of what is or not included. From there, you have multiple tool available to analyze the issue.
The thing is I don't know what I can rely on anymore and what is good practice, using Inspector fields to get Components from the active scene is something I do often, is it bad? GetComponents I use sometimes too, unreliable? Should I use .AddComponent every time instead?
I look into Adressables and see, but in that case it's the main ui
So it would make sense for it to be already there
oh and I have no errors in the console either
I only see a landing command in there, can you point us to the line of code that handles takeoff?
Unless you have extreme timing it's never gonna happen
This runs once, then you exit the while loop because hasLanded is true
touchedGround I mean
Handle it in Update
Or any method, as long as it runs each frame
lots of ways. your problem is you're only checking input in the same frame the colliders first touch
alr
think of a way to not do that, and you have your answer
maybe, try it then ask
Yes
what is a basic bool I cna define for isGrounded
what?
You already have it?
i dont
touchedGround
but is that a one time thing?
Not if it's declared in the class, checked in Update, and set to false on takeoff, for example
The landing coroutine sets it once, but its value doesn't change until you do so elsewhere
#💻┃code-beginner at this point
You also have a bool landed; declared in the class, that's unused. You could use that
or at the very least a thread
the touchedGround is defined in the courutine
how do i take it out of the corutine
wait
wait
wait
Migrate to #💻┃code-beginner. I have to go, someone else will take the lead
Okay, so some new progress on my issue, it seems to be way bigger. I tried creating a dumb script, it will only print in Play Mode, never in build.
It's at the root of the project, with a gameobject assigned (created an empty one also at the root of the scene), which can also be verified by the fact it works in Play Mode.
Also note there are no errors, the rest of the game is playable.
You have something wrong with your setup and we cant help you because we do not have access to your project. The only thing I can say, is that you should always be able to have reference by [SerializeField]. If something is there is the Editor and not in Build, it is most likely an issue with how the asset are being added to your build.
As much as I would like to help you, there is nothing I can do there. You need to look into it yourself and find out why your asset are not included in build. The best way is to ensure that it works is to make sure that you are correctly using Addressable (If you use it).
How do you fix build issues?
This is what I'm saying from the start. Look why the asset is not included in build.
So it's possible something in the scene is not included in the build?
That doesn't sound like that's how it's intended to work but I could be wrong.
It should not. But who knows. You may have a strange way to bundle your asset.
Where am I bundling assets?
Or how does one bundle assets, except adressable and Resource.Load?
I assure you that it works out of the box. It is something you have done wrongly. (At worst, it could be a new Version issue, which would be unlikely)
Addressable most be build and loaded manually.
I've done things this way for about 1 year on this project, and code that is EXACTLY the same, only difference it not being new, works.
Are you sure you are loading your resources correctly ?
What do you mean?
At edit time, how can I create an instance of a prefab with a link to the original in the scene?
Shit I think I figured it out, even though in Play Mode I use 0-2-2 as a scene, I think the build is just using an older version. Will try that out but it makes too much sense to not be it.
the prefab utility class should have those methods
Hi!
I apologize if this is the incorrect channel for Timeline related questions.
I'm currently pausing my Timeline by using a Signal Emitter that sets the speed to 0.
This "works" but the issue is that I'm getting varied results of when the Timeline pauses.
Though every time, it pauses a bit after the Signal Emitter is reached.
Is there an alternate way of pausing (setting the speed to 0) my Timeline outside of using a Signal Emitter? I'd like to be able to pause my Timeline immediately so it's consistent.
Thanks!
I believe you cannot pause the Timeline exactly where you want as it is on a separate Thread. I am not 100% sure though.
what is your goal?
programmatically pause a cutscene while the player does something, then when the player is done, resume it?
Yes
can't you loop somewhere instead? also, if you already have this working, if you know it's always pausing at around the same time, maybe add a little bit of slack?
what is your specific question
i'm surprised you can't stop the playhead exactly
Adding a little bit of slack isn't a very reliable fix unfortunately 😅
so help me understand, you are calling PlayableDirector Pause and it's not pausing "exactly" where you want it?
what does the signal event emitter have to do with it?
The signal emitter is whats calling the method that pauses the timeline
this is kind of a general programming question or even beginner. you have to break down the problem into smaller pieces 🙂
If there's an alternative, I'm not aware of it
why are you setting the speed to zero instead of calling Pause on the playable director object
Setting the speed to 0 pauses the Timeline in the traditional sense
the game object that has your timeline should have a playable director component
okay
but i'm asking why you are not doing it uh
you know, the way that i am saying
it's okay if it's "i don't know how"
Sorry, I'm not sure what you're asking me
Yes
or are you trying to achieve something happening in timeline without any scripts
can you show me the code that achieves this
My signal emitter is calling a method that is on a script. I really appreciate you trying to help but it doesn't seem like you are very familiar with Timeline.
can you show me that method?
Sure.
{
director.playableGraph.GetRootPlayable(0).SetSpeed(0);
}```
okay, so help me understand, why are you not doing director.Pause()
Because Pause() suspends the timeline at the current time and stops evaluating it. That is why people shy away from it in favor of just setting the speed to 0.
If it gives you peace of mind, using Pause() has the same issue because of exactly what Simferoce mentioned
That's why I'm trying to see if anyone uses an alternate method of pausing their Timeline instead of using a Signal Emitter.
okay... why not set the time to the time you want?
you can defer it if it seems ot interact poorly with pausing
e.g.
void StopTimeline() {
StartCoroutine(StopTimelineDeferred(signalEventEmitterTime));
}
IEnumerator StopTimelineDeferred(double exactTime) {
director.Pause();
yield return new WaitForEndOfFrame();
director.time = exactTime;
// you might have to evaluate the director here, not sure
director.DeferredEvaluate();
}
i'm not sure why it isn't happening exactly when you would expect it to. you might have to manually update your playable directors - i always do
because it's easier to wrap my mind around script execution order that way
i wouldn't use a coroutine, i would use an async task, but it's the same thing
@warm dust maybe this will work. i agree it's very odd that what you are doing is buggy*
i wouldn't set the speed to zero in any case
that makes the least sense 👀
i mean unless it specifically worked around this issue
you might be able to skip the waitforendofframe actually
you might just have to set the time and call deferred evaluate
and before the scene is actually rendered (i.e. within LateUpdate) the director will evaluate as expected
@warm dust does that work?
No, but that's okay I appreciate it. I'll figure something out. 👍
that exact code did not work?
does it go to any time?
like if you set the time to 0
does it go back to the beginning?
why people shy away from it in favor of just setting the speed to 0.
i suppose if you want someone really experienced with timeline to make game cutscenes, your colleagues can go hire a contractor!
Maybe if you were to use PlayableDirector.Evaluate manually, it could work. I heard some people whine about this particular function that it was removing the threading part of the evaluation which made the thing actually slower than faster when trying to reduce the Update Rate.
calling it manually was the most robust for me
unless playables uses Time.deltaTime, i assume for the sake of simplicity it only advances the clock to the timestamp of the frame that was most recently presented to the screen, which is maybe why this exact issue is occuring
it is the only other robust option if you don't do the science of Time.deltaTime
i.e., the time it "stops" at appears to be slightly ahead of when it was actually called
so no consideration is made wrt the time Pause is called
so basically what i'm saying is
a frame is presented to the screen at time t
a new frame has started
playabledirector.time is set to t
the user calls pause at time x, which is necessarily ahead of t
playabledirector is now going to compute the graph for time t, even though we are "t + Time.deltaTime" ahead
a frame is presented to the screen at time t + total frame rendering time containing playablegraph contents t
a new frame has started
playabledirector.time is set to t + total frame rendering time
...
playabledirector is NOT going to compute the graph for this new time, because it is paused
@warm dust @dusty wigeon does that make sense?
okay based on a visit to the source code, this is indeed what happens when DirectorUpdateMode is set to DSPClock. @warm dust you can try experimenting with GameTime, UnscaledGameTime or Manual instead?
the time isn't set to t + total frame rendering time but it is not set to t + Time.deltaTime either, so it will have the same discrepency
there are a lot of considerations in the source about time accuracy
i think if you are using sound, it might make sense that it is not at the exact time you call pause
Thank you everyone who directed me to Cube Marching yesterday, created a working proof of concept for my vr astroid game to get started
decided to tackle Marching Cubes in VR for the first time for a mining game, hears a proof of concept .
Beware of performance, such feature can be expensive to operate depending on the amount of objects being process. You should make sure that you obtains valid FPS from the hardware you use as well before commiting. The requirement of VR headset can be hard to meet.
That being said, I am sure you can find a solution that could work, but you may have to restrict your usage of this feature.
Once you get this working, you can replace the raycast with a cylinder shape cast and have an actual 3d wheel simulation going
I think it's called sweeptest
damn thanks ill look into that
@warm whaleYou don't just "setup A star". You implement it into your game. It's just a search algorithm.
That doesn't make any sense
What part are you stuck on?
You should have something that resembles walkable nodes. After you've found a path, it should be as simple as interpolating the NPCs along that path.
Right, so I did more testing on my Edge grabbing? It works fine, for the most part. The raycast RESULTS are just VERY delayed, and so for varying times. Hence the varying Y axis positions when grabbing an edge.
So I have this code to run when airborne, because I only need edge grab/climb when in the air. I'm running this in FixedUpdate() but I notice no significant change from running it in Update()
{
Vector3 rayOrigin = (user.Sign() == 1) ? raycastOrigins.topRight: raycastOrigins.topLeft;
Debug.DrawRay(rayOrigin, user.Sign() * user.parametersFile._CliffCatchRayLength * Vector3.right, Color.red);
if (Physics.Raycast(rayOrigin, user.Sign() * Vector3.right, out RaycastHit hit, user.parametersFile._CliffCatchRayLength, cliffMask))
{
collisions.onEdge = true;
user.EdgeGrab(hit.transform);
}
else
{
collisions.onEdge = false;
}
user.animStates.SetBool("Fighter_OnCliff", collisions.onEdge);
}```
What on bloody Earth? Seems pretty standard to me 🤷♂️
There's no such thing as "delayed Raycast results". Raycasts are instant.
Doing it in Update will change nothing since collider positions only update during the physics simulation step
But the collider doesn't move. It's totally static. But sometimes it hits, others it won't. And sometimes I get an insane delay between the hit and the action. It's totally weird. All that's supposed to happen is, my character gets "warped" to a position where it looks like his hand is flush on the edge, which can differ for different characters, ad that's it. Why it's so wildly inconsistent, I don't know :/
You'd have to show what you mean
And add some logs
The logs just show up when the (delayed) action happens. But I'll show a snap or 2, hold on
what do you mean by delayed, Raycasts like most things are blocking it returns right away
Thanks for the replies. Got any idea how HARD it can be to get noticed on this server? D:
Anyway, THIS is what I mean by DELAYED: In this shot, the raycast is INSIDE the collider, but does nothing. Only frames later will he actually grab the "edge", which by then, the character looks like he's grabbing wall instead of the corner. And that Y position varies all the time: he can be on the floor, just inches above it, and even above the edge.
Every online solution I've "found" is rigidbody based, which doesn't help. It's a custom solution.
Wouldnt that be an animation issue ?
No. I checked my transition times, etc. All checks out. It's setup to be instant.
If you detect the collision the frame you do and you act accordingly, then it should work.
There is no delay in detection.
It's so weird. I can code a moveset "scripting" interpreter, but this completely eludes me.
But it just doesn't want to detect it right away.
Raycasts that start inside colliders will not detect those colliders
If you do Physics.Raycast(...), it detects right now.
True
You can also use SphereCast.
Spherecast has the same limitation
It's firing from just outside the character's collider. This isn't trying to collide with itself (the character)
SphereCast with points*
It's unclear from your screenshot which collider is which
The collider I have highlighted is the Edge's.
Sorry for not clearing it up
yeah and it looks like the raycast starts and ends in the edge collider
so will detect nothing
I even tried to use a Trigger.
So I should give it a start offset, in a sense, to fire it from more in the middle?
What does "use a trigger" mean exactly
Trigger rather than a solid collider. IsTrigger
That doesn't change anything about the way Raycasts work
Very odd. I don't mean to criticize, but the way the Docs are written make it too cryptic and hard to understand.
In fact I assumed it was already a trigger since the character is inside it
its just a matter if where you raycast starts
There's a specific callout in the docs for this
..........I wonder if I should start the Raycast from the corner BEHIND the character's head rather than in front.
You'd probably be better off with an OverlapXXX call than a Raycast here
will be easier to fine tune and configure that too
I tried overlap but it lacks much of the precision I need from a raycast (layerMask, etc)
That is what I was thinking lol.
It has layer masks
If you need contact info that's maybe different
I was think Overlap Capsule for things like attack hitboxes later, but for this? 🤔
i dont believe this is exactly true, this is what collision matrix settings are for ?
capsule also has layer masks
It's true, read the docs for Raycast
You can start by using an OverlapSphere than go for Raycast if you detect a collision.
Notes: Raycasts will not detect Colliders for which the Raycast origin is inside the Collider.@warm stump
That's interesting, I had no idea...
Even the other video tuts I watched didn't make this clear.
thats a quote directly from the docs
I don't often read the docs. Most of the time they don't explain stuff in a way I understand. I'm mostly a self-taught Unity dev. I have very little programming background, mainly from Java so it helped with C#, but that's it.
its a habit to get into. if you hit issues its often a good use a time reading up on the building blocks of what you are using
For other stuff it's mainly very barebones explanations, so yeah. I turn to the Docs first usually, and almost always leave with more questions than answers.
Unity's voice recognition randomly stopped working for some reason and I have no idea why
I gave it permission, and it definitely worked before and I didn't change any code with it
Aha! Changed by Raycast origin to the corner of the collider BEHIND my character rather than right in front of his face. WAY BETTER, it actually hits every time for starters!~ Thanks!!! ❤️
Now just gotta mess with my Vector3 position offsets!
Can anyone tell me if they see anything wrong with this code? It's just meant to change the position / rotation of each of the children in the "terrain" prefab, but both the position and rotation seem to be refusing to change.
I debugged the newTransform values and they seem fine, but it doesn't seem to be actually applying to the object.
I'm new to programming so sorry in advance.
The transform part isn't working either though and I can't figure out why. Was working fine earlier
Quaternions are not Euler angles.
What this means:
- They are not a 3-axis system, they should not be considered rotations about
x,y,z.- Their individual components are not to be used.
x,y,z, andware for advanced use cases only.
You wantlocalEulerAnglesoreulerAngles, notrotation.
Thanks I'll check that out, but even if I comment out the rotation part
The transform is still not working
It's like childTransform isn't being changed
But newTransform has the correct x, y and z values
Have you done any debugging? What are the child transforms? Why would you need to change the positions of children instead of just rotating the parent?
Can't rotate the parent as terrains apparently can't be rotated
The child transforms are basically all of the objects in the "terrain" prefab
I've tried debugging for the last 30 minutes and can't figure it out, all of the values match up but it's like the transform isn't being applied to the child transforms
It's not actually taking effect
But the debugs show the correct transform values
And it was working perfectly fine earlier, it just stopped after a small code change which was completely unrelated to this
Presumably your sub-objects can still be parented and rotated, even if the terrain can't be
Yeah but rotating the parent doesn't have the required effect so we had to do it this way, it's for an infinite runner. It basically spawns a terrain prefab one after the other, and that code there goes through that prefab and changes the location of the children objects to the opposite side and sets a random rotation so it always looks different
Hey all. I hope this is the appropriate channel to ask this question. I find it rather complicated considering that I'm not the best at math. I think I have a general idea of how this could be done but don't know how to put it down in code.
Essentially, I am trying to snap objects to a 1x1 grid on a plane of ANY angle.
The picture basically shows the problem I am working with here. I hate the overlap here. I want them to snap to a grid no matter what angle plane the object lands on.
private void CreateGridSpace(Collision collision)
{
Vector3 pos = collision.contacts[0].point;
Vector3 normal = collision.contacts[0].normal;
// This is just some things I think might be helpful which I found while experimenting. Not sure if I will use them or not. Figured I'd share just in case.
Vector3 tangent = Vector3.Cross(Vector3.up, normal).normalized;
Vector3 bitangent = Vector3.Cross(normal, tangent).normalized;
Debug.DrawRay(pos , normal, Color.cyan, 1000.0f);
Debug.DrawRay(pos , tangent, Color.blue, 1000.0f);
Debug.DrawRay(pos , bitangent, Color.red, 1000.0f);
// This is the code that actually puts objects on the surface, rotated accordinglty
Vector3 upDir = Vector3.Cross(normal, Vector3.up);
GameObject newGridObject = Instantiate(_gridObject, pos , Quaternion.identity);
newGridObject.transform.rotation = Quaternion.LookRotation(-upDir, normal);
}```
I appreciate any help
@austere jewel Fixed everything, ended up being a logic problem and me not using my brain. Was in front of me the whole time. thanks for the help though 🙂
from this
to that lol
Do you have the logic to snap to a 1x1 grid positioned at the origin? If so, to make that work for any plans angle, the best approach would be to do the logic in the local side of the plane so the math is always the same and relatively simple
I've actually been tinkering with a slightly hacky but good workaround. I am creating a primitive plane on the position which becomes the parent of the instantiated object, and then the only thing that has to be rounded is the X and Z, and then the plane is aligned with the surface.
I believe I'm off though, It's not quite working as expected on surfaces other than the ground
GameObject newGridObject = Instantiate(_gridObject, pos, Quaternion.identity);
GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
plane.GetComponent<MeshCollider>().enabled = false;
//plane.SetActive(false);
plane.transform.position = pos;
newGridObject.transform.SetParent(plane.transform, false);
newGridObject.transform.localPosition = new Vector3(Mathf.RoundToInt(pos.x) - pos.x, 0.0f, Mathf.RoundToInt(pos.z) - pos.z);
plane.transform.rotation = AlignWithSurface(normal);```
Since the plane is set to that position then the grid object can't be rounded since its already locally at zero.
im trying to make my axe aim at right stick in the new input system using```
private PlayerInput PlayerInput;
private Vector2 rightStick;
[SerializeField]private Transform Axe;
private void Awake()
{
PlayerInput = GetComponent<PlayerInput>();
}
private void Update()
{
rightStick = PlayerInput.actions["RightStick"].ReadValue<Vector2>();
Vector3 dir = new Vector3(rightStick.x, rightStick.y, 0);
Vector3 aimdirection = (dir - transform.position).normalized;
float angle = Mathf.Atan2(aimdirection.x, aimdirection.y) * Mathf.Rad2Deg;
Axe.eulerAngles = new Vector3(0, 0, angle);
}```
but it doesn't work it just aims to at random position any one know how to fix?
(dir - transform.position) does not make sense.
why not
Think about it.
i do it like that everytime using the mouse position it works but when using the new input system it doesnt
If you cannot figure out, you are not at the right place. #💻┃code-beginner
i dont think you know either
Vector3
Maybe should be posted in #archived-networking idk --
I'm really at a loss here and would appreciate some direction:
Using the Unity Mirror library, I'm trying to synchronize Server --> Client references to custom NetworkBehaviour objects named ConstructableElement. I have a dictionary:
public Dictionary<int, ConstructableElement> elements = new Dictionary<int, ConstructableElement>();
per the documentation, I took the step of making it a readonly SyncDictionary:
public readonly SyncDictionary<int, ConstructableElement> elements = new SyncDictionary<int, ConstructableElement>();
And recognized I would need to make a custom reader/writer. Because my custom object ConstructableElement has non-writable features, I can not make a custom reader/writer. So I decided to store a reference to the ConstructableElement instead, storing the uint of the ConstructableElement.netId:
public readonly SyncDictionary<int, uint> elements = new SyncDictionary<int, uint>();
But then I realized that uint is also not a supported network type, so I will need to write a custom reader/writer for the uint now. I feel like I'm just going in circles.
Am I approaching this wrong? Or am I really needing to write a reader/writer for uint? Am I missing something? Any input is greatly appreciated.
Hi, I would like to create an ink system, for that I use this script which adds a texture over the texture of the object I want to paint, the problem is that it removes all the black in the texture and not keep any color except white so i would like to know how to keep colors without using shaders
Can someone help me why i get these weird out of bounds indices?
Here is the OnPointerClick Method
public void OnPointerClick(PointerEventData eventData)
{
if (eventData.button == PointerEventData.InputButton.Left)
{
int linkIndex = TMP_TextUtilities.FindIntersectingCharacter(dialogueText, Input.mousePosition, null, false);
Debug.Log($"LinkIndex: {linkIndex}");
if (linkIndex > -1) //check if we clicked a linked text
{
var linkInfo = dialogueText.textInfo.linkInfo[linkIndex];
var linkId = linkInfo.GetLinkID();
if (linkId == "continue")
{
Debug.Log("Pressed Continue");
}
}
}
}
and here is the method where i add the link :
void UpdateUI()
{
// Have a Speaker Dictonary with the Color Codes
dialogueText.text = dialogueText.text + "<b><color=#FF000088>[" +
playerConversant.GetSpeaker() + "]</color></b>\n" +
playerConversant.GetText() + "\n<u><link=continue><color=blue>Continue</color></link></u>\n";
responseDropdown.ClearOptions();
if (playerConversant.IsChoosing())
{
responseDropdown.gameObject.SetActive(true);
BuildChoiceDropdown();
}
else
{
if(!playerConversant.HasNext()) { return; }
playerConversant.Next();
}
}
what is dialogueText.textInfo.linkInfo ?
Thats an array of the Textmeshpro Links
So if i understand correctly every <link> marked element gets added to that
so debug.log dialogueText.textInfo.linkInfo.Length
ok i try that
ok so as i expected the link info has a length of one
but why the hell do i get this random index from my pointer?
AHH IM SO DUMB. I found it
i called FindIntersectingCharacter instead of IntersectingLink
Do you know what a ComputeBitmap is ? I cannot find any documentation online, it is pretty hard to know what it is using to modify the values.
Is it your class ?
Help me mates. I’ve been trying to use a Void Awake method to get the instance for a script of mine, but it hasn’t been working.
ryou need to configure your IDE
Your errors have nothing to do with awake, instance, etc.
IDE?
just a basic C# syntax problem
If your IDE is not autocompleting code
or underlining errors, please configure it:
• Visual Studio (Installed via Unity Hub)
• Visual Studio (Installed manually)
• VS Code*
• JetBrains Rider
• Other/None
*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.
you have obvious, blatant syntax errors that your IDE is not showing you, and you need to configure it so it shows you them
otherwise you are going to struggle endlessly with basic issues like this
Also, this categorically belongs in #💻┃code-beginner
Well, @storm totem maybe would be good to get some, basics of syntax learned. As that was comming right into eye the issue with the brackets
Hi, anyone have an idea how to launch a .jl (Julia) program in the background? I've set up the following https://hastebin.com/share/gonivomeke.csharp and I don't know why it wouldn't work... (If this is the wrong channel please correct me | Reposted because it kind of got lost)
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
you've hardcoded a bunch of paths that are not going to work at runtime, except possibly in the editor
but if you want to know "why it wouldn't work" you're going to have to explain exactly what you mean by it not working
what happens?
So I get the following error NullReferenceException: Object reference not set to an instance of an object JuliaUnitTest.Start () (at Assets/Scripts/JuliaUnitTest.cs:43). I guess the function within my Julia script doesn't even get called. Even if I just return a string without the other calculations, and print outputJson it prints an empty log in unity
NREs are always the same
go to line 43
figure out what's null
(can't tell you which is line 43 in your example since you cut off the top of the script)
the outputJson is null. I don't get why it is null tho
Oh this is always going to return null
JsonUtility.FromJson<Dictionary<string, object>>(outputJson);
JsonUtility doesn't support dictionaries
and even if it did it doesn't support naked collections
So it would work if I used just a string?
It prints nothing. Even if I just return a hardcoded string
if that prints an empty string then your julia program doesn't print anything to standard output
@lavish meteor start with that you place full code first.
43 line is empty, no-one know how much lines you have at top, fix your code, so it's more clear what is crasshing with NullReference
But basically more or less NullReference exception is if you try to access object method without having any object in there
EG:
WhatEvever myVariable;
--> in this process the object was never created and assigned to myVariable;
myVariable.doWhatEver(); // this will cause NullReference exception
How to print anything to standard output? Is that like a file location or something? I thought I'd just have to return my value
when you run a command line program
and it prints things to console
that's standard output
in C# you print to stdout with Console.WriteLine() for example
I have no idea what Julia is or how you write to stdout in julia
Yes, I get that. The reason why is unknown to me though
I tried just printing something now in julia but the output stays empty
based on this:
https://www.geeksforgeeks.org/hello-world-in-julia/#
it looks like print() is used in Julia to output to stdout
I didn't define which function it should use, just the .jl file... Could that perhaps be the error?
definitely
how would it know what function to run
you should really test this in the command line first
then bring it to C#
But how would I tell it
idk
that depends on how julia works
and I just learned of its existence 5 minutes ago
It also depends on how Unity works. Do I just enter what I would enter into the command line if I was to run a julia script?
it has nothing to do with Unity
yes
since that's exactly what you're doing
when you do Process.Start
Hello, I created a deepclone of a UIPanel using "Object.Instantiate" but it seems that some of the ui components inside this panel still points to the old UIPanel
how can i reassign them to point to the new panel
?
Generally you should be instantiating prefabs
not objects from the scene
yes thats what i did
then I have no idea what you mean by "it seems that some of the ui components inside this panel still points to the old UIPanel"
you'll need to share specific details.
it is UIPanel class
customOldUIClone.gameObject.name = customWorldInfoPanelName;```
customOldWorldInfoPanel.instance indicates it is not a prefab
but likely a singleton instance which is in the game already
yes
also your naming conventions are all over the place
it is a generic function
Why
Also that's not what you showed in your above example
you showed customOldWorldInfoPanel.instance
customOldWorldInfoPanel - is a variable
I know but it is a bit game oriented
Nobody is going to be able to help you without more details
and an explanation of what you're actually trying to do
the Game is Cities Skylines, i am creating a mod for it, the game has industrial buildings that has panels to them, i am cloning the industrial panel to add my own resources to it
so i have a a copied control class and i want to use the original ui with my control class
That seems like a really bad way to do it
Can't you just add more rows as children of their vertical layout group?
so i copied the ui panel and changed its name to my new class name and also destroyed the control object of the ui and add my object instead
no because the ui depends on transfer reasons and i am using my own reasons and you cant override these reasons and add your own
the issue is some of the ui elements in the UI still points to the old ui
when i click the close button on the UI, the game searches for the old panel name which does not exist
instead of searching for the new panel that is open right now
Sorry to pester you with probably a basic code problem, but I switched my IDE to regular VS instead of VS code and it didn’t change the problem. Could you please explain how exactly could I fix this?
Follow the link for Visual Studio
and future questions can go in #💻┃code-beginner
holy shit the problem was I used [] instead of the {}
my bad
indeed
my asian line eyes really be inhibiting me sometimes -_-
like I said, #💻┃code-beginner 😉
Guys. no idea why I'm getting this behavior while I'm not debugging. I'm getting a classic null exception on a script because the object doesn't exist... but the thing is the game is NOT running, not even in debug. and the only way to get to this part of the code, is to get into "start()" mono class...
I have no idea why it does that. Ever happened to anyone?
you'd have to show the full stack trace of the error
There is a public variable for this variable, so will unity try to initialize even though it's not running?
NullReferenceException: Object reference not set to an instance of an object
GameTypes.Players.Deck..ctor () (at Assets/Scripts/Main/GameTypes/Players/Deck.cs:18)
UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32)
Looks like you have a paramterless constructor throwing the rror
if the field is serializable - unity will create an instance of it to serialize
calling your constructor
hence the error
Hi, just wondering if anyone is encountering an issue with HDRP (14.0.7 in Unity 2022.2.14f1 using DX12) randomly throwing null reference errors from inside UnityEngine.Rendering.HighDefinition.HDShadowManager.PrepareGPUShadowDatas? It will either happen not at all, or trigger 15 or so errors, or sit there for a few seconds spitting out 1000+ until something stabilises internally. This is the Unity editor console of the errors that happen in sequence as well as where the error is generated from inside the HDRP package.
If I add a null check on m_ShadowRequests[i] before the assert and skip the loop if it's null then the errors don't occur (although I'm sure it's not a functional workaround), however the code obviously gets reset before next run since it's just changing the package cache, so it's not a long-term fix.
Should also mention that none of the lights in the scene have shadows enabled
You should try to report the issue.
private void Update()
{
chaseTime();
}
void ChasingDown()
{
isChasingDown = true;
}
void chaseTime()
{
if (isChasingDown)
{
Vector3 directionX = (playerPos.position - transform.position).normalized;
transform.rotation = Quaternion.LookRotation(directionX);
transform.position += directionX * chaseSpeed * Time.deltaTime;
}
else // Otherwise, move towards the next waypoint
{
MoveToNextWaypoint();
}
}
private void MoveToNextWaypoint()
{
if (waypoints.Length == 0)
{
return;
}
Vector3 direction = waypoints[currentWaypointIndex].position - transform.position;
direction.y = 0f;
if (direction != Vector3.zero)
{
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(direction), rotationSpeed * Time.deltaTime);
}
transform.position = Vector3.MoveTowards(transform.position, waypoints[currentWaypointIndex].position, speed * Time.deltaTime);
if (transform.position == waypoints[currentWaypointIndex].position)
{
currentWaypointIndex = (currentWaypointIndex + 1) % waypoints.Length;
}
Invoke("MoveToNextWaypoint", 0);
}
Hi guys sorry. The object that have this script moves funny, like really stupidly fast. Any rreason why? 😦
once you initially call MoveToNextWaypoint it will then begin calling itself over and over
ohh thank you sooo much!!
IEnumerator OrientationChangeChecker()
{
while (true)
{
#if UNITY_EDITOR
Orientation = UnityEngine.Device.Screen.orientation;
#endif
Orientation = Screen.orientation;
yield return new WaitForSeconds(0.5f);
}
}````
Would this be a bad approach ? im worried about using the while(true) but i want this to be checked during the lifetime of the game.... also.... is waitforseconds going to create garbage or can I use it like this?
while(true) is fine as long as the loop eventually yields
WaitForSeconds is a class, so i would expect it to result in garbage
but...probably not the biggest deal
i was using a waitforendofFrame but i found it excessive too
this runs once every few frames
its a damn sudoku so 😅 but its a test for a game company so they are gonna be picky
oh right, one thing
if you're REALLY picky about memory usage, you can just make a single copy of the WaitForSeconds and return it repeatedly
if you are worried about gc
private WaitForSeconds fiveSecondWait = new WaitForSeconds(5.0f);
IEnumerator OrientationChangeChecker()
{
while (true)
{
#if UNITY_EDITOR
Orientation = UnityEngine.Device.Screen.orientation;
#endif
Orientation = Screen.orientation;
yield return fiveSecondWait;
}
}
whats the difference? the class being reused?
yeah, it's only allocated once
I do this for stuff like MaterialPropertyBlocks
for example? i use also materialpropertyblocks in some parts of another game
it can be as goofy as
public class Something : MonoBehaviour {
private MaterialPropertyBlock block;
void Awake() {
block = new();
}
}
or, if you really want to go the extra mile
public class Something : MonoBehaviour {
private static MaterialPropertyBlock block;
void Awake() {
if (!block) block = new();
}
}
i asked about this on the forums a little while ago
this gets very goofy very quickly :p
ah ok i get it now
I do something similar for things like physics queries
private static Collider[] justOnePlease = new Collider[1];
im creating each time a new property block Im seeing
i use that for a function that tests if any colliders are in an area
i don't care which collider I get
but didnt find any issue
that'll produce a decent bit of garbage if you're setting lots of property blocks
hmmmm, ill note it down
I noticed it when profiling one of my games. I was creating a block for every single mesh on a character every frame!
Hi; I've a super swift question about Unity's Entities package. I've been considering learning it for a project and am currently trawling through documentation to try and understand how it works. My question is about unmanaged components; can you store Unity objects like Texture2D's, Meshes etc. within unmanaged components, or do these have to be done with managed components. I ask as a key component of my game will be runtime generated meshes and such, and I'm trying to scope out how that might look in my head. Thanks!
I was trying to study some of the components in the Entities Rendering package, as they have components that reference Meshes and Materials, but I couldn't determine if they were considered managed or unmanaged components.
How Idle Games Handle Huge Numbers?
i don't know if this counts as a coding question but
is there a way to connect two projects together like two clients? i am in this scenario because i am trying to run a server on my android version and join on my pc version (both are different projects)
using mirror btw
On Mirror, how can I find a spawned object via its netId? I'm trying the following:
NetworkServer.spawned.TryGetValue(elementId, out NetworkIdentity networkIdentity)
...but apparently NetworkServer.spawned is an empty dictionary. This is occurring on a newly connected client. The client joins, and all over SyncVars are good -- but when the client tries to refer to a network object via the netId the dictionary is just empty.
I would be surprise if you can by using mirror. I am expecting mirror to make some assumption on the structure of the project for the network identity of the objects. You could probably find alternate means to control the identity, but it would be ill advice to go against what the library was intended for. I suggest you look in alternate network solution that are of lower level in term of their entanglement with Unity. I would suggest you look into Unity Transport which is what Netcode for GameObject is build on. (https://docs.unity3d.com/Packages/com.unity.transport@1.3/manual/index.html) However, note there is a variety of possible solution.
https://docs-multiplayer.unity3d.com/transport/current/minimal-workflow
how do i download unity transport?
also if it's okay
would you be able to provide a simple solution
for mirror
because gonna be honest
my game depends a lot on mirror and removing it and replacing it would take a long time
Like I said, I do not think mirror is made for such enterprise. However, I do not know if there is any work around. You may want to find other means to get what you are trying to do.
What your game use Mirror for ?
Why does it suddenly require a separate project ?
Package Manager
multiplayer between devices
android and pc versions
i have target specific packages btw
unity transport is just a protocol for reliable data transport
so using conditional compilation is not an option
it does sound like you're going to need to do something pretty elaborate here
I am pretty sure you do not need to make a separate project for that.
like i said
You can manage different library in the same project.
I've done game on Switch, PC, PS4, PS5, XboxOne, XboxSeries without require an other project.
well i'm doing android and pc
Which should be the same.
It is only a different target, but everything works the same.
alright i'll try to combine them
I am trying to have a line renderer move with a game object. I have a line prefab that is instantiated on mouse down that has an edge collider. the points are made as the mouse moves. I have a script that sets the prefab as a child of what it collides with. When I move that object the line drawn does not move but the edge collider does move and I want the drawn line to move as well. this is in Unity 2d
Hey guys... i have a class with [Serializable] but when i do a test deserialization, none of its public parameters are deserialized. The class itself is deserialized but all of its variables are not.
It looks like this basically:
[Serializable]
public class CharacterDefinition : Definition<CharacterInstance>, ICharacterDefinition
{
[SerializeField]
public int Health { get; set; }
}```
the test data is
"TestDef": {
"ID": "Testt2",
"Health": 3
}```
It deserializes with an empty ID and health is 0.... So for whatever reason the serializer isn't liking it.... The base class is serializable as well so i don't get it. I would expect an exception or something if it was truly not deserializable, but it seems to partly deserialize properly
The issue is that you use a property. Property cannot be serialized. You will need to fully define your field.
From the documentation: CANNOT serialize properties.
https://docs.unity3d.com/ScriptReference/SerializeField.html#:~:text=CANNOT serialize properties.
You can serialize the backing field of an auto property with [field: SerializeField]
Oh interesting... I probably need to still re-assess my design.
Basically i have a data driven game with the concept of Definitions and Instances, i think i over engineered it though.
A given implementation of a Definition would have a shared interface with its Instance which defines the shared properties.
A better approach might be to have Instances derive from Definitions so there's no need for a shared interface
Hello, how can I loop through a list in a SerializedProperty array?
See the resource pinned to #↕️┃editor-extensions at the very bottom
I'm a little further now, I have the element as a SerializedObject, but there doesn't seem to be a property for Transform type
Thanks
That's it, there is no property for transforms, it's objectReferenceValue
Thanks a bunch, figured the rest out. Works perfectly 😄
ask in the Mirror discord
NetworkServer.spawned is serverside, you'll want to check NetworkClient.spawned when on clientside
Did you figure it out? As a shader programmer I'd really appreciate the feature. I am looking into this because I am wondering if it's possible to write custom shaders inside of vrchat.
does anyone know any good resources on flowfield pathfinding algorithms?
I'm working on Flow fields atm and got a good project going
pretty
cool!
are you following a tutorial or anything?
Look up Turbo Makes Games and find the Flowfield vids
Mines has changed quite a bit since it was based similarly on his code but nothing much remains except the algorithm itself 😄
i think flow field is basically per compute distance to target in all nodes, you can run dijkstra
Since Dijkstra starts from a center point and spreads outwards, I don't think there's a point in using it. I don't know the intricate differences but I know PA and Supcom use flowfields. A flowfield is effectively a modified version of dijkstra's algorithm
you start from target node then relax all the vertices
yeah, it makes sense for a uniform grid
unweighted graph we can use bfs
Yes but you don't want to scan all nodes, if that is how dijkstra alg works
the important bit is that everyone learns how to get to a position
rather than only someone
very nice for, say, an RTS with hundreds of units :p
I'm aware that a grid can be scaled and tiled more easily I guess which is what you'd want for large scale RTS. I guess that's why SupCom and PA use them
Yep
oh yeah I was already looking at that lol
i'm trying to remember the name of another algorithm
it computes the path from every vertex to a destination
oh wait, it's every pair of points!
Floyd-Warshall, right
O(n^3) cost, but I guess you can just do it once and then go to bed
yup, that's why I need it. I have a couple thousand soldiers and navmesh is getting quite heavy to run
and DOTS is scary
very scary
I got a basic game working
I came back to it a half year later and I'm having a fun time remembering it all, haha
I made a LOD system so that I could zoom in from earth-scale all the way down to human-scale
replacing cities with blocks and blocks with buildings and people as you get closer
oh cool
it is very wonky, since I avoided using child transforms at all
(they were slowing it down a whole bunch)
also, my first thought would be to create "virtual" agents for soldiers that have the same destination and that are close together
they'd just form up and all get guided by the agent
yeah...
but that would be very rough
I think flowfields would be best though
they'd get stuck on walls, or you'd need to make various agent settings for various sizes of squads
yeah, flowfields sound like the way to go
yeah, that makes sense
floyd-warshall is any source, and target
whilst this is any source, one target
and djikstra's is one source, one target
djistra is single source multi target actually (since you compute all shortest path to other vertice, can be reversed as multi source single target)
a star is single source single target
normally you run path find (single direction path find) from sources to target but flow field you run from one target to all sources
what I think I have to do is have separate pathfinding for unit-level and model-level
total war player lol
yes
i briefly looked into 40k when i entered college
I'm trying to recreate a total war-style game
I tried 40k for a bit, but it was so expensive and time-consuming
maybe you can just group many unit together and find their centre node then start path find....but i have never think how to implement, just a idea, since the word "group" is too abstract, no any solid rules to describe it
yeah, that'd make a lot of sense in a Total War setting
you control blobs of guys
You might use short-distance pathfinding to help them navigate through obstacles
yeah so I have them separated into units like this
lol true
so each unit has an array of nodes corresponding to each soldier's target position
when the unit moves, the soldier will try to follow that target node unless it is given another command (like fighting an enemy along the way)
I'm not exactly sure how I would implement flow fields here, but I'd probably want the soldiers to follow the flow field to the unit's center when they're following the unit, and then if they reach an enemy or get close to their unit, they'd use navmesh to get to their node or a close enemy
i wonder if you could just have each soldier navigate to its "spot" in the formation
and then have the whole formation navigate long distances
that would be lots of short-range paths
well that's what I'm doing now
ah, and it's still grinding to a halt?
well, not exactly a halt
but it could be a lot faster
and it gets exponentially slower the more soldiers I have
hmm
i wonder how it'd look if you just blindly moved the soldiers into position
they'd get caught up in corners sometimes
maybe you could turn on pathfinding if they get too far out of position
bad lol
lore explanation: they're very badly trained
I am curious what Total War does
i don't have a lot of experience with it (i mostly just saw the mandaloregaming reviews, lol)
from the research I've done (it's very hard to find info about it) it seems like they use flow fields
but I'm not sure
might be interesting
you know it's gonna be good when you have greek letters on top of some serious mspaint drawings
right now a battle of ~1000 soldiers runs at about 50-60fps when everyone is on screen, and about 100fps when looking away from the battle
so a lot of it is down to animations (which I have optimized a lot) and rendering
oh hell yeah