#archived-code-general

1 messages ยท Page 369 of 1

jaunty sundial
#

How would you go about moving particles in a particle system after they have been emitted

#

without movinf the whole system

white ether
jaunty sundial
white ether
#

You might also want to consider whether or not using particles is the right choice here, depending on how much you will want to manipulate them

elder marsh
#

This worked well enough and i dont have to make two silly scripts for one functionality xD is nice

elfin tree
#

Is there a "clean" way if there's water everywhere at the bottom of my map to have an infinitely large respawn trigger at the bottom (where there water is), or should I just make a very large trigger and place it there?

knotty sun
leaden ice
glad dew
rigid island
#

I would also go with a trigger.
Y position can change if you have different heights terrain.

#

eg you can also slope a trigger angled, you can't slope positions easily. Ofc depends on your level/use case Y pos check should be sufficient

glad dew
rigid island
#

Yeah I mean that works but Imo a trigger is also easier to see clearly visually in the scene

#

there is no second guessing on numbers etc

glad dew
#

Also, the preference depends if you want this for an emergency catch all respawn for when a character falls through the world or if it's for intended obstacles with death pits etc that player might fall into during regular play.

rigid island
#

if its flat, number should be easy, if you have many variations in height, triggers are better

glad dew
rigid island
#

I know but now thats already more work than a trigger ๐Ÿ˜†

glad dew
#

Well, better be safe than sorry when it comes to falling through the world due to a hole in colliders somewhere thinksmart

rigid island
#

its not like the cartoons? if you fall into a hole you just end up on the otherside of the planet UnityChanLOL

lean sail
#

A component on each object that checks your position, which may need to change between scenes, is a lot more setup than a large trigger

glad dew
#

Not really, you only need to add like 2 lines to your player controller to check the current height and call respawn from there instead of checking if you collided with a respawn trigger from OnTriggerEnter.

lean sail
rigid island
glad dew
#

A simple component that contains just a public float KillFloorHeight. Ain't exactly computer science.

#

It's not "bad hardcoding" to want a plane that's always infinite as a catchall. What if something clips into the ground and gets yeeted far beyond the bounds of your trigger volume.

lean sail
lean sail
#

What if my players character gets launched into the sky so far it takes an hour to fall?

serene stag
rigid island
chilly surge
#

It's probably for use cases where you don't want the values to be immediately updated while you are still typing, eg when value changes it triggers some side effects that are undesirable to trigger on every key stroke.

lean sail
#

That does make the most sense, though even knowing about that attribute I'd probably implement that functionality myself

rigid island
#

yea kinda super niche surprised its there lol

open plover
#

I have a script that returns a Mesh based on (int sides). I'm repeatedly getting the same Mesh from the same sides. Should I just add a dictionary[int, Mesh] and not generate the same Mesh over and over, or would storing them be less convenient?

leaden ice
#

You will also need to manage cleaning up the cached meshes somehow

open plover
#

Nothing else

#

Each mesh would be reused probably like 20 times

leaden ice
open plover
#

Whats the difference?

leaden ice
# open plover Whats the difference?

Technically I believe when setting the mesh there is actually no difference. But when reading the mesh, if you use .mesh it will allocate and create a brand new mesh unique to this one object, with the expectation you plan to modify the mesh and don't want to affect other objects. .sharedMesh allows you to get the original mesh without creating a copy, with the understanding that other objects may be sharing the mesh so changing it may affect many objects.

gloomy path
#

I have no idea how to change my tilemap back to rectangular, I accidentally made a hexagonal one after and it changed all the others, I cant change it back with undoing (crtl Z) it...

#

so now its all jumbled...

leaden ice
#

change the cell layout to whatever you want

gloomy path
#

nevermind I fixed it, but I apreciate the help! turns out I was lucky enough that I used crtl + s right before the issue occurred!

spare dome
gloomy path
#

whats a vc? is it like a backup?

spare dome
#

Version Control

#

but yes

gloomy path
#

oh right, ive heard it before, ill take a look, I appreciate it

elfin tree
#

How come this setting works perfectly in editor but has no effect in WebGL?
Application.targetFrameRate = -1;

elfin tree
vagrant blade
#

I would assume not, if it's "always limited by ___"

elfin tree
#

Yeah.. too bad, good to know though, thanks for the link to the doc

wintry crescent
#

I created a class deriving from EventTrigger for some event overrides, but now I can't see any variables in that class in the inspector - is there a way to deal with this?

#

should I access OnPointerEnter etc. in a different way?

leaden ice
#

You can and should implement the interfaces yourself

#

IPointerEnterHandler for example

wintry crescent
open plover
#

So I'm trying to compare two colors by thinking each of the r,g,b values as x,y,z and comparing their distance in the 3d world space. The algorithm does generally good, but sometimes two distinct color's distance could be as small as green and light green. What extra check could I add to fix this?

leaden ice
#

i.e. you want those to be the same?

open plover
#

Neither

leaden ice
#

or do some more complex analysis on the whole HSV set

open plover
leaden ice
#

like "if it's within n hue value but also within m brightness" for example

open plover
open plover
leaden ice
#

So you want.. what? I'm still not clear on that

open plover
open plover
#

and the other way around, they could look pretty same and be distant from each other

#

so what I wanted was an extra check besides the original equation

leaden ice
#

just due to the way eyes work

#

I believe I helped someone solve this a long time ago but one thing you can do is adjust the sensitivity of your distance check based on how far the hue is from green

#

i.e. with a remap function

open plover
#

that makes sense

jaunty sundial
#
    {
        Vector3 mousePos = cam.ScreenToWorldPoint(Input.mousePosition);

        var emitParams = new ParticleSystem.EmitParams();
        emitParams.position = mousePos;

        cosmicDustTap.Emit(emitParams, 1);
    }```

for some reason this is making the emit position very high up on the y axis
#

and not on the mouse psotion as it shod be

somber nacelle
somber nacelle
#

then it's going to be at the same Z position as the camera, so either way it's going to be too close to the camera so the camera won't be able to render it

jaunty sundial
#

i dont think it would it shod just give the position of the mouse in world space

#

cause thats how it workedbefore

somber nacelle
#

you can think that isn't how it works all you want, but that is how it works

#

if no Z position is specified then it will be the camera's Z position. and naturally that is too close to the camera for it to render

jaunty sundial
#

well i can see the particles so they z position is fine

waxen spruce
#

I'm trying to use a lambda function to get the objects with the lowest rect.x, not the lowest rect.x float value. This is my attempt so far Room room = level.rooms.Min(r => r.rect.x); but its only giving a float

jaunty sundial
#

its just the y position thats off

somber nacelle
#

and have you considered that perhaps the particles you are seeing are the ones that have moved up and away from the starting position of the mouse's X and Y coordinates and the camera's Z coordinate?

jaunty sundial
#

no cause im only spawning 1 in and i can see it appear in the wrong place

leaden ice
waxen spruce
waxen spruce
#

thanks!

somber nacelle
#

MinBy is not available in unity, it was introduced in .net 6

leaden ice
#

oh

#

that's tragic

#

just write a for loop then

#

it'll be more performant anyway

waxen spruce
#

but I feel so big brained when I use Lambdas

somber nacelle
#

could also just grab the source from source.dot.net or something and drop it into the project (with some modifications to make it compile)

leaden ice
#

you'll get over it

leaden ice
#

and write your own MinBy function

open plover
leaden ice
#

I don't think a single tolerance float would necessarily make sense, no - and that has nothing to do with normilzation (they're already between 0 and 1 as it is)

tough storm
#

im trying to get navmesh to work in 2D. Im using a git repo that i found to try to get it working, but it throws the "too far from navmesh" warning 9/10 times it tries to spawn and move an agent

open plover
#

and for hsv, s and v are between 0 and 1 but h sometimes isn't

tough storm
#

does anyone know how i can fix this? im wondering if the agent is just passing through the navmesh or something

#

they do have the same z coord

leaden ice
tough storm
leaden ice
open plover
tough storm
somber tapir
#

Anybody know why

item.hideFlags = HideFlags.DontSaveInBuild;```doesn't work for the "StreamingAssets" folder or an mp4 file inside it and if there is an alternative to not include that folder in a specific build?
leaden ice
#

There's no way not to include StreamingAssets in the build because the whole point of StreamingAssets is to include it in the build as verbatim copied files

#

Why do you want or need this exactly?

serene stag
proven light
#

Hello, I've been working on a problem for most of the day and its got me stumped. I have an NPC that is supposed to complete jobs by moving around the navmesh to given locations and carry out a task at each given location.

In my current setup, I have it moving to the location to pick up an item, then move somewhere else to discard it. The moving part works great, the picking up and discarding not so much.

#

the NPC brain script has a public array containing all of its tasks. The tasks right now are empty game objects placed around the map. It works for pathing. This is where I am struggling. In my design the tasks contain the associated action inside them, so the pickup location has a script attached which has a method to give an item to the NPC. The NPC has a reference to that script through its parent gameobject (the task object), and the NPC calls the method to give itself the item from the task

#

Now that I'm writing it out, this seems rather backwards, but I was hoping someone had a better idea of how I could do this.

