#archived-code-general
1 messages · Page 35 of 1
is there an easy way to make an animation run twice back to back?
Yeah, it was
Wdym is not serialized. I see it in inspctor
The EnemyType and Count
Those are props
they don't show up in inspector
yes, you can use [field: SerializeField] but I don't think it makes it modifiable , just show up in inspector
you can't serialize records . . .
wait, i see what you mean . . .
I don't think you should use record if you want mutable class 🤔
Makes sense
again though, unity doesn't support c# records . . .
I see
but if you want to display a property from the inspector, use the [field: SerializeField] attribute . . .
Disclaimer: serializing backing field could be pain in the ass if you need [FormerlySerializedAs] or something later in development
Just create a field and be comfortable 😄
i always wondered if that was used often or at all . . .
Do you mean FormerlySerializedAs?
@leaden solstice you seem to know how to fix every problem I have...why isn't this working? 😄
For example if you have deployed a library and users already serialized something, then you wanna change variable name then you'll need it
put it in a loop . . .
For just simple project I'd use it and re-serialize my prefabs and remove it
What's that animation event for?
Hello, does anyone know why my webgl game doesn't take keyboard input just mouse, it works fine in unity editor, but when i build and test in web it doesn't register any keyboard press, just mouse inputs, im using unity 2019.4
if I do this but loop twice it will just make sure its set to cast 2x and not wait for the first to stop before trying to do the 2nd
character.Animator.SetBool("Cast", true);
casting animation
so my fireball comes out of staff when its at the "top" position
at 0.15f
Sure but seems like you are controlling the timing with Coroutine not animation event
at 0.3f/0f
right
Then what'd be animation event doing there 😄
Anyways I think you want to restart your animation?
Wouldn't trigger parameter more appropriate than bool parameter?
I don't quite follow how it would change anything
how it should work atm...is do cast animation, wait 0.15f(halfway through animation) spawn fireball, wait 0.15f (animation ends) then loop that for as many fireballs as I need
issue is the 2nd fireball spawns at time 0.3f instead of 0.45f like expected
Is your animation looping?
I set the bool to true after 0.3f and the animation lasts 0.3f...so kind of?
Well bool parameter is always true because you don't set it false
if Im not setting it so true it gets over-rode on each frame setting state to idle
when its true...that entire animation plays all the way through
I have another character setup who just loops through the animation...the timing of the animation is correct and has no "time" inbetween
issue is the fireball just spawns at the wrong time
So im experimenting with compute shaders and im running into this really odd problem. Here are the snippets of code: the first is one in C# and the second is one in HLSL. I think you can agree that they're pretty much equivalent. Except that I get 2 different results from each, even though they're calculating from the same data. In C#, i get 1.768514E-08 (expected) and in HLSL i get 0 for some reason and its killing me
I dont see any git channels so iam gona ask here.
I create branch and when iam done with it i merge it to main branch, all normal. Problem is when i push changes to gitlab, old branch stays in gitlab and in vs2022.
I tried googling but either not using right keyword or not asking properly but you would usually flag that branch for deletion cause youre done with it. I dont see any of those options in vs2022. I have to manually go to gitlab and delete branch which asks me "DO YOU REALLY WANT TO DO THAT" and i second question my self a lot cause of that. Anyone knows what to do or just do it manually?
You can locally prune all branches that have been merged
and then push
Well i delete them locally. They are ok, GitLab shows in graph branch has been merged but still keeps branch alive on GitLab
I have a issue with my bullet script
Thats what pruning does, it removes branches from the remote
Apparently if I set the speed too high, it will move too fast for it to detect collisions properly
Change the collision detection mode of the bullet, i think the one your are looking for is called continous, not sure right now though
It's already on continuous
what are the other modes called?
Just "Discrete"
If its still too fast for continous, you can cast a ray each frame from the last position to the current position and check if it hits anything
that takes a slightly bigger toll on performance though
I really need a way too see hidden game objects in hierarchy window. Is there any way to do so?
use raycast to check for collisions . . .
@dusky lake @rain minnow Something like this?
private void FixedUpdate()
{
positions[i] = transform.position;
if (i > 0)
{
RaycastHit2D hit = Physics2D.Raycast(positions[i - 1], transform.position);
if (hit.collider.gameObject.CompareTag("Enemy"))
{
HandleEnemyCollision(hit.collider);
}
}
i++;
}
dont save all positions into an array, just the last position into a vector
otherwise, yes thats what i meant
I tried this and it doesn't work
Did some testing now and think i get it
I will use it more over few days and test stuff but i think i got it
thanks
How would I do that? I'm not quite sure how to
each frame just put your transform.position in a private Vector3 _lastPosition;
next frame check for collision and then put the current transform.position in there again
Can you show me an example because I'm still not sure?
I don't get how that isn't just storing the current position
You store the position after raycast
Well how would I get the first previous position?
You don’t it hasnt moved yet. Don’t do raycast if it’s null
you just call a raycast method using the direction of the bullet and its speed (velocity) as the distance. if a hit is returned, then the bullet is going hit an object when it moves. you can choose to call your collision method during this frame or the next (when the actual collision would occur) . . .
since you only want to check against an enemy, use a Layermask to filter the results of the raycast . . .
The rigidbody.velocity returns as a Vector2. How would I convert it to a float?
.magnitude . . .
Okay, thank you
Alright, this is what I have
private void FixedUpdate()
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, _lastPosition, rb.velocity.magnitude, LayerMask.GetMask("Enemy"));
if (hit)
{
HandleEnemyCollision(hit.collider);
}
transform.position = _lastPosition;
}
Let's see if it works
It didn't
The bullet now behaves strangely
Wait, I know what I did wrong
It now kinda works
If it lands in front of the enemy it will send the enemy flying
that's probably cause I have this
private void OnTriggerEnter2D(Collider2D collision)
{
if (!collision.gameObject.CompareTag("Gun") && !collision.gameObject.CompareTag("Door"))
{
ApplyExplosionForce();
}
Destroy(gameObject);
}
Actually, sometimes it'll apply the explosion mid-air
Not sure what's up with that
easier to create a LayerMask field and select the layer(s) from the dropdown . . .
[SerializeField] private _LayerMask enemyMask = default;
also, you cannot check if (hit) as hit is a RaycastHit which is a struct. a struct is a value type, and value types cannot be null. therefore, if (hit) will always be true . . .
What should I do instead?
Is there any reason that ScreenCapture.CaptureScreenshot could produce a low quality image when in editor/play mode?
int firedShots=0;
protected virtual IEnumerator ShootCoroutine()
{
// cooldown between multishots
while (true)
{
if(pauseShooting==false)
{
//multishots
while(firedShots < attackStats.multiShot-1)
{
character.Animator.SetBool("Cast", true);
yield return new WaitForSeconds(0.05f);
}
firedShots = 0;
}
yield return new WaitForSeconds(attackStats.attackSpeed);
}
}
public virtual void Fire()
{
Bullet fireball = BulletPooling.instance.bulletPools[BulletTypes.FireBall].Get();
fireball.transform.position = firePoint.position;
fireball.transform.rotation = firePoint.rotation;
fireball.Fire(attackStats.attackDmg, gameObject.tag);
firedShots++;
}
public class AnimationForwarder : MonoBehaviour
{
Fighter fighter;
// Start is called before the first frame update
void Start()
{
fighter = GetComponentInParent<Fighter>();
}
public void Fire()
{
fighter.Fire();
}
}```
AnimationForwarder Fire() is spent halfway through the Cast animation
The issue Im having is that it fires off 3 projectiles to start, then 2 over and over after...(multishot = 2) it should only shoot 2 to start with then 2 after
you need to check a reference variable within the hit struct, like if the collider is null . . .
Okay, now it only explodes the enemy sometimes and usually only if its really close
also, this raycast is incorrect. you use the current position for theorigin parameter and _lastPosition for the direction parameter, but _lastPosition is a position vector, not a direction . . .
I updated it with
RaycastHit2D hit = Physics2D.Linecast(transform.position, _lastPosition, enemyMask);
okay, i'd swap the position so you're checking from the last position to the current position instead of checking backwards, from the current position to the last position. also, if you're calling this frequently, it's probably best to use the overload with the array to avoid allocating the RaycastHit every frame . . .
which data path should i use in builds
because Application.datapath doesn't work
System.IO.Directory.GetCurrentDirectory() this one neither
@leaden solstice I was able to get it hooked up to animation events like you suggested
I'm seeing that it kills the enemy way too early now
for some reason its shooting an extra time the first time it "shoots" however and Im not sure why that is
i figured using the animation event would work. that's always the easy solution to use . . .
yep, seems like it should work super easy
I can't figure out why the first time it shoots it shoots 3x instead of 2 tho 😄
I think I'll just erase everything we did and increase the fixed timestep
no, don't mess with that value, it's unnecessary . . .
if it destroys too soon, then you must be calling the collision method during the current (this) frame. if that is true, then it is better to keep it the way you had it before: with the transform.position as the start and _lastPosition as the end parameters . . .
Even when I switch it, it still kills the enemy way before the bullet collides with the enemy
guys please, help me out of my desperation here... these white squares shouldn't be spawning over the blue tiles because they have colliders and are set not to spawn if they collide, but when I generate a new map, it takes in the tilemap collider from the previous map for some reason
so you see there's white squares over the previous spawnable area
I'm actually going insane over this
I can answer this one without seeing code
show the code?
you are spawning the white squares before you are spawning(or resetting or setting the colliders) in the black ones
meaning the black squares the white are spawning on top of are from the previous map still
the white squares are the last thing being spawned
I have checked the order countless times, even debugged it out of desperation
try splitting the code
make it so everything not white spawns, then click like a button on scene and it spawns in the white ones
the white squares are objects, whereas the rest are tiles. The blue tiles have a tilemap collider 2D and are the first thing being generated
Here is the script for the bullet prefab
when I generate a new map, I clear absolutely everything. All the tiles in the map and all the objects, in this case, all the white squares are destroyed
so supposedly I am left with nothing
but when I generate the second map, what happens is, for some weird reason, it takes in the colliders from the previous supposedly cleared map
and generated the new objects over those
If you use Destroy, then destruction doesn't happen until the end of the frame. You should therefore split the task in two frames
so you see the white squares here are being spawned over an area that was in the previous map
hmm
😄
that means my "click button to spawn" would have shown it working that way lol
glad that SPR2 actually knew tho lol
I'll do this but I have a feeling it might be something else
I mean, just throw in a 1 frame wait like SPR2 was saying (after you destroy)(
that should fix i
because the fact is, on my first generation before it destroys anything, it still isn't taking into account any grid, which is supposedly there
probably need to pastebin all your code at some point then
I suppose so...
I've been looking at this for hours though
it actually makes no sense at all
yeah but I mean, there are a lot of people here much smarter and better at coding than me
hmm, it might be better to query where the blue tiles are directly
so odds are its the same for you 😄
this doesn't need to be so decoupled
This script slides down slopes, but it doesn't work on slopes of all directions. If the slope is facing the wrong way, then the object slides up the slope. What do I need to fix here?
public class slope_slide : MonoBehaviour
{
private CharacterController characterController;
private void Start()
{
characterController = GetComponent<CharacterController>();
}
private void Update()
{
// Cast a ray downwards to check for the slope
RaycastHit hit;
if (Physics.Raycast(transform.position, -Vector3.up, out hit))
{
// Check if the slope is steeper than 25 degrees
float angle = Vector3.Angle(hit.normal, Vector3.up);
if (angle > 10)
{
// Move downwards in the direction of the slope
Vector3 slopeDirection = Vector3.Cross(hit.normal, Vector3.right);
characterController.Move(slopeDirection.normalized * Time.deltaTime);
}
}
}
}
you know an object with center x,y and radius r will not overlap with a tile with gridpoint col, row and side length gridSize if
I would calculate the "slide direction" as:
Vector3 slopeTangent = Vector3.ProjectOnPlane(Vector3.down, hit.normal).normalized;```
(in pseudocode)
Thanks, seems to have worked,
check each corner of the grid square
if it is less than radius distance
from the center of the object you are placing
the grid square and object (simplified as a circle) overlap
if you got this far, the grid square and object do not overlap.
@thick socket does that make sense?
so you don't need to use physics at all
you only need to check a few grid squares
whenever you spawn
I'm not sure that's exactly what I'm trying to do though. What I'm doing here is spawning an object through the location of each tile with a small offset for the x/y so it looks more random. The objects themselves aren't overlapping so that much is working well. But for some odd reason, they are only looking at the previous collidable grid for collisions so it always looks like the white squares formed a border over the previous map, instead of the new one
i found a simple implementation online - https://www.geeksforgeeks.org/check-if-any-point-overlaps-the-given-circle-and-rectangle/ - that you can use @thick socket . a snippet is available in c#
you don't need to use Physics.OverlapBox or Physics.OverlapSphere (whatever you are doing) to query whether or not you can spawn an object on a tile
there ar elots of reasons why the time you are using those physics queries is wrong
it's not super interesting to deal with
yeah, I'm doing it because of the objects themselves, since they're spawning at random positions and might overlap themselves
anyway i think you'll figure out on this journey what's going on
someone said that there's a difference between when Destroy is called and when its side effects propagate
but the problem occurs before Destroy is even called
no it's okay. Thank you
when you use the physics system for non-physics things, like spatial queries, there are nuances
it's just what's occurring here makes no sense. Like, for the spawning, it is doing it in the correct positions, perfectly, but only after I create a new map
and since it's a new map, the positions won't be making sense for it, just for the previous map which was just cleared
I don't understand why
the state of the physics data you are querying using Physics.OverlapX hasn't changed between the old map and the new map, but you think that it has
that's it
if you are using Physics.OverlapX to place objects on your map
which i think you are... you haven't shown enough code to know, but that's my guess
I mean I mentioned that a while ago - that the colliders won't update until the next physics simulation
do you see this? It's the first map that's created when I initially run the program. It has no previous reference border
I looked into this
are you placing the objects using physics.overlapX?
and what did you find
this is how I'm placing them now
so this code, to get to the concrete stuff it actually does
within an Update:
do something to the old map
generate a new map
call physics2d.overlapx repeatedly to place objects
I found the Physics.autoSimulate and uhh Physics.Simulation or something like that. I called that and it said in the console there was no need because Physics.autoSimulate was enabled
anyway you can try doing this
IEnumerator ReplaceAndGenerateNewMap() {
RemoveOldMap();
GenerateNewMap();
yield return null;
PlaceDecorations();
}
do you know how to use coroutines?
after I generated the second map, it does the correct spawning of the white squares for the previous map, for some reason
so I imagine it might be that
I'll try this
ok so you never actually solved the problem.
https://docs.unity3d.com/ScriptReference/Physics.SyncTransforms.html to generally force collider updates
or waiting for the next FixedUpdate
where would I put that?
whenever you want to force collider updates
so before I spawn the objects would be a good idea right?
I put it all over the place just to test it out
before spawning the objects, after creating the grid, before spawning every object... still the same result
I also tried this and I may be using it wrong but the map stopped generating at all
there is a lot of stuff going on in your code
my guess is the solution is the one i wrote earlier, which is to not use physics.overlapbox to make these queries*
you could also be using the wrong grid or be misusing it somehow
it's okay to kind of muddle through procedural generation - every procedural map generator has a crazy ants architecture
maybe you can attach the debugger and step through some of your generation steps
and see if what actually happens matches your expectations
I need to give this a try
it's just so hard to know what's going on without seeing all the code
How can I have an array of something (float2 in this case) with a variable length (determined in the C# script) in a compute buffer/compute buffer struct?
this might be asking too much but I can stream it. Though there don't seem to be any voice chats in the server
you would have to reallocate a larger buffer whenever you overflow your current one
kinda depends what you mean by "variable" though
like actually changing over time?
At the start of the game (in the inspector)
I want to have positions for a line, and the length to be set before I start simulating
so that's not variable at all
you just allocate the buffer at the size you've set in the inspector
(or the size of the positions array)
and use it
As far as I know compute buffers don't allow reference types, they might be referring to a NativeArray<T>?
a list will allocate memory if the size becomes larger than the original buffer length . . .
Or I'm mixing it up with Burst stuff
I don't really know what Lists or NativeArrays or refrence types have to do with ComputeBuffers - which was the original question
each element in your computer buffer would be the point of the line
Oooh sorry
seems pretty cut and dried
And I have another question about compute shaders:
If the number of threads is set to [numthreads(64,1,1)], and I dispatch it shader.dipatch(kernelNumber, Array.Length/64, 1, 1);
And the length of the array is 246, the shader gets "dispatched" 4 times.
In the first "dispatch" the id of n cell is n, the second time it's n + 64 (the number of threads), the third time it's n + 64 *2 (the number of threads, times two because it's the third "dispatch")
Am I understanding it right?
you do not do
[VFXType(VFXTypeAttribute.Usage.GraphicsBuffer)]
struct Line {
Vector2[] points;
}
var buffer = new GraphicsBuffer(..., 1, sizeof(Line));
you do
[VFXType(VFXTypeAttribute.Usage.GraphicsBuffer)]
struct LinePoint {
Vector2 position;
}
var buffer = new GraphicsBuffer(..., numPoints, sizeof(LinePoint));
does that make sesne @floral coral ?
it sounds like you already know this
does anyone have any tips for someone starting out making their own 3d assets?
after reading your second question
It does
are you asking is there a technique for variable length arrays inside graphics buffer elements?
Ask in the correct channel would be the very first => #🔀┃art-asset-workflow
yeah, pretty much
I want to make a trajectory line to know where n number of rigid bodies will go in a gravity simulation
Something like the trajectory line in KSP
Hi could someone help me with my WheelCollider code?
this should go in #💻┃code-beginner
because it's a beginner question
okay
also the channel is more active
good to know
I added wheelcolliders, and used GetWorldPose, but when i press play, the wheels go above the car and i don't know how to fix it.
yo, i have a pretty simple question about sprite sorting- is it possible to change a sprite's pivot for the sake of sorting without also changing its position in the game?
gotchyu. this is pretty advanced lol
do you have a working C# implementation?
No, I thought it would be too slow to try it in c# since it gets called called in fixed update to simulate the gravity a few hundred times at least, but (I think) I know how to calculate it
hmm
well you know a lot about this but generally, to get people to collaborate on this kind of problem you need
1 a working C# implementation
2 then you can try making an "HPC#" implementation (i.e. burst-compilable jobs)
3 then you can see if any of this would be sped up by gpu
there are dedicated libraries for gpu accelerated rigidbody physics but they do not necessarily solve your problem
also i'm sure there is a specific implementation in computer buffers for the "n body problem"
@floral coral is this helpful?
it's kind of an exercise for you
if you want this for a game there's https://tzaeru.com/compute-shader-basics-with-unity/
(EDIT: I unfortunately lost the images related to this article. Some of the meaning of the text may thus be lost. Apologies.) In this small tutorial, we'll take a look at the basics of shader programming. We're using the Unity engine as our framework, though the tutorial is meant to
if you want this to learn compute shaders you will have to strugglebus through this yourself
Well it is something, but I want something to simulate a few bodies (15 max) for planets, and more for how many rockets/vehicles there are in a scene. I can simply not make lines for un-controlled vehicles, so this line needs to be generated a few times per fixed update. Then there is the real-time simulation, which is a few hundred times less to simulate. And this is just for a project (of a beginner frankly) and optimization isn't my main concern (that being for the project to work)
really depends what your learning goals are
To learn how to:
Use compute shaders
Use compute shaders to make a trajectory line
I'm not sure if this is helpfull, but I once coded a gravity simulation which could handle about 3000 objects on a single thread, and I used an octree structure to stop it being n^2
I want to have some planets and moons. The main point of the project is programming the vehicle.
it is definitely realistic to do this in a compute buffer from scratch (euler method for n body is very simple)
but 15 is so few, that you will spend more time reading back and forth from gpu memory
due to how that works in reality, in a pipelined graphics engine like unity
than you will computing this in c#
hpc# (i.e. burst compilable C# for unity jobs) is prob the best fit
if you want to learn something
If I write and read from GPU memory on fixed update?
in short, while a gpu is like a 1,000 core cpu, the API to get and send data from it is like a single core computer without pre-emption - it's a queue
for this express purpose, an nvidia graphics card usually has 4 distinct queues (drawing, copying memory, async compute programs, and encoding/decoding video). and async compute isn't supported in editor earlier than 2022.2, and you will need to run the editor in dx12 on windows
so it interacts a lot with your specific hardware
if you do not Do These Really Nuanced Things Right
you will wind up waiting 1-5ms for a result from an async compute shader
almost always (99.9999%) tutorials you read online retrieve the results that were computed from the previous frame
which is to say, if you're willing to wait a whole frame (16ms), use hpc#
do you see what i mean?
SystemInfo.supportsAsyncCompute probably shows false for you in editor right now
I'll make it in C#
lol
okay
i don't want to take you away from your learning goals
it's always a balance
the article i linked is sort of a tutorial but it's bogged down by specifically translating n body to compute shaders
so you'll need to have a correct C# implementation anyway, to understand the problem better
Maybe I'll make some boid or agent simulation, the one's Sebastian Lague made we're pretty cool
you will always want a working C# implementation
if you stick to Dr P's Strategy you're way more likely to get something that works
You seem to know a lot about shaders, it would be great if you could help me on this
I'm writing a procedual planet generator, which uses double for the coordinates in order to keep pressision at higher values.
It's all working great until this problem:
I can't find a way to calculate the square root of a double in a computeshader, while keeping the double presssion
i have actually never written a computer shader
oh xdd
because 99.99999999999% it's the wrong choice for your problem
it s basically hlsl I think
like why are you doing this in a compute shader?
Idk because I thought it would be faster
okay well, the fact that you can't find a way to calculate a square root without loss of precision should be a big signal that it's not for general purpose computing
yes, the only way I could think of was writing my own squareroot function, but that was really slow
you should stick to the same strategy. have something that works in C# first, then use HPC# (jobs), then see what makes sense to turn into gpu acceleration
I already have both of that
okay
is it slow?
did you profile it?
most of the time, stuff that people do is slow because it's written poorly
yeah it s just really cpu intensive
not because it's inherently slow
it s about the procedual generation algorithm, I tested both and indeed the one on the gpu was faster for a mesh of 240*240 vertices
like what is the time complexity of plant generation? probably O(n * r) where N is the length of your starting string, R is the number of rules you have for an L-system
which is nothing
O(n * r)*240 x 240
planes
the planet uses an lod system
and in total I'm rendering 4-8m vertices at all times
which means that yes there are a lot of calculations
I'll show you some of my code if that helps
#myCode
okay
it really depends what your goals are
there is a ton of tradition around making huge amounts of foliage
do you care about any of that pre-existing stuff? @simple mountain
how do you mean?
hmm
okay based on the code snippet you shared you are on the start of a very, very long journey
I used a preexisting library to calculate the noise, but in general I like to do my own stuff
I might be xd
do you know what an L-system is?
don't think so, unless you mean a tree structure
okay, can you correct this? you said planes, planet..
is it plants? is it planets? is it planes? what are you trying to do
noo
and you typoed it
those three things are very different and it looks like you typoed a few times
okay so
Planet referes to a spherical mesh and
Plane referes to a Flat mesh
what are you trying to do
you don't have any plants?
anyway
i think you will be fine on this journey
good luck out there
xdd
you can look at my code if it instrests you and I'm always open for improvements
i think i misread your original problem statement, or your original problem statement had a few typos, before you started editing it
it still has typos in it
what s a typo?
can someone remind me: if I do a physics raycast with a LayerMask.NameToLayer("Foo") Does it only collide with the layer Foo or does it collide with everything Except the layer Foo
it's currently your primary antagonist on your programming journey
my problem is: I don t know calculate SquareRoot of a double in a computeshader
when you have defeated Mr. Typo, you can come back to me
NameToLayer is not the way to make a layermask
You need to use LayerMask.GetMask("Foo")
then it will collide only with Foo
and I could use a ~ to invert that, right
yes
ok cool thanks
Hello, question for anyone out there that might know.. We're using the Input Manager & Input.GetButtonDown(...) in an update loop to trigger certain events. However, we also have a text input field that the user must type in that also triggers the GetButtonDown while typing. Is there a way to disable the Input button events when typing besides creating various bool checks in the update function?
disable whatever script is running said "Update" function
I'm using A* Pathfinding (https://arongranberg.com/astar/) and it seems that the way the path finding works is by manually adjusting the game objects position. Is anyone familiar with A* and how I could modify it to use forces?
the issue with that is that we're using it across multiple scripts in many update functions, a quick InputManager.Disable or something like that would be much much more handy if it exists
A* is an algorithm not much to do with physics at all
it doesn't. If you switch to the new input system you will have a lot more flexibility in that area
Gotcha, would I be better off somehow working on my own AI or are there some alternatives?
I'm using for specifically 2D.
If you plan to use physics in your motion probably yes, I found A* very useful when I did work on 2D
without A* you need distance checks , directions + raycasts
lots of raycasts
;p
hmm I was hoping for an easier alternative. The project I'm working on.. it wont be possible to make the switch to the newer input system.
at least not any time soon
then you're stuck with workarounds
Is there anyway to take the resulting paths from A* and use them to apply forces in that direction through my own code?
You could make yourself some kind of central input handler script that implements its own enable/disable functionality
of course
both in general A* algorithm, and with the Aron Granberg asset
ya there are a few work arounds which are possible, I was just checking here to see if there was any quick solutions to my issue. Thanks for your responses.
from node to node is usually your heading
I thought so, I'm just VERY unfamilair with how their pathfinding works.
Will need to look through the documentation.
yeah! should be somewhere inside the local avoidance class , haven't used this plugin in years but should be possible
something like this for example, no reason you can't use that info your custom move
yes, you'll have to reinvent Input System using Input to get Input System features with Input
that said, you probably should be using EventSystem
if you're listening for mouse clicks
really depends what your goals are. to have a less buggy game?
if you're only encountering this now i have a feeling this isn't a shipping game right @static oracle ?
it might take you a few hours to port to input system
and a few more hours to use EventSystem
and a ton of bugs will go away
Hi does anyone know the best way to handle transitions between areas in isometric games when they are enclosed (like underground areas)
One of tunics development updates shows what I mean
is this a code question?
I believe so at least with how I’m doing it right now
It seems most related to code
At least that’s how I’m currently handling it
wdym by transition ?
TUNIC is an isometric action adventure about a tiny fox in a big world. http://www.TUNICgame.com
Hi folks ♥️ In this video I give a quick dev update and show some behind-the-scenes level design. I hope you like it!
This is the inspiration I’m going for
It darkens rooms as the character enters a new one
Right now I’m handling it by looping through the objects if a room and changing the layer for each one
But I feel like there is a better way
Oh I see, so they are using like a visual mask
yea Layers is something I would think to do as well
Visual mask?
yes I assume Masking is how they hiding the parts they don't want?
It can be anything, it can literally be the shader or something when it steps out of the camera frustum it changes or something
I'm no expert in VFX tho lol don't quote me on this
oh Alr
Yeah same
I really liked the effect it had around edges as well like the little blur
Actually it's a shipping app ready to beta test very soon 😅 I've just recently been hired for some ui stuff and they haven't had any user input text required until now
okay well it's their prerogative. in general naked Input. calls inside an Update is a bug in any sufficiently real game
you will either reinvent input system to fix this bug
or you will use event system
or you will use Input System
it's not really "workarounds"
i mean maybe "workaround" is the right word when you have to do this psychological warfare on your bosses who "just" "want" "it to work"
but dude i am in the no bugs in games writing business*
I totally understand and if it were up to me I would redo these things properly.. but I've just just jumped into this and it's already almost out the door. I think it will have to be bandaids until I can convince them to spend time on it
the plugin i author for publishing unity games doesn't even allow Input. to be used because 100% of the time it is a source of a bug later down the line
just just
you might be too far gone
😛
you're already a critical "Just" patient
just just just get me outta here!
lol
the bandaids are recreating Input System
it truly is
you will be creating a new class that wraps Input. calls
and presenting a new abstraction layer
i've seen this in every codebase that uses Input.
I'm literally half way done doing just that heh
just
😱
pretty sure you’re the only one 
there's no "just" here! this is not an easy thing to do
🙃
your people are not this stupid
you can copy and paste this conversation directly into their slack or discord or god help you microsoft teams
you will still spend the same amount of time
you will spend less time in total using input system
I mean, the entire app doesn't heavily relay on keyboard inputs anyway so a few bugs/missed key presses is not a big issue anyway
there are already a ton of bugs with naked Input.
I tried putting the UI.text instead but no dice
you don't need QA to know that
UI.Text is legacy anyway, you should really be using TextMeshPro at this point
then you can get rid of all this code simulating mouse versus touch inputs or whatever
all this stuff
Anyone know how I can serialize a Script graph in c# ie [SerializeField] private ScriptGraph _scriptGraph ?
random asset from store I was checking out
migrating to Input System, there's a whole page on it
Use UI.Text, auto complete should provide the remaining corrections. Btw #💻┃code-beginner
it's already almost out the door.
unless this is something that you expect 0 people to play
then i guess, you know, it doesn't matter
does this use AR?
in that case, sounds like the asset is outdated
yeah I tried that
didn't work
thus
I came here lol
ahh never mind i got it 😄 [SerializeField] private ScriptGraphAsset scriptGraph;
ScriptGraphs as in, visual scripting?
Anywaysn, thanks for the feedbad @polar marten . I'll pass along some of your tips and hopefully they see the value of upgrading to the input system
lol
okay okay good luck out there
you'd have to do more than just change the type of the variable if you plan to get this working because obviously the code will likely be relying on the specific type of object to interact with it
yeah, was hoping that simple fix would work but the whole script is worthless lol
at least the only thing I needed were the effects 😄
The only reason you would use an interface over an abstract class is if you need multiple inheritance, yes?
use an interface if you need similar behaviour among non-related objects or classes . . .
if all classes can inherit from the same base, an abstract class is fine . . .
Can you provide an example of when you used an interface rather than an abstract class?
if you can damage enemies and obstacles, like a barrel and a goblin, utilizing a base class doesn't make sense bc an enemy and barrel have nothing in common . . .
is there a way I can make some kind of property that iterates trough multiple value types?
@hard sparrow instead, you can implement an IDamageable interface that both, the barrel and Enemy class can implement with a ApplyDamage(float value) method . . .
you should explain what you are trying to achieve and why
https://xyproblem.info/
@polar marten dude uhh... I don't even know if I can call this a fix but I found the dumbest patch ever to my problem
it's actually ridiculous
in other words - wait a frame
as has been said
this isn't robust though
you're just waiting for the next frame . . .
because that might not be enough to cause a physics simulation to happen
public struct Layout
{
#region public fields
private Unit x, y, width, height;
public override string ToString()
{
}
#endregion
public Layout(string input, Align align)
{
}
public Align Alignment
{
}
#region properties
public string position
{
set
{
Unit[] xywh = new Unit[4];
List<string> splitStrings = StringMath.SplitString(value, ",");
for(int i = 0; i < splitStrings.Count; i++)
{
(double, string) valueUnitPair = StringMath.InvalidStringToDouble(splitStrings[i]);
xywh[i].Value = (float)valueUnitPair.Item1;
xywh[i].Key = valueUnitPair.Item2;
}
}
get
{
return x.Value+x.Key+","+ y.Value+y.Key;
}
}
Yes so in the public string position field I'm to set the variables x,y,width,height the array represents x,y,width,height variables and I would like to itterate over those 4 while still keeping their naming for convenience
@thick socket didn't someone mention using a coroutine for this (to spread across multiple frames)?
I see
though dude
don't get me wrong
I listened to your advice, I just can't apply it
I don't think so, but I think I found some stuff related to that during my immense hours of search
so what I need to do is wait a frame, but how do I do that robustly, as you guys say?
I am sorry, I am just terrible at programming
coroutines is it?
nono, as I have it right now, it is working
it's just not the right way and apparently it might not work every time
let me check if I can get the coroutines going
Yeah someone did, I remember seeing a block of code with yield return null; at some point
Found it
yeah, I see that now
though I had no idea that was a coroutine or what it was
I tried using it but it didn't do anything
uh huh, so why are you parsing a string like this anyway? if you want to store the data as a string why not serialize it to json which won't require you to manually parse it? (also you cannot iterate over an object's fields without reflection)
I didn't know I needed a StartCoroutine(X()) to make it work
idk I just wrote it my own because I don t know json
yep, that works now...
that's how you use coroutines. this is the general intermediate channel; basic knowledge of c# and unity is expected . . .
i mean why is the data being assigned from a string in the first place? is this an attempt at serialization/deserialization? or do you have some other reason for creating it from a string
I did start by asking in the beginner channel a few times but it wasn't getting me far, and I was very desperate. Sorry about that
for convenience mainly
that doesn't answer the question at all
for this
let me introduce you to my friend the Vector2
I might add that later
well, I still think it is an odd fix but it is working. Thank you guys. And sorry that I had to come back so many times for this, it is finally over
okay well i'm not even going to try to help you with your harebrained scheme of whatever the fuck it is you're doing because it makes absolutely no sense to do that instead of use the already existing types and tools to do it much easier and in a much more performant way
I think what I was asking for is a refference array, which doesn t exist
I don't know if this is the right place to ask, But right now I am a bit of a conundrum.
I have a custom tilemap system which generates tiles itself that doesnt use unitys built-in tilemap system, however I'd like to have a compound tile that can collapse into different tiles, similar to rule tiles with built-in tilemaps. Can anyone point me into the right direction of how I can code this myself, since I have no idea where to begin with this, or if possible how I could use unitys tile rules without using unitys tilemap.
hey why is this wrong ?
int A = 24;
int B = 10;
float results = A / B;
// results = 2; .... not 2.4
theyre ints not floats/double
when you divide an int by another int it does integer math. cast one of the values to float and it will do floating point math
at least one of the numbers in the operation must be a float to return a float . . .
@shadow sonnet @somber nacelle @rain minnow Thank you ❤️
How much overhead is there when you parent 3-4 objects together per "character"? Is it advisable to do things that would save trouble in terms of programming via extra objects, or does it have a heavy performance cost?
no overhead, players will often have dozens of child objects
I see, good to know. Thanks.
is this a bad way of doing 2d movement? It feels like there's an input delay on my key presses
void FixedUpdate() {
// handle movement
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector2 movementVector = new Vector2(horizontal, vertical).normalized;
if (movementVector.magnitude == 0f) movementVector = Vector2.zero;
rb.AddForce(movementVector * rb.mass * acceleration);
}
Do you have acceleration set to a high amount? If not then it would be hard to tell.
yes it is, it goes from zero to top speed near-instantly
I don't see why there would be any delay unless it's affected by mass or acc. I'm using the same input system more or less for 3d, and it works without delay as far as I can tell.
you don't get input in FixedUpdate, always use Update . . .
thanks
get input in update, do movement calculation on fixedupdate
I'm trying to use A* pathfinding and when hitting "Scan" to create grid graph, nothing happens but the console logs that it was complete.
Anyone familiar able to lend a hand?
I have a script to move head when moving mouse... but when I transfert my game to android, when I use 2 fingers, it is doing that... how can I prevent it?
use input system and event system. you can use heuristics to determine which Pointer corresponds to the one for moving your player POV versus one that is interacting with UGUI elements
Jason weimann has a video on update vs FixedUpdate that'll explain how to do this properly
that is not my problem... my problem is when i click to move or anything else and i move my head, it doesnt turn like what i want
for example, in your OnPointerEnter handler for your virtual joystick, cast PointerEventData to ExtendedPointerEventData and add the pointer to a set. you can dynamically enable/disable a input system action for each pointer that isn't that pointer; or, you can listen to your UI/Delta (or similar) action and ignore, in code, events from pointers currently being used by UGUI.
There is an overhead to deep transform hierarchies, but it's not going to be noticeable with 3-4 children:
https://blog.unity.com/technology/best-practices-from-the-spotlight-team-optimizing-the-hierarchy
okay based on the video you are showing me, it looks like when there is multitouch, the delta being used to rotate the head is based on the midpoint of the touches
this would be the case if you are using Input.mousePosition to compute a delta or Input.GetAxis(...) to query unity for a delta directly and you are emulating mouse using touches
which obviously isn't going to work for you because a mobile device is multitouch
Thanks, I'll take a look.
but the real problem, it's that when the multitouch activate, it cound like i mouved ans this is what i dont want, multitouch isnt the problem, juste the movement when actived
so i don't know what to tell you, you can reinvent Input System using Input and try to fix this issue
i described the problem
you can ask questions about the solution, that might help you understand it
or you can try to tell me i don't know what the problem is
there's no easy fix
if you want to use the camera movement and eventsystem together (i.e., the Button scripts on your movement UI elements), you will need to specify which touch moves the camera. this is a lot harder to do with Input than it is with Input System
when I touch with 1 finger, no problem happen... when I put 2 or more, it takes the middle point of them... but when it is putting the middle point, it is counting this as moving. and I dont want this...
it's not that much harder*, but it would require extending StandaloneInputModule and doing something pretty arcane
you will need to fix this problem the way i described
Input.GetAxis uses the midpoint of every touch to compute a delta when you are emulating mouse using touches (https://docs.unity3d.com/ScriptReference/Input-simulateMouseWithTouches.html). when you are not emulating mouse using touches, Input.GetAxis doesn't work.
as soon as you try to use Input.touches, you will not know whether one of the two touches is being used by UGUI or not. you will have to determine that heuristically, for example by using screen regions; or, in Input, you can query the pointerId for a pointer event data using protected methods in the StandaloneInputModule (so you'll have to subclass it); or, you can use Input System and query directly
also, as soon as you use Input.touches, you'll have to make the code make sense for the editor
there can be surprising misbehaviors here. for example, the mouse is always moving in the editor, but not pressing.
@arctic lintel does this make sense?
in any case, you can't use Input.GetAxis
🫡
you will not know whether one of the two touches is being used by UGUI or not. you will have to determine that heuristically, for example by using screen regions
this is probably the most useful approach for you
@arctic lintel another approach is to exclusively use event system. for example, place a 0-alpha Image behind your controls (i.e., an object that can receive graphics raycasts, but doens't do anything visually), and add a script with IBeginDragHandler and IDragHandler interfaces onto it.
this image should cover the whole screen. whenever you touch and drag on this image, you'll receive calls to OnDrag(PointerEventData pde)
and that pde object has a delta property which you can use instead of Input.GetAxis
that PointerEventData object will correspond to a distinct pointer (i.e. touch) and it will Just Work
i see that i made your brain explode and you yeeted out of here in frustration. this is okay. you are on an early part of your mobile game development journey.
just a quick question:
how should i go about making plant vines? i basically want to have the player be able to sprinkle seeds that can be grown out into infinitely long vines, i want them to squirm about and brush up against walls they collide with, with each step bieng a different vine
i can set up a simulation, but im mainly wondering how i should go about making this visually
Hey, is it possible to trigger onEnable to run again inside the same script?
Like i have a script that does some initialization stuff, and i want a condition in my Update() method that basically triggers the script to disable and enable again.
i was thinking of doing like this.disable and in the onDisable function just do this.enable. Will this cause issues?
this is procedual generation of assets, on mesh?
void OnEnabled(){
Method();
}
void Method(){
// your stuff
}```
mehh, sorta
this lets you manually call the same method whenever you want
id describe it as closer to bieng procedural generation of mesh, but im wondering if making a procedural mesh is even the way to go
high end modeling software can use python scripting to achieve this
dunno in unity tho
i could probably do it as a baked operation, since i dont really need the vines to curve around things like players or enemies, because they grow incredibly slow
but i also intend for the player to be able to cut the vines..
perhaps i could place gameobjects that have meshes of different vine segments in a way to achieve the effect?
Thanks
but im mainly wondering how i should go about making this visually
there are lots of splines libraries that might be helpful. you can also use SpeedTree.
i was thinking about splines actually, ill look into them some more
there's also really cool stuff you can do with vfx graph if you want to stay totally on GPU
and want like, lots of vines all animating
To a degree. Why not use plain class/SO instead of a component?
To me, just being honest, it looks like it is greatly over complicating wanting to track a list of statuses.
Keeping in mind, I don't know what a status is in this context, or why it needs a private setter, or why you would want the status and the reference out of sync
So it might be a solution to a problem that I'm not knowing, and I hesitate to provide much advice on it
I thought I needed to instantiate it because I wanted statuses to be able to remove themselves and decrement their own durations and such
Why can't you do the same with plain classes or SOs?
I guess I'm supposed to make StatusEffect an SO and have the UIC track duration and handle removing and such?
You could have a plain class StausEffect that holds the status effect SO and the runtime state of the current effect, like duration and such. Then you can update a list of effects from your script(not sure what UIC is).
If you want a clean solution you can use an SO with serialised reference for the behaviour, then use one of the unity plugins that gives you a dropdown for the serialised reference
There are a few, including Odin
There are two on open upm two, I've tried them both and they're both good
So a single status effect SO, but you can select its functionality from a dropdown instead of using inheritance
Works a treat
I do mine using graphs because we have very complicated status effects, but that's a huge can of worms
I made an infinite breaking bad episode generator in python that spits out mp3 text to speech audio for each character in order
Awesome.
after the mp3s are generated, how do I access them in c# and play them in order?
I thought about making them one big mp3 but then it would be way harder to get information on which character is talking at what time
right now they're formatted like "(index) - (character name)"
Lol I just googled it
Never tried before
I'd def go with the individual files though
I'll see if I can figure it out
That way you can keep them generating in the background and loading them on the fly
yeah I really didn't want to export labeled timestamps or something
right now it generates them in batches
I assume this is something like that amazing Seinfeld show?
yeah almost exactly like it except I built a chatGPT webscraper and ask it to continue from the previous prompt
it's hilarious, it goes off the rails after 5-6 iterations
I'd consider exporting a script file that includes text and filename
I also coded in random chance "mood affectors"
And then have the unity program step through it line by line
Loading the file and playing it with the subtitle
my idea was to have like a init.json file that says which characters should be loaded in the scene and other important info
Waiting for the audio to finish is easy enough, the entire program could be a giant coroutine
right now it generates one script ahead and shifts everything from newScript() to script()
I'd go all in on coroutines. Just a big while(true) loop that loads the script, plays it out, loads the next script and so on
that's pretty much what the python script is haha
I did this for an interactive narrative game
since the webscraper holds the tab open it has to be a giant while loop
You can call out to the python program to ask for the next script
so it waits for the c# script to tell it to generate a new script and make the audio and stuff
Yeah perfect
yeah exactly
hopefully it shouldn't be hard to control with c# now that the python stuff is done
Can you DM me when you've got something to show? I'm very interested in this XD
oh I can show you some of the example scripts it makes
Yes plz! DMs are open
how does someone get the back buttno input on the phone [with and without the new input system]
On the old one, it's the esc key
even for ios?
i used "input.backbuttonleavesapp = true" that should work (haven't tested it yet) but what about ios.. that's my concern
iOS devices don't have a back button
You only have the swipe back action when you swipe from the left on iOS
Hey yall, my mind is stuck.
How do I create a new 'type' in c#.
I mean like: myColors that can only take red and blue using a dropdown
I remember using something like a struct
enum?
Jesus, yes
thank you
Sadly you cannot use a method that has an enum as a parameter as a clickEvent :/
Because events have a set amount of parameters, and the only way to omit that is to use no parameters
You can translate whatever the event brings to your enum?
ye ye I just was experimenting
What exactly do you mean?
Oh you mean like in the inspector having the dropdown?
Inside the onclick event
You could write your own class that you can use to set in the inspector and just onClick.AddListener in your script to hook into the button
That's true, nice idea. The reason is to avoid a switch case mistake using the strings etc. That approach seems nice
Optionally to increase scalability: Write a scriptableobject that you attach to the button, defining the information it contains.
In your case it would just be an enum, but your onclick script can now get the info from the scriptable object, and it makes it easier to adjust its values instead of making multiple methods.
It would just be a class on the gameobject with a button, on that you already can set your enum. But SO can be an alternative depending on the complexity
What property of the camera should I change in order to zoom in? (Z axis is not working on a 2d game)
It should be the projection size
Assuming the camera is ortographic, change the orthographicSize field.
[SerializeField]
float zoomFactor = 1.0f;
[SerializeField]
float zoomSpeed = 5.0f;
private float originalSize = 0f;
private Camera thisCamera;
// Use this for initialization
void Start()
{
thisCamera = GetComponent<Camera>();
originalSize = thisCamera.orthographicSize;
}
// Update is called once per frame
void Update()
{
float targetSize = originalSize * zoomFactor;
if (targetSize != thisCamera.orthographicSize)
{
thisCamera.orthographicSize = Mathf.Lerp(thisCamera.orthographicSize,
targetSize, Time.deltaTime * zoomSpeed);
}
}
void SetZoom(float zoomFactor)
{
this.zoomFactor = zoomFactor;
}
Maybe adjust the if statement since comparisons with floats should not be done like that btw
Thank you
How can I force remove a component and it's dependencies? I.E CompB has RequireComponent(CompA). If I call Destroy on CompA it won't do anything, pointing out CompB is dependent on it. But if I call Destroy on B, A will remain.
Add the same to CompA?
Or add custom behaviour to an onDestroy method
Can't really prevent it without RequireComponent but you can log a message and maybe add it back in an onDestroy method
I think you're misunderstanding. I want to remove the component CompA, but I can't since CompB has dependency on it. afaik I can't from code figure out (maybe through reflection) which components I would have to remove first before I can remove A
how do you work with untity's camera functions like
WorldToScreenSpace, ScreenToWorld, ScreenToViewPort
I'm trying to add buttons to my own ui tool, therefore I need to
1.st project the mouseposition to my ui, I'm using an ortographic camera for this
2.nd project the mouseposition onto my workspace, which is using a camera with perspective
I think the first one will work something like
public Vector3 MousePosToOrtographic(Vector3 mousePos,Camera camera )
{
Vector3 point = camera.ScreenToWorld(mousePos);
return point;
}
public Vector3 MousePosToWorld(Vector3 mousePos, Camera camera)
{
Vector3 position = camera.GetComponent<Transform>();
Vector3 point = camera.ScreenToWorldPoint(//idk what to put here);
}
//would be great if someone could help me
I am trying to create an endless line drawing game, am using Linerenderer with edge collider2d on it, as it is an endless game will the the increased number of points in the line renderer and edge collider2d affect the performance of the game
Then remove RequireComponent...?
Unless this code is from a third party. But I assume they added it with a reason.
That would just break the purpose of RequireComponent? I want the attribute to ensure prefabs are correctly set up
If you want to ensure the component exists, do it in an onValidate method instead of using the attribute?
But these also run every validation cycle, so you will still have the issue
So you should ask yourself when you need it. Perhaps do it in a Start method if you want it to appear during runtime?
Either way, my point is custom behaviour is probably better than RequireComponent in your case, so that you can define how it should work.
Adjusted my messages since I was thinking out loud 🙃
Yeah I noticed 🙂 Can't really work around that though, so I think I just have to do the full reflection lookup and delete each component in order.
Anyway thanks for your help 😄
Only post your question in one channel.
you can definitely achieve the idea you have by doing that, but it really does sound like a bit of a mess doing it that way and horribly inefficient - just how fluid is the use-case that you need to be adding and removing these components to begin with?
It's in editor time, so performance is kinda irrelevant 🙂 Can't tell to much since NDA but the base idea is that I can define a meta-template for a type of prefab. Then I can create instances of that prefab using the template, now if someone modifies the template I have a function that updates the instances, either by adding or removing new/old components.
First plan was to use Prefab and Variants, but they come with their own slew of UX issues, and creates a hierarchy which is unflexible at times
Yeah, onValidate sounds best I think. just make sure you're in editor more somehow, because this also runs in play mode (I think??)
The only problem is figuring out how you can only add components on the first run, and not when you remove them
Honestly scrapping usage of RequireComponent is a good valid approach here. Since if the template is used anyway, it's sort of doing the same thing
Sorry my bad
Is the gravity calculated with refresh rate in mind? Because it feels like when the fps is lower the objects fall slower.
gravity should be based on the FixedUpdate loop. which means it's based on time, not framerate
okay, so basically to account for slower computers I should simulate the gravity myself?
in 2d it shouldnt be hard, but maybe there is an option
slower computers..? i dont think so. it's not device based
it's based on the time step that's set in the project
oh, my bad misunderstood
I unplugged my laptop and put it in power saver mode
now the gravity feels like reduced
but honestly, this is just my assumption.. Gravity is a physics thing, and physics stuff is done in parallel with FixedUpdate
thats odd. sorry I can't be more sure
No worries, i'll try plugging my laptop back in at home and testing it out.
It's more likely an optical illusion. Things moving in lower framerate look slower even if they really move at the same speed. Measure, and if there's really a difference it's more likely that there's code that interferes
Im developing a plugin for unity but it seems I cannot access the Vector2 struct because its in UnityEngine.CoreModule
hi. i have this
private void Tree()
{
foreach (Transform tree in Trees)
{
float dist = Vector2.Distance(tree.position, CollectionPoint.transform.position);
if (dist < nearestDistance)
{
nearestTreeDistance = dist;
nearestTree = tree.gameObject;
}
}
}
i have filled the array with my transforms. but it keeps giving back the wrong tree(gameobject/transform) and with wrong i mean not the closest one. how how do fix it?
nearestDistance and nearestTreeDistance are two different variables
what are those errors, this is the first time im seeing them (only when building the project)
Tried changing parameter name from i?
My wild guess would be that when built the macros/methods are optimized to be inlined and creating clashing variable names 🤷
no, i didint change anything in that shader code
i would but then it'll build another 2h :/
bump
The code you provided is missing some important context, so it's difficult to say exactly what the issue is without more information. However, it appears that you are trying to find the closest Transform in the Trees array to the **CollectionPoint **Transform.
Based on the code you've provided, it looks like the issue may be with the **nearestDistance **variable. It appears that you are using **nearestDistance **in the comparison in the if statement, but that variable is not declared or assigned anywhere in the code you've provided. Instead, you should be using **nearestTreeDistance **in the comparison, like this:
Try This Code
`private void Tree()
{
float nearestTreeDistance = float.MaxValue;
GameObject nearestTree = null;
foreach (Transform tree in Trees)
{
float dist = Vector2.Distance(tree.position, CollectionPoint.transform.position);
if (dist < nearestTreeDistance)
{
nearestTreeDistance = dist;
nearestTree = tree.gameObject;
}
}
}`
This code should initialize the **nearestTreeDistance **variable to a very large value (in this case, float.MaxValue), and then use that value in the comparison in the if statement. If the distance between a given tree Transform and the **CollectionPoint **Transform is less than nearestTreeDistance, then **nearestTreeDistance **will be updated with the new, smaller distance, and the **nearestTree **variable will be updated with the corresponding tree Transform.
This should help ensure that the closest tree Transform is correctly identified and returned by the Tree method.
iknow its got solved but for more info if you want to understand
If you want to have your mouse position in UI, it should already work, because screenspace is in pixels and your mouse pos is too. For the other, if you want to have a screenposition in world space, you have to use ScreenToWorld as you said but keep in mind, that you have to set your z value manually because otherwise, your worldspace z would be 0 and the worldposition would just be at your cameras position
Yeah so I will have to add the camera posiiton into the equasion
Oh wait, wrong channel 😄
I have some issues with setting UI to mouse position.
I have a Loading Scene where there is my canvas in screenspace camera with a dont destroy on load and singleton instance so I can use it in my other scenes
Some objects have a script to show a tooltip in this canvas and set its position to Mouse.current.position.ReadValue() (using InputSystem)
My issue is that the same code is called on different scenes but the position set is different (one is correct, the other is setting position to 40000+)
(canvas' camera is set on scene loaded with the same parameters on the camera on the 2 scenes)
Well you would just do Camera.main.ScreenPointToWorld(Input.mousePosition + yourZvector);
Also, setting my tooltip position works weird :
public void KeepFullyOnScreen()
{
string log = "";
Vector3 position = Mouse.current.position.ReadValue();
log += $"{position}";
movable.position = position;
//More code after.......
}
this logs something like (480, 10) but sets the position in inspector to (965, 6) as if there was some scale applied somewhere
yep, it is taking the nreaplane value I think of the camera, or whatever its called in your renderpipeline
At least one assumption
hmm well the cameras on both scenes have the same params for clipping planes, so it should be the same I assume
I see nothing related in my URP settings so I think it should use the camera's
Is movable a UI object? Or 3D object
2D UI
Why do you cast the position to a 3D vector then?
yes this cast is not needed (does not fix anything though)
and why do you set the position of your movable instead of the anchoredPosition as supposed to in UI? is movable a recttransform?
yes it is a recttransform, I am not familiar with the anchoredPosition, will try
anchoredPosition is the pixel pos on UI elements dependant on their anchor and the parent recttransform in 2D. position is the inheritance of transform and is not in pixel space but in 3d world space
OK! This works way better, it adds some offset now, so I guess it needs to be changed to another referencial (world, screen)
this explains a lot of bad behaviour I have seen 👀
yeah the parenting and anchoring is something you gotta look into carefully, maybe check some tutorial on it, because I still get confused sometimes what does what 😄
Oh and the offset could exactly be your anchors OR your pivot being on a place you dont want it to, like in a corner but you want your object to be centered. In this case pivot would need to be 0.5 0.5, and so on, lot to experience in UI 🙂
more than an offset it is more of a ratio applied
I think my anchor point is correct the problem is more getting this position from screensize to canvas size I think, like a Camera.WorldToScreen of sorts
how do you currently get the position?
Mouse.current.position.ReadValue();
And then how do you set your object right now?
which returns from 0,0 (bottom left) to Game window max size (top right)
just apply flat to anchoredPosition
and what does your parent object look like, inspector wise in its recttransofmr values?
I think I could get Screen.width & height and apply mathemagics to scale it to the canvas' 1920/1080 but isn't there a Unity function to do just that?
you want it to be always on the propirtions of 1920?
my canvas is in scale with screen size based on a 1080p reference so the values should always be calculated on this base right?
Yep, no need to do something codewise
movable.anchoredPosition = new Vector2(position.x * (1920f / Screen.width), position.y * (1080f / Screen.height));
This applies the correct scale
Thank you for your hep, I have been on this problem for way too long
still weird, its taking this into account for you
Yes, I think it did not until I used the anchored position
But looks like its the way people handle it on the web. So you might just have a static vector for your mouseposition that you can access from anywhere that already takes that calculation into account, so you dont have to copy paste that code everywhere
Oh, here is a neat thing you can use to not fiddle around with that long calculation I think: https://docs.unity3d.com/ScriptReference/Canvas-scaleFactor.html
Hello guys got a problem and nowhere i cant find solution ....... im accesing animator parameters via scrypt 1 of 4 parameters work the rest 3 is showing error the Parameters not found...... i checked spelling , calling it same as the first param which is working , i tried recreate animator restart unity and many other things nothing work , can anybody have idea??? thank you
if the error is saying the parameter is not found, then it's not there. Maybe show what you have?
There is whole script and screen that these parameters are there
make sure you don't have any extra spaces or other invisible characters in the names
i checked it and there is no extra spaces , only the isMoving bool working as it should the rest dont
I see you're looking at a prefab, with some overrides
probably your actual object is using a different animator controller
The handleAnimations method doesn't actually set the field values. It creates local variables and then discards them.
Hi everyone, I'm about to go crazy now. I am trying to develop a UI system. But no matter what I do I can't make the Pause Menu. Let me explain it this way. I assigned a task to the "Escape" key in both scripts. One of these managers is Game Manager and is responsible for bringing the Pause Menu when the "ESC" button is pressed during the game. Another manager is UIManager and this manager allows the player to return to the previous UI window sequentially when the "ESC" key is pressed. (I used the Stack structure to sort the classes I named View in UIManager and implement FILO (First In Last Out). This way I can bring up the previous UI window.)
The first problem when I started building this system was that the UIManager was running after the GameManager, causing the menu to close before it even opened. I solved this somehow, I don't face such a problem anymore. But now it's reversed. Since GameManager is running after UIManager, the pause menu opens right after closing.
I could not establish the logic of this system. Please help me.
the handle animation i have just for store the IDs from hash to string then these ID im using somewhere else whats wrong there?
The thing that I just said is what's wrong
you're not storing the IDs, you're creating new variables
remove the ints from inside the method
if that was the case then moving animation wouldnt work as well , but i checked it and my actuall character using this same animator
oh ** me 😄 thanks a lot now its working ....... well programer blindness 😄 such a beginer mistake 😄
Hey guys, I've kinda ran into a stump here and request guidance from the wisemen of coders.
Currently I'm trying to create a system in my game where a cube with a battery script detects all generators loaded into the game to manage some charge functions. Currently I'm running into an issue where one script doesn't seem to be able to access the other. It's probably very trivial what I'm missing here, but I'm really confused on how to handle this.
This is the issue; My scripts don't seem to be able to access each other.. I'm getting two errors which are fairly the same:
"Assets\Scripts\BatteryScript.cs(34,35): error CS0122: 'GeneratorInteraction.isActive' is inaccessible due to its protection level"
and
"Assets\Scripts\BatteryScript.cs(39,35): error CS0122: 'GeneratorInteraction.isRegressing' is inaccessible due to its protection level"
what would be a good way for my battery script to detect generators loaded into a scene with the interaction script? I've been scratching my head for a minute thinking about this but I cant seem to figure it out. Also I've tried namespacing but im VERY bad at it.
I think this message just says the isActive and isRegressing are private fields, either make them public or create accessor functions
What are accessor functions? I'm intrigued.
basically a public function that only returns a private field, the goal is to be able to read data from outside but not allow write
public float GetLength()
{
return length;
}
from the outside you can call this function to get the variable length, but you cannot modify it
Okay, thanks much I'll try it out
properties are a way to do it
one more question guys is there any way to compare on which frame is animation currently?
Depends on what you want to do.
If you want something to happen on a specific frame, you can use animation events
If you want to know the progress of an animation you can use AnimationState.normalizedTime : myAnim.GetCurrentAnimatorStateInfo(0).normalizedTime
Which returns the progress state between 0 and 1
thank you a lot 🙂 i want to use jump on specific frame reach , because now character jumps and then animation plays in air
Does the rigidBody component calculate the position over time like this objectPosition += rigidBody.velocity * 0.02f (the 0.02f being the deltaTime of FixedUpdate)?
YOu can just use Time.fixedDeltaTime in place of 0.02
and yes more or less
not accounting for collisions etc
I'm trying to calculate the future position of rigidBodies (planets, afected by gravity only) (gravity between the planets) and it doesn't seem to follow that path
it follows that path, I've done trajectory paths before
that's how I made this:
https://www.youtube.com/watch?v=0xasKAsCHio
I added a throwing mechanic to my untitled drone puzzle Unity game. This makes it a little easier for the player to insert objects such as power plugs and batteries into their slots from a distance, without having to awkwardly fly every object around.
In order to get an accurate throw path I had to do a discrete integration over time of the obj...
Hi i'm new to unity and i'm trying to have people enter multiple names into a different inputfield and trying to use it in another scene. I looked a lot of video's of it but I didn't find any help for it sadly..
you can also you Time.deltaTime, it gives correct deltatime if in fixed update
sure but why include that ambiguity when we're just talking about how it works
I also like to be explicit about it, especially since trajectory calculation code is often not done in FixedUpdate
you're right
I'm having a lot of trouble knowing when it's appropriate to separate logic from UI, and when it isn't
almost always
if you are changing scenes between input and usage, you should store this data in either a scriptableObject, a file on disk, playerPrefs, online etc
So in FixedUpdate() I have bodyVelocity += gravityImpulse
Like right now I have a StatusEffectUX class which is responsible for both applying statuses to units, and for creating ui controllers for the display of those statuses. Is this already too mingled?
generally should also be:
bodyVelocity += Time.fixedDeltaTime * gravity;```
assuming your gravity is expressed in the normal units of m/s^2
Yes
Also if you're doing a planetary gravity thing, that gravity value will change every simulation frame according to distance
(universal law of gravity)
I calculated the gravity using newton's formula, then multiplying that by the diference of position between the bodies normalized. the result of that being gravity in that message
in that case you may need to also incorporate the object's mass
I do
I have the script on the two planets, the script giving an "impulse" towards the other gameobjects with the tag planet
and since I'm using newtons formula, it emplies I am using the mass of the two objects
I'm setting the mass of the planet in the rigid body component, and getting that for the math
yep, got that part, but the mass would also need to be included in the velocity change calculation, right?
f = ma since the newton formula is going to give you a force amount in newtons, not an acceleration amount directly
i.e. this part: bodyVelocity += gravityImpulse
so the impulse * the mass then added to the velocity?
We'll that doesn't work
The mass of the planet/s is about 80000kg
wait but acceleration isn't velocity
velocity is a vector over time, acceleration is a vector over time^2
velocity is a vector over time too 😛
I corrected it
to be precise, it's a change in position over time squared
same for velocity without squared
Yeah
so then we need to remove one of the time values from the acceleration to then add the velocity to the rigid body
add force
wow
If I have two floats:
float 1 = 0
float 2 = 1000
How can I plot out a certain amount points along these two floats that are a certain distance apart?
Let's say I want four points...
I don't want to just have 1 point at 200, another point at 400, another at 600 etc.
Point one might be at 160, point two might be at 400 etc.
Lerp
I could use a rigid body variable (private RigidBody2D body = new RigidBody2D;) to transform a force into a velocity by adding a force * deltaTime then getting it's velocity
I'm trying to edit a save game file that starts with " ÿÿÿÿ FAssembly-CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
how would i turn this file into something easily readable and modifiable? the game its from has unity as its game engine
you'd have to actually describe the rules of the points you want?
because you're just kinda stating random numbers here
for evenly spaced points you can just do something like:
float min = 0;
float max = 1000;
for (int i = 0; i < numberOfPoints; i++) {
float val = Mathf.Lerp(min, max, (float)i / (float)numberOfPoints);
print($"Point {i} is {val}");
}```
damn
Okay, well lets say evenly divide the total number by the amount of points that I want, and then shift those points around a little, but not so much that they are overlapping or passing each other
yall dont know?
Been 2 minutes my dude
There are already existing save file editors. But it's impossible to say because the game developer could have used any save file format imaginable, and telling us the first line of the file does absolutely nothing to tell use the save file format
how to fix and give me the script
Oh, discussing modding/cracked games isnt allowed on this server
looks like you're missing a {, but impossible to really say without seeing the code.
If thats what this is
probably just trying to edit the save file to cheat
nah nah of course not
I don't say this in a bad way. I don't think there's anything wrong with cheating in single player games
understand how to fix it?
you only stand to ruin your own fun, nobody else's
read what I wrote
but impossible to really say without seeing the code.
this is the file but the name has random numbers and without .txt
if this gives u an idea of what format was used lmk 🙏
you think we're going to reverse engineer someone's binary save file format for you here?
tedious at best
dang thats sad
Good chance it's BinaryFormatter.
I have this code to calculate the gravity between two objects (planets)
for(int i = 0; i < rigidbodies.Length; i++)
{
if(rigidbodies[i] != thisBody)
{
Vector2 delta = rigidbodies[i].transform.position - thisBody.transform.position;
Vector2 direction = delta.normalized;
float distance = delta.magnitude;
float force = Gconstant * ((rigidbodies[i].mass * thisBody.mass) / (distance * distance));
Vector2 impulse = direction * force;
thisBody.AddForce(impulse * Time.fixedDeltaTime);
}
}
and this code to calculate the trajectory (using a for with the trajectory length to draw the line)
for(int i = 1; i <= trajectoryLength; i++)
{
for(int o = 0; o < rigidbodies.Length; o++)
{
if (rigidbodies[o] != thisBody)
{
thisMass = thisBody.mass;
thatMass = rigidbodies[o].mass;
Vector2 fakeDelta = rigidbodies[o].transform.position - thisBody.transform.position;
Vector2 fakeDirection = fakeDelta.normalized;
float fakeDistance = fakeDelta.magnitude;
float fakeForce = Gconstant * (rigidbodies[o].mass * thisMass / (fakeDistance * fakeDistance));
Vector2 fakeImpulse = fakeDirection * fakeForce;
fakeVelocity = fakeVelocity / thisMass * Time.fixedDeltaTime;
}
}
currentPointLocation += fakeVelocity * Time.fixedDeltaTime;
lineRenderer.SetPosition(i, new Vector3(currentPointLocation.x, currentPointLocation.y, 0));
}
However, I have to set the initial speed to be in the millions in order to start seeing the line because of how close the points are one to another. I assume that is because the mass of the planet is ~80000kg.
You might scale your object down datawise maybe to have handleable values?
(there are unused variables, I added them to be able to calculate the gravity with the other body moving, right now it's assuming all other bodies are stationary)
in what way
Working with values of millions and 80k kg in rigidbody might just make it way more complicated to handle values later on. You could just divid the whole thing by thousand for example to have readable values.
Well I don't want the initial speed to be in the millions, what's why I asked
And I want to keep at least some realism in the game, since if the density of a planet would be set to 500kg/m^3 (density of the earth / 10), normal water would be 100kg/m^3
Yeah, thats why I said, you are right with your values you need to move a 80ton object. But for you to make it easier to read and calculate, lower everythign by thousand so your force does not have to be in millions.
Yeah, but you can still scale down kg as well as m3
Thats just a suggestion for you to make it easier to write and read. The physics behind it will still need your force to be the nth multiplier of the mass
Thank you so much!! I really appreciate that you took the time out to explain that to me. I have been living in the mindset that lerp is used for gradual movement and did not think to use it in this way.

you use lerp when you want a linearly interpolated number between two numbers
Hi everyone,
how can I force the build executable to open on the main monitor?
It always opens on the wrong screen.
I tried this code and it didn't make any difference.
private void Start()
{
int primaryDisplayIndex = 0;
Display.displays[primaryDisplayIndex].Activate();
}
Hey guys, i've been struggling with this for a few days now
text won't change it'll log to the console but the text on screen won't change
Please show us your code.
So sorry about that
private IEnumerator RegisterAsync(string name, string email, string password, string confirmPassword)
{
if (name == "")
{
Debug.LogError("Username is empty!");
}
else if (email == "")
{
Debug.LogError("Email field is empty!");
}
else if (passwordRegisterField.text != confirmPasswordRegisterField.text)
{
Debug.LogError("Password does not match!");
}
else
{
var registerTask = auth.CreateUserWithEmailAndPasswordAsync(email, password);
yield return new WaitUntil(() => registerTask.IsCompleted);
if (registerTask.Exception != null)
{
Debug.LogError(registerTask.Exception);
FirebaseException firebaseException = registerTask.Exception.GetBaseException() as FirebaseException;
AuthError authError = (AuthError)firebaseException.ErrorCode;
string failedMessage = "Registration failed, ";
switch (authError)
{
case AuthError.InvalidEmail:
failedMessage += "email is invalid!";
break;
case AuthError.WrongPassword:
failedMessage += "wrong Password!";
break;
case AuthError.MissingEmail:
failedMessage += "email is missing!";
break;
case AuthError.MissingPassword:
failedMessage += "password is missing!";
break;
default:
failedMessage = "registration failed!";
break;
}
Debug.Log(failedMessage);
warningLoginText.text = failedMessage;
}
{```
public class FirebaseAuthManager : MonoBehaviour
{
// Firebase variable
[Header("Firebase")]
public DependencyStatus dependencyStatus;
public FirebaseAuth auth;
public FirebaseUser user;
// Login Variables
[Space]
[Header("Login")]
public TMP_InputField userLoginField;
public TMP_InputField passwordLoginField;
// Registration Variables
[Space]
[Header("Registration")]
public TMP_InputField nameRegisterField;
public TMP_InputField emailRegisterField;
public TMP_InputField passwordRegisterField;
public TMP_InputField confirmPasswordRegisterField;
public TMP_Text warningLoginText;```
Oh firebase does that stuff on a separate thread so if you try to use it to set stuff that runs on main thread only like Unity UI, it won't work
You need to use a firebase extension called ContinueWithOnMainThread iirc
how do i add that extension
Add the namespace
I don't remember exactly what it's called sorry
how much easier would it be if i just switched over to playfab?
Hard to say but I prefer playfab over firebase personally so imo it'd be worth it
Hi guys, I have list as see in the image which has Buttons in it instantiating at runtime.
I want to make these button pop in (scale up one after the other) as they spawn in a sequence.
I have tried using animation clips but they all run at the same time voz well,
I would like to know how can i achieve the sequence pop in effect
how long would it take to learn to program in c#
i already have a some experience with lua
how do you render a RenderTexture created in runtime with URP?
That depends on you and your effort. Also #💻┃code-beginner material . . .
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody2D rb;
public float playerSpeed = 5f;
public float dashSpeed = 10f;
public float dashDuration = 0.5f;
private float inputX;
private float inputY;
private bool isDashing;
private float dashTimer;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
inputX = Input.GetAxisRaw("Horizontal");
inputY = Input.GetAxisRaw("Vertical");
if (Input.GetKeyDown(KeyCode.LeftShift) && !isDashing) {
isDashing= true;
dashTimer = dashDuration;
}
}
private void FixedUpdate()
{
Vector2 input = new Vector2(inputX, inputY).normalized;
rb.velocity = input * playerSpeed;
if (isDashing)
{
rb.velocity = dashSpeed * input * dashSpeed;
dashTimer -= Time.fixedDeltaTime;
if (dashTimer <= 0)
{
isDashing = false;
}
}
else {
rb.velocity = input * playerSpeed;
}
}
// Powerups
public void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Ability"))
{
playerSpeed += 5f;
other.gameObject.SetActive(false);
}
}
}
why does the dash speed not change even when i change the value
it gives me the same dash speed
is there anyway i can get it to work with firebase got a lot of work done i tried the continueWithOnMainThread and it's not working
where are you trying to edit the text? only in the last 'else'?
The error log seems to come from the first if. There the text on the screen is not changed
it says username is empty
according to your code it's not going to do any of the other stuff in that case
protected virtual IEnumerator ShootCoroutine()
{
// cooldown between multishots
while (true)
{
if(pauseShooting==false)
{
//multishots
firedShots = 0;
while (firedShots < attackStats.multiShot && !pauseShooting)
{
character.Animator.SetBool("Cast", true);
yield return new WaitForSeconds(0.05f);
}
character.Animator.SetBool("Cast", false);
}
yield return new WaitForSeconds(attackStats.attackSpeed);
}
}
is there a better way to code this since I have !pauseShooting twice
(I need the while loop to end if pauseshooting)
it's notoriously difficult to use "real" numbers like this, they are quite literally astronomical values - errors grow and things start to crack when the values are so many orders of magnitude
I'm not trying to make a 1:1 solar system, I want the game to act realistic
I mean, the answer is still the same I suppose - we're not using newtons equations here with algebraic results, we're using an iterative method and crazy values with large errors can and will break that
well ya that is part of the error but i want it displayed in the text box on the screen instead of the console
someone said something about continueWithOnMainThread because im using firebase
if someone can please help it's been 3 days
Hi!
I have a particle system that has texture sheet animation module enabled with mode=Sprites and the sprites array is populated.
I want to spawn particles using Emit function from code, and change which sprite will be used for that particular particles batch.
And now I face an issue, where I set textureSheetAnimation.startFrame (basically sprite array item index) and it changes all the previously spawned particles to the new sprite.
Is there any way around this? Something like spriteIndex (like the existing meshIndex) would be nice in the ParticleSystem.EmitParams, but uh...
The only way around this (that I can see) would be to play with the randomSeed, set the startFrame to 0-max, and then build a seed table (which seed gives which sprite index)... But that is just tedious, and probably won't give the same results for each platform.
(duplicated from #✨┃vfx-and-particles as it involves code actually)
For a top-down game, do I want dynamic rigid bodies or colliders? I see both in various tutorials but i also see some terrible code in them so idk
For the characters**
Hi all, is this the right place for this? If not, I'll delete the comment and take it to the correct channel:
When I create an assembly definition asset in the folder containing all my scripts, it appears to break all references to plugins installed via the package manager (could be more or less, but the list is long and I haven't checked every single broken reference). I think I could relink the packages individually as references, but according to the docs, it should have these definitions auto-linked: https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html#:~:text=the predefined assemblies.-,Default references,-By default%2C the
This is the flavour of error that I'm getting:
Assets\Scripts\PuppetTool\AprilTags\AprilTagRecorder.cs(3,19): error CS0234: The type or namespace name 'Recorder' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
Why isn't it working for me?
You need to link them individually, only engine stuff and DLLs are auto-linked
startFrame can be randomized, but can it be set individually per-emit (textureSheetAnimation.startFrame overrides all the previously spawned particles)?
that is unfortunate, there is really a lot of them. Is there a faster way then linking one at a time?
You are supposed to only reference the ones you need, in an IDE like rider they are referenced automatically when first used
Will VS 2022 autolink them? It doesn't appear to be.
this is a bunch of old code, so it isn't the first time i'm using them
so i just have to go through each one and add it I guess
managing such references is a normal/required process in all of software development
alright, thanks for your help!
using a cellular automata to create a random map that looks something like this. the map is represented as an int[x,y] with each position being a 0 or a 1, is there any way i could check for little pockets (like the one on the left hand wall)? they're messing with some of the post generation stuff that needs doing.
Hey, I am looking for a solution to determine if a user is moving in VR and when they stop. The problem is that the OVRCamera is your head so it registers movement if you nod your head as well as when you walk. I just want the walking and ignore the head nods and looking around.
I have tried velocity but if you nod your head fast enough you can trick it. I tried tracking my previous position and current position but the head nods register a change in position.
a naive approach that comes to mind is to flood fill, keeping track of each connected coordinate, and setting every coordinate you don't find to 0
i mean it's super janky but tbh
i think i might
it's already janky as
plus i can run it from the center of the map because it already ensures that the center tile isn't a wall
anyone know anything about firebase?
yeah - was about to say the harder part is dealing with edge cases where you might start in one of the smaller caves
@loud wing Don't cross-post and ask the actual question.
i've been for 3 days no one knows
i can't seem to have the debug.logs to print on the screen to show the user error messages
Also is it related to Unity?
on unity
Look at the API examples
yeah the way the generation works there can't be a pocket in the middle and it's garuanteed to be air, i'll have a look at flood filling cheers
this won't change that error is suppose to show where text is on the screen
i tried literally everything
I'm on step 5, following the scripted render pipeline example in the second section of the page below but the pipeline asset doesn't appear in the create menu.
https://docs.unity.cn/Manual/srp-creating-render-pipeline-asset-and-render-pipeline-instance.html
Is there something else I need to do that isn't mentioned?
someone said something with firebase it won't display on the main task or something
There are plenty Unity centric tutorials on it as well
Hey guys dont know if this is the right place to post this so apologies if it isn't. Im trying to make a first person player controller using the new input system. Now I got the WASD keys working fine, and I set up the Mouse delta in the InputAction panel. I can get the mouse delta but now I'm not sure what to do, I'm using cinemachine with the settings in the screenshot. I have removed the Input Axis names because I think I have to set it to the new Input system, but how ?
If this is the wrong way please tell me what the correct way to do first person player rotation is
thanks im looking into this would the way to go be create a script that implements that interface ?
so I can control the sensitivity etc
nvm I got it thank you
What's a good way to shorten SetEntitySpriteHorizontalVertical(Sprite sprite)? This method sets the sprite for a tile whenever it has north and south or west and east neighbors with the same tile
are you asking for a better name for the method?
yeah sorry, i just replaced it with SetEntitySprites instead
then take parameters for corner, horizontal, and vertical sprites
One more question, is it bad if I rely on the camera transform inside the player to make the player rotate ? Should I use the Vector2 MouseDelta from the input system instead? The reason I ask is because considering the camera has a certain speed etc and is using the input system I'm not sure how I would obtain the same results using mouse delta instead
I am lost and need some advice. You know those 3d hole games on mobile you move to suck items into the void?
I'm not sure how to make a hole where the cylinder is at and when it moves, regenerate the ground it previously made a hole at. Unless I'm going about this wrong?
I'd use a depth mask with your cylinder to make a hole: https://dinwy.github.io/everyday/2019/depthMaskUnity/
how would one go about making a level editor for a rhythm game osu-style?
- create a data model to represent the song
- make a system that can read that data model to "play" the song
- create an editor that can generate that data model
- make sure the data model is serializable so you can save it to files
- profit
makes sense lemme google how to make data models