I was playing with putting a collider at the task location to trigger the task, however I'm building for a warehouse environment where lots of NPCs doing the same jobs may pass through the collider as they are moving around

cosmic rain
# proven light the NPC brain script has a public array containing all of its tasks. The tasks r...

I have an actions system in a project I'm working on.
The actions are just a list of so's that the character(or a character template) has. I then use goap similar system to generate an actions plan. That part is probably irrelevant to you, but when I create an action within the plan, I provide it all the required info, like the item reference that it needs to pick or an object it needs to interact with, for example. These references are passed to the system from the character sensors. The sensors update every frame(or a few frames) and detect all kinds of objects within some radius around the character. If the detected item is an item container(a physical representation of the item or an inventory in the game world), I add all the items inside to a list of detected items.

proven light
#

If I'm understanding that right, I should essentially be making the equivalent of a pickup button for the AI? Then I just have it be able to see and decide which one to pick up based on what's around it?

#

more specifically, it would be like "your job it to pick up chicken" so it moves to the chicken point and looks for "chicken" in the list of detected items?

cosmic rain
cosmic rain
#

The latter one should work the same way both for ai and player characters.

#

The former one is what replaces the player brain for the npc.

proven light
#

Action decision is going to be handled by an outside source, in this case preprogrammed but in the final form it will also be able to be assigned at runtime

cosmic rain
#

In my project, both the player character and npcs use exactly the same system for action execution.

proven light
#

just executed from a different source (human input vs... NPC whatever) right?

cosmic rain
#

Yes

proven light
#

ok yeah. I essentially have the same. Everything is using the same inventory system, I just need to make the NPC perform the action. Neat

cosmic rain
#

You probably don't want the UI to be a part of the this actions/jobs system at all. It should be part of the player controls.

proven light
#

In this case its exclusively NPCs, so that takes care of itself

#

Well that makes a lot more sense now. Originally it was "Go to chicken and activate the chicken action and do what it tells you", whereas now it will be "Go pick up chicken"

#

I just need to figure out how to attach the action to the location

#

Because right now we have "go chicken, go truck"

cosmic rain
#

Or do it via code.

proven light
#

scriptable objects sounds like a good approach. I will need to go back and study them again because I am not very familiar with them

#

reading into scriptable objects more, I dont know if I'm misunderstanding but they cant store implementation? only data?

fossil remnant
#

I'm not entirely sure where to look or how to properly word this: I have a scriptable object in it a few serialized classes attached, these are just a lists of the same scriptable object.
I made it so I could just right click and make the object, the idea is that the scriptable object has 4 lists which just say what can be near its 4 sides.
Is it possible when I had an object to the list, it adds the second object to the first objects list?

#

Essentially the lists look like this, in editor I drag and drop in other nodes. I'm wondering if its possible that when I add the prefab node to this one, it adds itself to the other

fiery rover
#

Hello so i recently set up DevOps for my project and have it sending discord webhooks. Is there anyone that is familiar with DevOps and know if their is a way to change it from using your email in the webhook message to your username?

plucky inlet
tawny elkBOT
fossil remnant
#

I think we're on the same page

astral echo
#

Hey guys, im using ARM IK of Final IK to do True First Person Shooter(Full Body), but im struggling in the hands position in realtion of the camera with the rotation of spines. When the spines are not rotated(changed the position because of the other spines rotation) its works more than fine, but when rotate for a reason i dont know the hand are considering the spines rotation, but i get the hands position before the spine rotation. In my head its supposed not consider.
Ill be very glad if anyone could help me in this, im struggling on this and other logics of this script has months.
The Code:
https://gdl.space/dexifedexa.cs
The Examples:

astral echo
somber tapir
signal moon
#

when the white object (player) goes through this black doorstep, it begins flying up

signal moon
#

any ideas?

knotty sun
sharp saddle
#

Hello, I am trying to publish my first mobile game and am very close the last step really is just building it to an abb file but when it I try to build it, at the end, it always does this.

sharp saddle
#

ok

plucky inlet
subtle path
#

Hey i want to save (override) a prefab variable from the copy that was initialized. how is this possible?

cosmic rain
mellow sigil
subtle path
#

i instantiate a prefab and during play i save a score. But i need that new score on the original prefab, because the instantiate is just a copy and the score is lost upon destroy ofc

mellow sigil
#

Why do you destroy the object that stores the score

subtle path
#

the level is the object

#

when the level is finished, it gets destroyed

mellow sigil
#

Then don't store the score in the level

subtle path
#

but its the best place for it. so is there a way to save a value back to the original prefab

mellow sigil
#

How is it the best place for it if it doesn't work the way you want?

cosmic rain
subtle path
cosmic rain
#

Json doesn't save references.

upper pilot
#

Hey, is there a built in/simple way to change anchor + pivot through script?
So TopLeft would be stuck to the corner at correct pivot(object would not go outside of parent object at 0, 0 position)

#

or do I have to if/else 9 times for each anchor

eager fulcrum
#

Hey, is there any way to detect if mouse is over line renderer?

errant blade
#

i was coding and suddenly i cant do any like unity shortcuts or something

like i cant write transform, gameObject, or anything like those shortcuts
not sure what happend

errant blade
cosmic rain
fringe ridge
#

fixed it, blocks were clipping through eachother

proven light
#

I'm back on my NPCs and a little lost again

#

This is the flow I've settled on

#

My issue is specifically the end of the flow that I'm struggling with. How to make the NPC actually interact with the object.

The thing that I'm actually stumped on is I want to have a lot of objects that use this framework, and many with different functionality. Some will be picking up items, some will be dropping off items, and then some could be completely different behaviors like doing something on a computer or opening a container or whatever.

I dont know how I can attach a custom interact behavior to different objects and still trigger it in the same way for all of them

past raven
#

my rigidbody for my character's arms are moving even after the main body collides with a collider

#

so the arms fly away if i keep the joystick down

#

how do i prevent this

leaden ice
cosmic rain
cosmic rain
proven light
#

That is fair. That was more for the case of "I reached my area but something pushed me out of the way" or some cases like that, if something prevented the NPC from reaching the thing they thought they could reach

cosmic rain
#

Ai brain takes the world context and decides what action to do -> queue desired action(like interact) -> queue any dependency actions(like move to interact position) -> reverse the queue -> agent executes the queue.

proven light
#

its the actual code behind "queue desired action" that gets me

#

before I was thinking store a reference to the interact method in a scriptable object

cosmic rain
#

agent.EnQueue(action)

proven light
#

but I dont know if thats actually possible

#

oh?

#

what kind of agent is that? looking for the api docs on it

cosmic rain
#

The action would be constructed at the planning stage and include reference to the interactable object(or whatever else context it needs). Then, when it's time to execute it, it would use this context.

cosmic rain
#

There's no built in agent for that.

proven light
#

oh agent being a custom thing with your own queue

#

ok I see

#

got confused with the existence of navmeshagent

cosmic rain
#

Yes, with anything related to controlling the npc/character.

cosmic rain
#

In case of navmesh, it's handling the navigation.

past raven
#

and when my code moves the character as a whole

#

but then the arms go flying off

leaden ice
#

and how are th things connected, wth joints? Active ragdoll?

past raven
#

o man it's a real mess my code

#

has clamps and everything

leaden ice
#

That's not super helpful

past raven
#

they're just bones

leaden ice
#

what do you mean "they're just bones"

#

This sounds like an active ragdoll setup based on the limited information you've given

past raven
#

like using the sprite splicer

#

sprite editor*

leaden ice
#

you'd have to make sure you're moving your character via appropriate physics calls, and not by moving the Transfrom directly for example

leaden ice
past raven
#

well i made bones for the body

#

in the editor

#

idk what else u want me to say

#

ok so move the rigidbody and not the transform

leaden ice
#

But yes, don't bypass the physics engine, and physics will work.

#

Active ragdolls are not generally simple

past raven
#

i just want to know if i can prevent body parts from flying off

leaden ice
#

They should be attached to the main body via joints
And everything should only be moved via the physics engine

#

then they won't fly off

past raven
#

what are joints

#

like where the bones connect?

leaden ice
#

It's confusing to me that you're talking about making bones and having Rigidbodies and everything and you don't know what joints are

#

how did you get to this point

past raven
#

i learned along the way

#

plz enlighten me

leaden ice
#

Anyway it's tough to help you since you're providing so little detail about your project

cosmic rain
#

Like a few very big and important steps.

past raven
#

does it matter if the arm bones arent connected to anything?

#

or do bones not even matter

#

will the joints be connected from a distance?

cosmic rain
leaden ice
#

but yeah bones aren't a thing

#

which is why I asked what you meant by that

#

They're a thing in 3D rigging, but the form they take in Unity is not actually as anything called a "bone"

#

Same for 2D sprite rigging.

#

But again I can't even tell if you're using that since you still haven't shared any details about your project

past raven
#

i cant really share it cuz it's all over the place

#

id have to put up like 5 different screenshots

leaden ice
#

That would be lovely

#

Make a thread while you're at it

past raven
#

bleh so much work

#

ill just read this joint api

#

and come back when i need help

leaden ice
#

Maybe also just explain what you're actually trying to do

#

It's confusing to me that you're using multiple Rigidbodies

#

Are you just trying to make an animated character?

#

Or are you trying to make an active ragdoll game

past raven
#

its cuz im using fixedjoint component for sticking the arms to my weapon

#

and it requires a rigidbody by default

leaden ice
#

Why ar eyou using a joint

past raven
#

cuz it rotates

#

the weapon rotates

leaden ice
#

to attach the arms to your weapon (or vice versa)

#

Things don't need to use joints to rotate

#

unless you're trying to simulate physical realism with the rotation for some reason

past raven
#

i can do it in code but thats too complicated

leaden ice
#

Trust me the path you're going down is going to be way more complicated

#

rotating things in code is very simple, once you understand it.

past raven
#

the component is there for a reason man

leaden ice
#

Yes, the reason is for physics simulations

#

But, you do you

#

I was just trying to help.

past raven
#

ty but im pretty sure im doing it the right way

#

i just need to add a joint

leaden ice
#

Well I still don't know what "it" is that you're trying to do

#

so... maybe?

steady moat
# proven light but I dont know if thats actually possible
Unity Learn

In this project you will learn about the Goal-Orientated Action Planning (GOAP) architecture used to create intelligent agents that can set goals and plan at achieving them. Unlike Finite State Machines, actions and states are uncoupled, making for a very flexible system. You will build a GOAP system from the ground up and implement it in a si...

past raven
#

have u guys seen the billion dollar code

#

they really made it interesting

#

i feel like an entrepreneur after watching episode 1

#

i can relate

#

to the crunch

#

even tho ive been working on this game for 10 fucking years

#

on and off again

#

god i hate having a full time job

#

to pay for food

#

and gas

#

indie is so hard man

spare dome
#

why are you thought dumping on here

blazing tiger
#

Is there any library out there that does this? All I found so far is overkill stuff for 3d meshes like greedy meshing

#

I feel like it should be simpler for 2d

#

When I can 100% ensure everything will be coplanar

teal quarry
#

Hi everyone, I am implementing roll mechanic in the game, the movement worked fine, but the roll animation is playing twice(I am using trigger to play the animation), I don't know why, I am tried checking using GetCurrentAnimatorStateInfo(0).IsName() method, but still animation is playing twice. Here is my code

#

if(!playerAnimator.GetCurrentAnimatorStateInfo(0).IsName("Roll"))
{
          Debug.Log("Rolling");                
          base.Move(swipInput, rollMoveSpeed, rollRotationSpeed);
          HandleRollAnimation();    
}

#

private void HandleRollAnimation()
{
            //Debug.Log("Playing roll animation");
            playerAnimator.SetTrigger(rollID);
 }
leaden ice
teal quarry
#

Actually what I want is that I want to know whether animator has set the trigger or not.

leaden ice
#

Your code is confusing to me because it seems like it's saying "If I'm currently playing the roll animation, trigger a roll"

knotty sun
#

there is a ! in there

#

but it's not !code

tawny elkBOT
teal quarry
teal quarry
knotty sun
#

just edit your post

teal quarry
knotty sun
#

so what is the context of the code

teal quarry
teal quarry
#

Sorry for not understanding the question.

knotty sun
teal quarry
#

Okay. I will.

knotty sun
teal quarry
#

Here it is @knotty sun

knotty sun
#

I was looking for this.
//Debug.Log("Playing roll animation");
also uncollapse the log

teal quarry
#

Okay.

knotty sun
#

So why no Playing roll animation ?

teal quarry
#

Okay. I will add it. Sorry for inconvenience.

#

Here it is again.

#

@knotty sun

knotty sun
#

omg. Now you've taken out the Rolling

teal quarry
knotty sun
# teal quarry

Ok, so there is obviously a delay between you setting the trigger and the animation running thus causing you to constantly set the trigger. So you will need to implement a bool to stop you doing this

teal quarry
knotty sun
compact fog
#

Can someone help me figure out what is going wrong with my rigidbody controller?

        public void SetVelocityWithMomentum(Vector3 incomingVelocity)
{
          // Ignore y velocity when calculating the desired change in velocity
            incomingVelocity.y = 0;

            // Calculate the desired change in velocity
            Vector3 desiredVelocity = incomingVelocity + currentGroundAdjustmentVelocity * acceleration;
            Debug.Log($"incomingVelocity: {incomingVelocity} currentGroundAdjustmentVelocity: {currentGroundAdjustmentVelocity} acceleration: {acceleration} desiredVelocity: {desiredVelocity}");
            // Example output while holding W key:
            // incomingVelocity: (1.35, 0.00, 2.68) currentGroundAdjustmentVelocity: (0.00, 0.20, 0.00) acceleration: 4 desiredVelocity: (1.35, 0.79, 2.68)

            rb.AddForce(desiredVelocity);
            Debug.Log($"Actual Velocity: {rb.velocity} Current Speed: {rb.velocity.magnitude} Desired Speed: {desiredVelocity.magnitude}");
            // Example output while holding W key:
            // Actual Velocity: (0.00, 0.00, 0.00) Current Speed: 0.001517748 Desired Speed: 3.103522
        }

As you can see from the debug outputs, its not gaining any momentum at all. The rb's mass is set to 54, but even when I set it to 1 it gains as such a low rate that its nearly pointless.

Debug at 1 mass, while sprinting (doubling the incoming velocity):

incomingVelocity: (2.32, 0.00, 5.53) currentGroundAdjustmentVelocity: (0.00, -0.01, 0.00) 


acceleration: 4 desiredVelocity: (2.32, -0.03, 5.53)
Actual Velocity: (0.00, 0.00, 0.00) Current Speed: 0.001421971 Desired Speed: 6.000091
rigid island
#

no shit

rigid island
tawny elkBOT
compact fog
#

I dont see why you need the rest of the code, I literally am outputting all the variables used. Nothing else in my code modifies velocity on the rigidbody.

leaden ice
#

it gets updated during the physics simulation

#

If you want to do it in a way that is visible and mathematically equivalent you can do this:
rb.velocity += desiredVelocity / rb.mass * Time.fixedDeltaTime;

#

note that desiredVelocity is a confusing name for a force.

compact fog
compact fog
leaden ice
rigid island
leaden ice
#

The "not supposed to modify velocity" instruction is mostly about setting it to something that doesn't take into account the current velocity at all

#

In addition I thought it would cumulatively add the force the longer the velocity was applied.
This is true both about AddForce and doing velocity += ...

#

For example if you do velocity = Vector3.forward * speed; this completely overwrites the velocity. That's the thing you were warned about

compact fog
#

Gotcha that makes sense. I'll look into a bit more.

elfin tree
#

my webgl build seems 'slow' but still runs at 60fps, is there a way for it to actually slow down fps wise and not just the timescale and things like that?

#

or am I missing something

#

like I have a timer running and 1s takes almost 2s

leaden quiver
#

I'm currently trying to make a small tower defense game, mainly inspired by Bloons, and I'm having trouble making a good way to get the enemies' movement path to work well. All tutorials I've found so far have just placed "checkpoints" and having the enemy move toward the next checkpoint whenever they get close enough to the previous one. This doesn't work for me, both because it can mess up at very high speeds, and because I'm trying to make enemies that split into multiple smaller enemies when killed. When this happens I don't want the smaller enemies to just spawn on top of each other.

Like, if an enemy splits into 2 I want one to spawn slightly forward on the track and one to spawn slightly back, but I can't figure out a good way to accomplish this, at least not with the current way I made the path. Does anyone have any ideas?

leaden ice
leaden quiver
severe sleet
#

not a code issue, but everytime I launch Unity and then open a script, it doesnt have the intellisense thing active. (like the autocomplete for GameObject etc) I have to keep going into the settings to reselect visual studio

dusk apex
severe sleet
soft shard
timid briar
#

Hi

blazing tiger
#

Will having a giant texture on a material be a problem down the line? Talking about texture atlases here

#

Stiching all the tile textures into one big texture because that way I can draw everything at once, and I know for a fact I'm gonna be using the same material

#

I think some gpus actually have hard limits for how big a texture can be

elfin tree
#

hey i changed a setting in build settings(?) and I don't remember what it is but I no longer have Debug.Logs in Editor

#

I have all Full Stack Trace boxes checked and running in WebGL

#

anyone knows what the setting/where it is?

shell scarab
#

I am trying to jump to a time on a timeline, but for some reason when this code runs while the timeline is paused, it evaluates signal emitters in-between the current time and the time it's jumping to (that aren't set to retroactive). How do I avoid this?

As an example, imagine a timeline where this code runs at 10 seconds, there is a signal emitter at 15 seconds, and the marker it is jumping to is at 20 seconds. If the timeline is playing and hits 10 seconds, this code will correctly jump to the marker's time, skipping the signal emitter. If the timeline is paused at exactly 10 seconds, when this code is called to jump to the marker at 20 seconds the signal emitter at 15 seconds will be evaluated. How do I prevent this?

director.Pause();
director.time = markers[markerID].time;
director.Evaluate();
director.Play();
somber nacelle
elfin tree
#

ah

#

i need to run a build

#

so the settings would get applied in editor aswell

#

it seems

somber nacelle
#

wait, are you actually referring to your logs not printing to the editor console rather than the log file?

#

also that's not really a code question

cosmic rain
sleek bough
#

@marble totem Not a place for requests. If you have an actual question about learning Unity, ask away.

#

Also this is a code channel

marble totem
quaint rock
#

that sounds like a question about roblox studio not unity though

sleek bough
#

And this is still a code channel

marble totem
quaint rock
#

no one is answering since it makes no snese without the context, Unity is not a DCC app you dont export fbx files from it

quartz folio
#

There's little reason to author content in Unity for export to other apps, unless it's for further authoring in Unity, or you've got a virtual production pipeline. None of which this sounds like

quaint rock
#

or unless its for like making a asset bundle for something made in unity, but that is rare and i would still look at the docs for that thing not unity

marble totem
#

thats why i have to shove it into unity first

sleek bough
#

I mean there is a supported way to do it. Just the question was posed as a job request and still in the wrong channel. Also simple google search would answer that. Extremely lazy and off-topic.

marble totem
# sleek bough I mean there is a supported way to do it. Just the question was posed as a job r...

lil bro u have no clue the issues im having u sound like such a nerd, ive used google, ive watched videos do u seriosuly think my first thought when i have an issue it to look up the officical unity discord and ask a bunch of condisending nerdy moderator to answer my question. The FBX is in a complex format, rigging, materials, animation keyframes are all seperated from original FBX model file. honestly bro gets moderator and just goes to his head.

sleek bough
#

!mute 887086739846479902 3d rude as well. Take some time to read server rules.

tawny elkBOT
#

dynoSuccess awvm was muted.

quaint rock
#

you are acting like a child when people are only trying to inform, and pointing out the question is off topic and lacks enough context to be answerable

quartz folio
# marble totem lil bro u have no clue the issues im having u sound like such a nerd, ive used g...

If it's an FBX that just happens to be in a unitypackage file then it's just an FBX and this has nothing to do with Unity. If there's more stuff added to it all of that is Unity-specific and cannot be exported. (You may have luck with the FBX exporter, but that's unlikely to be relevant).
This is a programming channel for Unity. None of your question relates to that, so it's no surprise you're getting a response like this

void basalt
chilly surge
#

I have n 2D points in clockwise order, which each connects to the origin and thus they divide the plane in n parts (think a pie chart). Given a target point, what's the easiest way to tell which part it's in/test if it's in a certain part?

quaint rock
#

if its like a pie chart, you should know what angle each starts and ends out

#

can make a direction from the origin and given target point and get its angle

chilly surge
#

Testing angles is kind of annoying though because of wrapping around.

quaint rock
#

modulo to 360 should help with that unless one of pie pieaces goes over the 0 point

#

other way could just be treating each area like a triangle and testing if the point is in any of them

#

i forget that math for checking that manually

#

but you could use like a PolygonCollider2D and its OverlapPoint method

chilly surge
#

Yeah I'd like to do that with pure math.

#

The points can rotate around and the only guarantee I have is that the points are in order. So even after moduloing them, the first point could have an angle of 350 degrees, and the next point could be 7, and checking if an angle is in between or not still seems a bit annoying.

#

I guess one approach is to normalize the angles to a strictly increasing manner, and also normalize the target point's angle to be larger than first point's angle, then comparison could be done without worrying about wrap around.

quaint rock
#

yeah mentioned that first since solving as a trinangle is kind of a pain

lucid ivy
#

how could i make something where theres like the us map with states and i can click on each state for info and interaction options

leaden ice
quaint rock
#

yeah split it up, or draw polygon colliders over it

lucid ivy
#

so after i split the map and put them individually into the project how would i make it select that state's stats and interactions instead of the other ones

leaden ice
#

Put a script on each with the state information

dawn nebula
#

Need a bit of analysis. In this video, I'm placing my mouse over a specific part of Earth, and as I zoom, the camera slowly pans over to that location centered around the mouse. What's the math behind this?

plucky inlet
maiden fractal
#

Could be something like that but the zoom out is something that I'm wondering how it would be able to inverse that behaviour

maiden fractal
# dawn nebula Need a bit of analysis. In this video, I'm placing my mouse over a specific part...

One thing I'm wondering is whether it would simply work by zooming in by moving the camera straight towards the earth and rotating the camera right amount to keep the cursor pointing at the same point on map. To help calculate that rotation, it might be easier to try to figure out the amount you need to rotate the earth to keep the cursor at the same point and just inverse that rotation to get the camera rotation

plucky inlet
#

I am guessing, the target spot the camera is point to is also just a lerp between center of earth or current rotation towards the final spot. Botht he movement and target lock are then animated from 0-100 percent in parallel to give you this smooth bidirectional movement.

hexed pecan
open plover
#

Doesn't linerenderer follow the parent position if its a child of the paren?

past raven
#

my distance joint isnt working

maiden fractal
past raven
#

is anybody alive out there

hexed pecan
#

And provide more info

knotty sun
tawny elkBOT
#

:thinking: Asking Questions

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

eager fulcrum
#

Hey is it possible to create animated rule tile?

placid edge
#

what movement type is good for when I want to add 2 different movement forces to the same object?

#

I'm trying to make an object that slowly pulls other objects in, but these objects are all also trying to get to a different point, how would I go about doing this?

soft shard
# placid edge what movement type is good for when I want to add 2 different movement forces to...

If your using rigidbodies, you could use AddForce to add a directional force onto the current velocity, or you could control adding velocity yourself, I do something similar for effects in my game where I have a "move" velocity controlled by player input (in your case, it sounds like it would be controlled by AI logic) and then I can += a "influence" velocity and either drop it over time back to 0, or have something like a debuff set it to 0 when it ends, so it may be something like rb.velocity = move + influence; influence = Vector3.Lerp(...);

placid edge
#

Hmm somethings not adding up for me here

#

the lerp is the distance between the black hole and the object right?

#

and the move is the original movement betwen its current position and its destination?

knotty sun
#

no, lerp is
current = start, end, t
where t = % of difference between start and end expressed as 0-1

placid edge
#

yeah thats what i meant ;v

#

so t at 1 would be a blink?

knotty sun
#

no, t at 1 would return end

placid edge
#

so, yes...

leaden ice
#

Lerp(a, b, 1) just returns b

placid edge
#

yeah

leaden ice
#

Lerp(a, b, 0) just returns a

placid edge
#

alright I got it working in a smooth way, just need to figure out how to reset the influence, cuz its stacking forever whenever they come back into contact with the black hole

placid edge
soft shard
dusk apex
placid edge
#

I don't know what it is I just cant do it

#

im trying everything but the speed just keeps stacking

#

they're also no longer going into the black hole but being repelled by it

#

though i dont think its because i got the Vectors mixed up i think its something to do with the objects distance from world 0,0,0

placid edge
#

I got it. I forgot a times force

#

haaaaah coding, never change

wanton cedar
#

I have this "chunk" of integers here, which is a blank canvas for my procedural road script to create road on, so moving one tile up would be done by subtracting 8 from the current tile, and down, would be to add 8 to the current tile.

My question is, now that i am making it detect if it is near the edge of a chunk, how would i do that with the left and right edge? - I did it for the up and down, by checking if the length of the array is longer than current tile + 8 for down, and same with "- 8" for up, but how could i do left side check when it can be all the numbers: "0, 8, 16, 24, 32, 40, 48, and 56"

should i just check if the currentTile incremented with one would be divided by 8 with a remainder of 0 ?? or does that have some issues as well??

simple egret
wanton cedar
#

i would rather not xD - each of these numbers will be changed, and each of those numbers it will be changed to has properties that i have allready built

leaden ice
#

Or I guess you're asking if the column is 0 or 7?

#

wouldn't it be:

int width = 8;
int height = 8;

int row = index / width;
int col = index % width;
```?
#

then it's just bool onHorizontalEdge = col == 0 || col == height - 1;

#

likewise bool onVerticalEdge = row == 0 || row == width - 1;

simple egret
#

You can convert XY "coordinates" into a single-dimensional index using the formula idx = WIDTH * y + x assuming Y goes down (rows) and X right (columns)

leaden ice
#

yeah that's the reverse calculation:

int index = width * row + col;```
wanton cedar
#

the rest of the row & column navigation is pretty much made by now, so i just wanted to use math for this last little detail. The script will move out procedurally from around the center point, in increments of one row/column at a time. so if i can just with math calculate a list of numbers that would make up the left and right "edge", using the width of the square

neon plank
#

Why if I wrap serializable fields with #if UNITY_EDITOR and build I sometimes get an error which says that an scripted object has a different serialization layout?

  1. Why it's sometimes and not always?
  2. During building the game, I thought unity recompiles the scripts and reserialises the assets, if that were true then this error should not appear and they field would be filtered out. ๐Ÿค”
chilly surge
#

(As a side note, a single dimensional array where you do your own index conversion is obviously the fastest, but even jagged array is faster than multidimensional array. Not that I would suggest choosing base on performance, the difference between these are negligible in most cases)

leaden ice
leaden ice
neon plank
#

I have several classes which uses that and I don't run into problems, until today where I'm starting to get this error...

leaden ice
#

As far as I know that's always been disallowed.

shut sun
#

the manual says otherwise, which is... fun

neon plank
#

Unity documentation says something about this? Where?

leaden ice
#

I'm now very confused

lime viper
#

i have an fbx prefab imported (i ensured the axis are exported correctly). I want to apply a rotation via script to a gameObject inside that prefab. the problem is it is acting erratically. meanwhile if i try the rotation script on a cube, it works as expected.
does anyone know if there is something native to fbx that is causing this issue?

leaden ice
#

show the code, and show what ahppens

#

not likely to be related to the FBX, no

lime viper
#

my best guess is it has a pivot point way out in space so a rotation of 1 degree looks like a move of about 2 meters

leaden ice
#

why is that a guess

#

why don't you just look

lime viper
#

the prefab has the location -46, 0 -35. but all the objects are 0,0,0

leaden ice
#

I'm not sure what that means

#

show some screenshots

lime viper
#

location data for each child

#

all at 0,0,0 except the prefab. but i dont even think thats an issue

leaden ice
#

You need to set this to pivot

#

if you want to see the real locations of the objects

lime viper
#

ok , yes the pivot is way off in the distance. but i feel like i can find that in script then translate it over to where the red sphere is on the door.

#

like find pivot and center in script then move pivot to center and use it for rotate.

leaden ice
lime viper
#

ok. ive seen one in twinmotion thats kind of like 2. but i was trying to avoid that. i'll look up the blender way.

versed loom
#

What would be the best way of doing multiple string comparasions? I have a param of readonlyspan<char> and I want to do different things if the param is "b", "uppercase", "u", "lowercase" etc

leaden ice
#

a loop, a switch, a series of if statements, a Dictionary

#

any of them could work and be elegant, depending on the circumstances

simple egret
#

Check out StringComparer.Create(), you can pass a culture and a variety of string comparison options (ignore case, ignore symbols, etc.). You could pass an instance of that into your method and use .Compare(s1, s2) to do the string comparison

plain halo
#

I am using a kinematic rigidbody for the player and a dynamic rigidbody on the ball.

#

Another thing I don't understand is why hitting the ball horizontally doesn't apply any of the things written in the script (speed, bounce, animations). It is as if only the collider is applied

ornate perch
#

does anyone know if its possible with custom editor stuff to get this graphic from the rule tile

#

I can't really find anything about what type of field this would be at all

ornate perch
#

okay!

tawny leaf
#

My code is this:

#

Im making a spaceship that shoots bullets, but it dosent work

#

Does anyone knows?

vagrant blade
#

Line 25 is referencing something that doesn't exist. Presumably because you have no "Cannon" object in your scene to actually find.

tawny leaf
#

okay

solid heron
#

you can just check if the y < a certain amount and if so then just add a default amount that would make it go towards the enemy?

chilly surge
#

Hmm, more of a math question than code one so not sure if this is the best place for it.
Let's say I have some triangles where I know when they are rendered on screen, any pair of two triangles will not intersect. In other words, choose any two of the triangles, one of them will be in front of the other.
Is there a value I can assign to each triangle, such that when I take two triangles I can use their values to determine which one will be in front?

leaden ice
#

Like - based on the vertex data or something?

#

Could you calculate the centroid of each of them and use the distance from the camera to the centroid?

chilly surge
#

Yeah I have some triangles in the form of triplets of vertices.

#

I thought about using distance from camera to center of each triangle, could work but was wondering if there are other ideas.

leaden ice
#

Square distance to the centroid ๐Ÿ˜‰

dawn nebula
#

I have 2 rotations and I want to move along it by X degrees, what method should I be using?

plucky inlet
knotty sun
dawn nebula
lean sail
dawn nebula
frigid turtle
#

hi there guys, did anybody face the issue with TMP and addressables, when you load a bundle with prefab which has TMP it shows pink text?

dawn nebula
#

Probably my own code.

#
    void Update()
    {
        var delta = Input.GetAxis("Mouse ScrollWheel") * scrollSpeed;

        var newScale = Mathf.Clamp(currentScale + delta, 1, 100);

        var input = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Camera.main.transform.position.z);
        Ray ray = Camera.main.ScreenPointToRay(input);

        if (Physics.Raycast(ray, out var hit))
        {
            var angle = Vector3.Angle(Vector3.back, hit.normal);
            var arcLength = Mathf.PI * currentScale * (angle / 180);

            var scaleFactor = newScale / currentScale;

            var arcOffset = (arcLength * scaleFactor) - arcLength;

            float radians = arcOffset / newScale;
            float degreeOffset = radians * (180 / Mathf.PI);

            Vector3 axis = Vector3.Cross(hit.normal, Vector3.back);
            transform.rotation = Quaternion.AngleAxis(degreeOffset, axis) * transform.rotation;
        }

        sphere.localScale = Vector3.one * newScale;
        sphere.transform.position = Vector3.forward * newScale;
        currentScale = newScale;
    }
plucky inlet
dawn nebula
#

Fits with the mouse.

sleek bough
plucky inlet
#

Yeah, but the zoom final position of your camera is the hit.point or something with offset above the hit point normal?

dawn nebula
#

Optimal illusion.

lean sail
dawn nebula
lean sail
#

I find doing your own trig can pretty much always be avoided

dawn nebula
lean sail
#

If you just learned what a trig function is maybe, I prefer to use methods that directly solve what I need

plucky inlet
frigid turtle
#

or maybe it missing shader or material, idk

stone rock
#

Are there easy methods to create functions that replicate what Gizmos do but for builds? so you can turn on some debug lines in a game build?

sleek bough
stone rock
#

With procedural geometry i assume you just need a game object with a meshrenderer and modify that mostly right?

sleek bough
#

building out custom shape from vertices into procedural mesh

stone rock
#

yeah, i mostly just needs some lines and circles, that should not be too hard i think

sleek bough
#

If you need this for 2d only you can just shape spriterenderer calculating how to scale it and use other primitives as well

stone rock
#

I am using it for 3D, it's mostly to visualise some forces and direction vectors for a vehicle

sleek bough
#

Could shape simple capsule objects for that then. As line renderer doesn't always look right in 3d

stone rock
#

yeah, i was thinking of a sort of mesh with a thickness to represent the line and circles

plucky inlet
gaunt rain
#

Hi, I'm trying to batch render the blocks of a grid:

void SpawnGrid()
{
    for (var i = 0; i < GRID_SIZE; i++)
        for (var j = 0; j < GRID_SIZE; j++)
            SpawnBlock(i, j);
}

void SpawnBlock(int i, int j)
{
    var o = Instantiate(BlockObject);

    o.transform.position = BlockPosition(i, j);
    o.transform.localScale = BlockScale();
    o.isStatic = true;
   
    o.GetComponent<MeshRenderer>().sharedMaterial = BlockMaterial;
}

however the batches count is +800

thick terrace
gaunt rain
#

I already tried StaticBatchingUtility.Combine but I can't dupplicate the gameobject BlockObject without spawning it in the scene

thick terrace
#

aren't you spawning it in the scene in the code above?

knotty sun
gaunt rain
gaunt rain
#

ok I managed to merge all meshes together and render them as one gameobject only

#

now I got 9 batches count, the fps changed from 240 to 240 ๐Ÿ˜‚

#

some useles optimization here

knotty sun
gaunt rain
knotty sun
#

So in Editor. Editor fps is meaningless, the Editor itself has too much influence, Built fps is the ONLY one that matters

gaunt rain
#

ah ok, predictable, btw is this even batch rendering? I just merged all the mesh together manually

#

I'm not even sure it's batch rendering at this point

bleak cypress
#

Hy everyone! I'm asking help for my game project, can i ask it here?

tawny elkBOT
#

:thinking: Asking Questions

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

knotty sun
bleak cypress
#

I make a game with ennemies helthbar, all work. But when I add more game featurs, ennemies healthbars strangly stop working! skript seems good and no console errors, can someone help me?

somber nacelle
gaunt rain
# knotty sun you wouild need to look in the profiler

what do you mean? the batches count is at 9 despite the big number of blocks I spawned, the point is: is this how batch rendering operates under the hood? is it a "merging meshes together and doing only one draw call" or is it rendering multiple objects and doing only one draw call?

cosmic rain
#

If you need further performance troubleshooting, you should use the profiler to identify bottlenecks.

outer plinth
#

Hey, i am struggling with this particular Orientation problem, I want the character's Up and Forward axis to return to normal but also apply the additional rotation, this code seems to do this but the additionalRotation is applied in the wrong direction

https://pastebin.com/d5Ny7BH5

#

I think it's a problem with how the rotations are being combined but I'm unsure of the best way to combine them

hexed pecan
sick cove
#

i'm trying to make snake on this system.
when the object collides with one of the squares, that same square turns on the light to the right colour. red for food, green for head and yellow for the tail.

when the object enters the collision of the square, it changes the colour to the right colour (red, yellow or green), and when the objects exits the square, it changes it back to 0/off/white.

however as visible in the video, it turns on and off the lights at the same moment. causing it to be inconsistent if the light is on or off.

i'm using the following code:

#
    public int LightX = 0;
    public int LightY = 0;
    public int LightLevel = 0;
    // Start is called before the first frame update



    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
            LightScript.SetGridButtonLight(LightX, LightY, 0);
            GetComponent<SpriteRenderer>().color = Color.white;
        }

        else if (collision.CompareTag("Red"))
        {
            LightScript.SetGridButtonLight(LightX, LightY, 0);
            GetComponent<SpriteRenderer>().color = Color.white;
        }

        else if (collision.CompareTag("Yellow"))
        {
            LightScript.SetGridButtonLight(LightX, LightY, 0);
            GetComponent<SpriteRenderer>().color = Color.white;
        }

    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Player"))
        {
           LightScript.SetGridButtonLight(LightX, LightY, 1);
           GetComponent<SpriteRenderer>().color = Color.green;
        }

        if (collision.CompareTag("Red"))
        {
            LightScript.SetGridButtonLight(LightX, LightY, 3);
            GetComponent<SpriteRenderer>().color = Color.red;
        }

        if (collision.CompareTag("Yellow"))
        {
            LightScript.SetGridButtonLight(LightX, LightY, 5);
            GetComponent<SpriteRenderer>().color = Color.yellow;
        }
    }

does anyone know a solution to this?

#

setting the light happens in a separate script. however until the tail got introduced i didn't have a problem with this.

rigid island
sick cove
#

press the button to go through the colours

rigid island
#

wow. Does unity read these inputs as regular HID device or ? serial?

sick cove
#

however now that i'm actually making a moving game, i have the above problems

rigid island
#

will check it out and see if I can come up with something

sick cove
rigid island
sick cove
#

(it's too long for discord. 1 sec

rigid island
#

so the tail growing keeps flashing whilst moving , thats the issue?

#

here use one of the linkshare websites !code

tawny elkBOT
sick cove
#

!code

tawny elkBOT
sick cove
rigid island
#

okay so the LED matrix is just a simple 2d array. Ok so you only set positions OnTriggerEnter it seems

#

or is there a movement script that updates each motion/ key stroke

sick cove
#

and with OnTriggerExit I reset them

rigid island
#

which object has this trigger though

sick cove
#

there is a movement script. but it doesn't interact with the lights

#

the squares each have their own trigger

rigid island
#

oh

sick cove
#

when someonething with one of the tags collide with those the colour changes to the one with the same tag

#

so i have a 'red' tag, a 'yellow' tag and for the player i have green 'player' tag

#

so i use compareTag for that.

rigid island
#

the same script works on PC ? because using triggers is not something i've seen before with a snake game

sick cove
#

from what i see, it fires both enter and exit at the same time, because both something enters and exits the square.

sick cove
#

let me quickly make a gameplay video from pc

rigid island
#

I feel like thats what might give off result, need to prob see how you move the snake as well , thats very important for accurate detection for physics (triggers)

sick cove
#

for the movement:

i set a vector2. to one of the directions using the buttons in fixed update. and then i lowered the fixed update amount to about 0.25

rigid island
#

I would probably just update the LED matrix every move made. I would not use triggers or physics, esp the 2D representation working fine

#

assuming you are moving this with transforms directly or something ?

sick cove
#

normally yes, this is just a prototype.

sick cove
hexed pecan
#

I wouldnt use physics for this at all, some array/2d array would do

rigid island
#

yeah moving too fast that wont give very accurate hit results

sick cove
#

with a mathf.round to make sure it's a full int

rigid island
sick cove
#

i'll just have to figure out how. i'll take a look at it.

#

not to used to coding things like this

rigid island
#

but yeah physics here is overkill and prob more harm than good

rigid island
sick cove
#

is on it's way

#

i don't use the rigidbody and movespeed, which are in the script as something i removed

rigid island
#

yeah rigidbody is the physics component, right now you're teleporting it skipping the physics

#

sometimes it catches up in time though so it does detect

#

you normally let rigidbody move your transform into place, instead of other way around

sick cove
#

the green is always consistent on the screen. it's only the ones that come after that that get confused and randomly decide to be on or of each movement

#

screen = board

rigid island
#

just one of those luck of the draw things lol

sick cove
#

yep.

rigid island
#

guaranteed if you code the leds to match whats already happening in the 2D space you wont have issues

sick cove
#

is there a way to delay either the 'onentertrigger' or 'onexittrigger' ?

rigid island
#

you dont even need triggers

#

You could just signal an event or just tie the LED script into movement

sick cove
#

i'll take a look at both options. thanks a lot

rigid island
#

you already have the positions of yellow, green and red no? you just update them on the led board each movement

#

might have to create mapping function like v2 to your 2d array matrix

sick cove
#

so first check the locations on the grid, and then update the lights

rigid island
#

yeah first you want to make your current movement move on a 2D array board

sick cove
#

i'll have a look at it later tonight. i have to go now. i'mma save all of this

rigid island
sick cove
#

That's a great idea

#

Led snake

floral crescent
#

I can't seem to find KeyCode.Section

rigid island
floral crescent
outer plinth
vagrant blade
floral crescent
rigid island
floral crescent
vagrant blade
#

I don't even know where that is on my keyboard

rigid island
#

facts

floral crescent
#

lol

rigid island
#

you prob need to store it else where

floral crescent
#

Hm... Can I put the keycode based on layout location?

rigid island
#

no

floral crescent
#

By that I mean, I'd like to set KeyDown to Location of tilde

#

Since Mac blah blah

rigid island
#

Don't think you can change the enum bindings

#

as I think each keycode is a ascii representation

somber nacelle
floral crescent
somber nacelle
hasty plinth
#

Ok so I am getting this error:
"Object reference not set to an instance of an object"

#

Very standard error

hasty plinth
#

But here is my code:

somber nacelle
#

!code

tawny elkBOT
rigid island
#

also you havent said which line that error is on

hasty plinth
#

I know sorry, I had an idea mid sentence and went to test it out

#

it didn't work

rigid island
#

probably wont be anything revealing you can't see on your own

hasty plinth
#

line 40

rigid island
#

whatever is on line 40 is null then ๐Ÿคทโ€โ™‚๏ธ

hasty plinth
#

it is on this line
BlackHoleData[i].x = stageManager.BlackHoles[i].x;

rigid island
#

stageManager or BlackHoles[i] is null

hasty plinth
#

stageManager.BlackHoles[i].x is not the problem

#

BlackHoleData[i].x is null

rigid island
#

x can't be null if its a float

#

prob BlackHoleData or BlackHoleData[i]

somber nacelle
#

presumably there was nothing assigned to that index of the array

hasty plinth
#

yes because I am setting it right now

somber nacelle
#

where

rigid island
#

on/from an unkown/null object prob

hasty plinth
#

ok so give me a sec

#

at the begging of the code i set

public BlackHole[] BlackHoleData;
rigid island
#

is this a private array ? did you actually initialize it

hasty plinth
#

where

[System.Serializable]
    public class BlackHole
    {
        public float x, y;
        public float size;
        public float radius, pull;
    }
#

at the bottom of the script

rigid island
#

alright so whatever is at index i its null and not blackhole

hasty plinth
#

then I do

BlackHoleData = new BlackHole[stageManager.BlackHoles.Length];
        for (int i = 0; i < BlackHoleData.Length; i++)
        {
            BlackHoleData[i].x = stageManager.BlackHoles[i].x;
        }
somber nacelle
somber nacelle
hasty plinth
#

but now that I see it again do you have to download it to see it?

#

if thats the case I will sent a paste bin

somber nacelle
#

notice how the bot message almost directly below that tells you how to correctly share code here

rigid island
hasty plinth
#

Oh ok then

#

give me a sec

#

I assumed you could see it

hasty plinth
somber nacelle
#

okay well the issue remains the same, you have not actually put an instance of BlackHole into any index of your array, therefore every index contains null

#

same goes for your Obstacles array

rigid island
#

all you need is new() in your loop and make new object each loop

somber nacelle
#

in fact, literally all you need to do is just BlackHoleData[i] = stageManager.BlackHoles[i]; like you're doing for PlanetWeights, unless you need separate instances for whatever reason

rigid island
#

oh yea much easier ^

hasty plinth
#

Thanks for helping with my issue

hasty plinth
#

the problem is that I have 2 identical BlackHole classes. One in the script I shared and one in me StageManager script. Is there a way to make them "Global" in some way?

somber nacelle
#

just don't redeclare the same class

hasty plinth
#

But then I will need to reference it in my other script in some way

somber nacelle
#

what

thick terrace
hasty plinth
#

Oh wait. My current BlackHole class is inside of my StageData class

hasty plinth
somber nacelle
somber nacelle
hasty plinth
#

Like this:

public class StageData
{
    [System.Serializable]
    public class BlackHole
    {
        public float x, y;
        public float size;
        public float radius, pull;
    }
}

and

public class StageManager
{
    [System.Serializable]
    public class BlackHole
    {
        public float x, y;
        public float size;
        public float radius, pull;
    }
}
knotty sun
#

why on earth would you do that?

leaden ice
void blaze
#

HI,I need help
my new input system works on the editor but not after build and run, why?

hasty plinth
hasty plinth
hasty plinth
#

thanks for helping though

void blaze
#

HI,I need help
my new input system works on the editor but not after build and run, why?
anyone help me pleasee?

somber nacelle
void blaze
#

okay

knotty sun
void blaze
#

my new input system works on the editor but not after build and run, why?
anyone help me pleasee?
thats all..
I tried some method on youtube but still didn't work. and also tried as in https://discussions.unity.com
I just don't know why??
the input wasd and more works in the editor but not after build and run
Here are the possible image that I know..
I don't know where the exact problem is

plush ridge
#

Anyone have any advice on controlling the timing/flow of a game when using an event based structure? Basically, the flow of my game is completely linear, so I need thinks to happen at specific times after other things have happened.

I currently have a game manager that manages the states (these are sequential and occur in series, with the exception of an idle state) and fires off different events sequentially in each state.

For example,
"SetUp"
OnShuffle?.Invoke()
OnDeal?.Invoke()

If shuffle completes after deal, then I have a problem.

vagrant blade
#

If you're doing it sequentially, then you can use a coroutine that yields to other things that have to happen. That gives you full control of the order of things, while allowing you to wait for things like animations, etc. to complete for each part.

plush ridge
#

and then wait for the finished event using a coroutine

vagrant blade
#

I wouldn't use events here, really

#

I would just reference the deck and stuff directly

#

That way you can yield return new WaitUntil (...) for them to do their thing/animate, before stepping to the next part

#

Or if they have coroutines, just yield return StartCoroutine(...)

plush ridge
#

I gotcha. I'll probably end up doing that. Thanks for your help!

#

ChatGPT came up with something kinda cool. Sorry to be douchie and share it right after you had suggested coroutines; but I still think it's pretty neat and wanna share it anyway lol

#

although doesn't work for passing parameters :/ you're right, direct references is the way to go.

vagrant blade
#

This does work, I've used this method before specifically for a turn based game.

#

You create "Template" functions PlayerTurnSetupTemplate() , PlayerAttackTemplate and queue a bunch of events based on what you want to happen, then pass it to some manager that steps through each event that was added in the template.

#

But it does lead to a lot of switches/if statements, which is why I prefer to just do things directly.

#

You don't need to be fancy about it, just make it work for your game.

torn cedar
#

Hello, how can I make the input system easier to use? What ways can I follow to prevent the code from getting mixed up?

gray mural
leaden ice
torn cedar
#

should i use events

gray mural
#

Events are useful if implemented correctly

leaden ice
#

You should use events for things where events make sense.

#

You should use polling (reading input in Update) for things where polling makes sense

torn cedar
#

I'm not doing anything very important, I just want to make it go back and forth with WASD. Even if I want to do something simple, I want to proceed with the best practice.

leaden ice
#

Not sure what you mean by "important", but for basic directional movement my recommendation is to poll the input data in Update.

#

Since it is a thing that continually changes

rigid island
spare dome
#

you optimize after your game is mostly made

#

or when all of your ideas are in fruition

torn cedar
river kelp
#

If I report bugs in unity systems that are critical to my setup, is it usually worth waiting for them to fix it or should I start making my own parallel system?

#

Assuming my bugs aren't cool enough to get pushed to the top of the queue

spare dome
knotty sun
river kelp
#

of course it varies wildly

lean sail
#

You should find a workaround always

knotty sun
river kelp
#

Oof

#

Took them only 48 hours to have a tester confirm my bugs existed so I was hoping for something speedier

knotty sun
river kelp
#

Alright. Thanks.

river kelp
#

Instead try to designate a key to something in something like a player controller and then send the event around. Makes it easier to control and prevent button presses from activating in certain situations.

sleek hedge
#

where is AsyncGPUReadback?

leaden quiver
#

Does anyone know how to access the position of the first knot in a spline container with the splines package? I'm trying to get the position from another script

hexed pecan
#

It's available since unity 2018.2

grizzled dune
#

hey everyone
so i have a general question on coding, I myself know how to code however sometimes i may need a friend's help over a certain topic
example, I coded the player but he will code enemy for me, etc....
is this a good idea that i can stick to and end up making a successful game?

indigo tree
lean sail
#

Though if you dont understand what their code is doing at all, you more likely have spaghetti

indigo tree
grizzled dune
lean sail
grizzled dune
spare dome
#

you want us to write you code while you model or something?

#

not sure we can or will do that but we can assist you along the way

grizzled dune
spare dome
#

i mean you can if you want if it is working for you guys

#

if you are working efficiently the sure

#

if not, then probably not

#

we cannot really give you a yes or no answer, it is up to you to decide

subtle oasis
#

Hellooo

spare dome
#

do you have a question?

modern creek
#

Are there any issues with networking in webgl builds? I was thinking of a side project using a socket-ish (Telepathy for C#) library and headless c# server, but it might be nice to be a web client. Obviously there's a host of other problems (load time, no access to file system, etc) but... I'm just in the daydreaming stage so none of that stuff matters anyway. ๐Ÿ™‚ FWIW I've built a mobile (and windows build) game with a server solution like this before so I could always go that route, but I'm just sorta thinking of the tech now

#

Another option would be a server that does everything with web based API calls but.. maybe makes for talking back to the clients harder without something like signalR

queen raft
#

if I use mousedelta from new input system (inputmap action), do I need to scale it based on platforms/window size? WebGL window size is small

modern creek
#

(Seems that WebGL pretty much doesn't allow anything in System.Net)

latent latch
#
int numColliders = Physics.OverlapSphereNonAlloc(potentialPosition, AvoidanceDistance, terrainColliders, AvoidanceLayers);
if (numColliders == 0)
{
    GameObject spawnedObject = Instantiate(spawn.ObjectToSpawn);
    spawnedObject.transform.SetParent(transform, false);
    spawnedObject.transform.SetPositionAndRotation(potentialPosition, Quaternion.identity);
    positionFound = true;
    spawnedObjects++;
}```
So I have a problem with a editor script such that instantiating an object like this does not seem to get caught by the next iteration's filtering. However, if I instantiate it all in one line such as:
```cs
int numColliders = Physics.OverlapSphereNonAlloc(potentialPosition, AvoidanceDistance, terrainColliders, AvoidanceLayers);
if (numColliders == 0)
{
    GameObject spawnedObject = Instantiate(spawn.ObjectToSpawn, potentialPosition, Quaternion.identity, transform);
    positionFound = true;
    spawnedObjects++;
}```
It works fine, but the reason I don't want to use this method is because I want to instantiate prefab instances via PrefabUtility but that doesn't have the same instantiation parameters.
#

My guess is those additional method calls don't update till next frame when I'm looping over everything in one.

little meadow
#

@latent latch you mean the physics thing doesn't detect it? If so, maybe you need to call Physics.SyncTransforms or something... Oh, actually you can probably also manually update RB.position/rotation (if you have such)

latent latch
#

takes a little longer but works ;)

modern creek
#

@latent latch Also, depending on what you mean by "get caught by the next iteration's filtering", your SetParent(transform, false) is different than just passing the transform of the parent

#

(I don't think you want false for the 2nd parameter)

latent latch
#

Yeah, I was toggling that back and forth but no go

#

what's odd though is it doesn't work in a prefab scene.

#

Need to drag the terrain out onto the main scene and run it

#

had to make my own billboard populater because the terrain's auto population doesnt work with spriterenders I guess

unborn elm
#

What is best practive if I have a script that adds a delagate to an action OnEnable but then potentailly wants to unsubscribe during update? Is there any problems with having both an condition -= as well as one on OnDisable?

#

Kind of like this:

    private void OnEnable()
    {
        RunningSceneActions.OmPlayerPosChanged += ChangePos;
    }
    private void OnDisable()
    {
        RunningSceneActions.OmPlayerPosChanged -= ChangePos;
    }
    private void ChangePos()
    {
        if (activated)
        {
            RunningSceneActions.OmPlayerPosChanged -= ChangePos;
        }
    }
#

I can of course use the bool for a check on disable, just wondering if there are better ways?

knotty sun
unborn elm
#

Cool, thank you, it seemed to work but didnt know if it could cause some wierd stuff that i didnt notice

knotty sun
unborn elm
#

Yeah that is really not a problem. Its just a collision detection thing that gets activated once the player is near, after that there is no need to turn it off again

knotty sun
unborn elm
#

haha

#

Yeah it is

#

Its not the actual code beeing used, just deleted a bunch of stuff to make the example clearer

#

Guess a added a typo

spice hill
#

I'm using a Character Controller for an endless runner, you can control horizontal movement. I want to apply a small amount of rotation when moving left or right to make the movement feel more fluid.

My issue is that I can't really get the rotation amount to be framerate independent. On lower FPS there will be more rotation, and higher FPS will have less rotation. I calculate the horizontal movement amount in Update, use characterController.Move, then call SmoothRotate(horizontalMovement). I've tried various things, but still wasn't able to make it framerate independent.

private void SmoothRotate(float horizontalMovement)
{
    float rotationAngle = horizontalMovement * rotationMultiplier;

    rotationAngle = Mathf.Clamp(rotationAngle, -maxRotationAngle, maxRotationAngle);

    Quaternion targetRotation = Quaternion.Euler(0, rotationAngle, 0);

    transform.rotation = Quaternion.RotateTowards(transform.rotation, targetRotation, rotationSpeed * Time.deltaTime);
}

Here's the full test character controller code: https://hatebin.com/dqfnvbipgz

unborn elm
#

Weird, shouldn the delta time handle that?

hexed pecan
#

Where does horizontalMovement come from?

spice hill
hexed pecan
#

Like SmoothRotate(direction.normalized * speed).x)

spice hill
hexed pecan
#

You are effectively passing in a target angle. There is no reason for it to be multiplied by delta time

#

Can't explain it better at least right now, I have barely woken up

#

With higher framerate your deltatime is smaller so your target angle got smaller too

#

At low fps you might be rotating towards 45 degrees but with high fps towards 10 degrees

spice hill
#

Thank you!

quiet terrace
#

Does anyone have any idea why this wouldnt go to the 2nd else if statement after the 1st one gets completed

#

When i click the button using the sapling (Currently holding 2) i get this. But when i change to the water pot (Currently holding 1) i get no response after clicking

#

hatebin doesnt seem to work for whatever reason so sorry for the picture

knotty sun
quiet terrace
#

So how would i make the statements go from the 1st to the 3rd in that order?

knotty sun
#

remove the else's of course

quiet terrace
#

The problem is, it still doesnt work because i did that inittialy

#

of course if thats what you meant

dusk apex
tawny elkBOT
gray mural
#

I have created a helper script, which is supposed to shift the initial color's brightness.

Color.RGBToHSV(_initialColor, out float h, out float s, out float v);
v *= 1 + value / 100f;

_color = Color.HSVToRGB(h, s, v);

I convert it to HSV, change its value and convert it back to RGB.
Having a pure blue initial color, it properly shifts it to black on shift decrease, but stops at (0, 0, 0.7490196) (RGB 0-1) once shift reaches > 0, where 0 is the initial color.
Is there any way to properly convert it, since I'm sure pure blue adjusted with G and B at least seems brighter?

gray mural
#

Correctly adjust color's brightness

wary veldt
#

So you guys know that there is the OnGUI method you use to draw gui on the unity game, right? So is there a way to make such a gui visible and interactable in VR? Without making entire gui as canvas and so on

rigid island
inner charm
#

Can I refer to a scene as an object? I'm thinking something like:

public Scene myScene;```

And via the inspector drag n drop a scene in the field?

I've been refering to scenes by their name, but it's kind of a hassle for me.
somber nacelle
#

no, you can use something like NaughtyAttributes or Odin Inspector which i believe both have an attribute to select a scene from a dropdown for an int or string variable. or you could write your own property drawer for it (i did this, it's not too difficult)

inner charm
gilded nymph
#

found a way to connect arduino to unity through serial ports. unlocks many interesting elements to my game

rigid island
#

i recommend you using structs to transfer larger data instead of sending strings, this allows to group data together rather than line by line or doing weird string tricks

gilded nymph
#

im working on an ai based game

#

with cameras and sensors

rigid island
#

would be interested to see

gilded nymph
#

sure

rigid island
#

working on a few hybrid projects myself

gilded nymph
#

as of now just managed to connect a joystick

gilded nymph
rigid island
#

thats pretty cool, I recall my first one I did a claw machine with real controls (joystick n buttons) xD

gilded nymph
#

especially ones with real life purposes

gilded nymph
#

when i was like 10

rigid island
#

in unity?

#

I did it for basically a virtual arcade sim that controls 3d arms in unity, was supposed to be a lan game but nothing came of it cause netcode got annoying with physics lol

indigo tree
rigid island
#

ig the trick is to try to mitigate the differences as much as possible? or use server simulated which looks like crap cause all clients are basically kinematic interpolating

lean sail
rigid island
indigo tree
#

But you can also program your own using fixed point math if you want to be simple

oblique spoke
# indigo tree Rapier

Seems like PhysX has pretty similar determinism guarantees as Rapier, which are that if the data is the same, everything is done in the same order, compiled on the same toolchain ..... it's deterministic on the same device.

#

There probably are some differences, but either way, there are many pitfalls.

indigo tree
inner charm
elfin tree
#

How can I check if a x euler angle rotation value is between -45 and 45 knowing that -45 reads as 360-45?

rigid island
elfin tree
#

ah, hmm

elfin tree
#

i get confused easily with modulo lol

rigid island
#

float normalizedAngle = ((angle + 180) % 360) - 180;
I think

elfin tree
#

i wonder if modulo is slightly more optimal

#

but i guess both are pretty close

#

it's not something that happens too often

rigid island
#

use whatever is most legible and make sense to you tbh

#

the difference are probably so minute they would serve no relevance

elfin tree
#

yeah i understand the first one better but i'd like to be able to think like the second one

#

i kinda get it cause i guess with that way it's at most 180 and then you remove 180 and you get a number between -45 and 45

rigid island
#

the +180 puts it in a positive range

#

the modulo is there to wrap it back, then -180 is just to get range -180 / 180

solemn arrow
#

hello does someone know about unity ads legacy for android?

stark plaza
#

Does it make sense to use Pub/Sub for unity or is it redundant ?

lean sail
stark plaza
#

Another weird question.
It's generally preferred to make Singletons for God classes such as GameManagers, AudioManagers etc etc because defining interface for those and use Service Locator would be just an overhead?

hidden compass
#

just have to use Singleton<Class> and tada, ๐Ÿฅณ you have urself a singleton

lean sail
wintry crescent
#

I have an insanely weird bug
Running this code makes the coroutine get stuck during the first yield
Changing Start() to OnEnable() solves the problem
What the heck is going on?

[SerializeField]
    private List<RectTransform> _titles;

    
    private void Start()
    {
        StartCoroutine(AnimTitle());
    }

    private IEnumerator AnimTitle()
    {
        foreach (var title in _titles)
        {
            title.localScale = Vector3.one * 30f;
        }
        foreach (var title in _titles)
        {
            var scale = title.DOScale(1f, 0.3f);
            scale.onComplete += () => _soundManager.CardPlayedSFX(CardPlayedSFX.Punch);
            Debug.Log(title);
            yield return new WaitForSeconds(0.5f);
            Debug.Log(title);
        }
    }
#

by stuck, I mean only one debug.log ever is displayed

mellow sigil
#

Disabling an object cancels its coroutines. So presumably the object gets disabled and OnEnable restarts the coroutine

wintry crescent
#

and it does not get disabled here

#

also I specifically mean the first time the coroutine runs

#

if it's called from within Start it stops, if it's called from within OnEnable it doesn't stop

mellow sigil
#

Put this in and see if it prints:

void OnDisable()
{
    Debug.Log("Object disabled and coroutines stopped");
}
wintry crescent
#

okay what the hell

mellow sigil
#

You can't see it in the hierarchy if it's disabled and enabled during the same frame for example

wintry crescent
#

I guess technically it does get disabled and enabled within the same frame at the beginning

#

thanks

proven marsh
#

Why does netcode for gameobjects change lightning of the scene when loading it with NetworkManager.Singleton.SceneManager.LoadScene? The right one is the correct one, and i am using unity 2022 built in rendered netcode for gameobjects v1.10.0

proven marsh
rigid island
#

nahh switching scenes in playmode without Lighting settings baked does this

proven marsh
#

alr thanks

jaunty sundial
#

Does anyone know why my particle system is visible over my UI elements

rigid island
ionic ermine
#

Okay I don't really know where to put this so it is going in here. It is not coding per say but it has to do with editing components of game objects so I hope this is the right place. Essentially, my problem is that I have a 1bit sprite that I'll attach, and I feel like there has to be some automated way to get the polygon collider for it. Especially because it is literally just squares. But I have looked into creating a custom physics shape from the sprite shape and all that but I run into a problem: the bounding box decides to be just a little bit too wide. And so the polygon collider is too big and that is obviously something I would prefer didn't happen

#

Here are some pictures

somber nacelle
ionic ermine
#

Ok cool sorry bout that

warm badger
#

!code

tawny elkBOT
warm badger
#
     [SerializeField] private AssetReference assetRef;
    public bool T;

    private void Update()
    {
        if (T)
        {
            StartCoroutine(InstantiateCoroutine());
        }
    }

    IEnumerator InstantiateCoroutine()
    {
        AsyncOperationHandle op = Addressables.InstantiateAsync(assetRef);
        yield return op;
    }
#

Here i want to instantiate an object using addressable only once when the bool turns true. but the code instantiates it infinite times, i know cz i am using it in update. But i don't know how to do it correctly to instantiate only once, what to do?

ocean hollow
warm badger
#

well, actually i want to use it based on distance proximity, when player is near the target, i want the object to instantiate only once, then what should i do? again i have many objects in the list to activate based of distance proximity

ocean hollow
warm badger
#

here is the actual siituation